[ossim] 01/10: New upstream version 2.2.0

Bas Couwenberg sebastic at debian.org
Sat Dec 9 13:32:25 UTC 2017


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

sebastic pushed a commit to branch experimental
in repository ossim.

commit b6b7a82f7efa28790bac52b6a23df008f672bb5b
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date:   Sat Dec 9 12:05:37 2017 +0100

    New upstream version 2.2.0
---
 CMakeLists.txt                                     |   31 +-
 apps/CMakeLists.txt                                |    8 +-
 apps/curl_apps/CMakeLists.txt                      |   11 -
 apps/curl_apps/omarDataMgrUtil.h                   |    4 +-
 apps/ossim-ogeom2ogeom/ossim-ogeom2ogeom.cpp       |   27 +-
 apps/ossim-rpcgen/CMakeLists.txt                   |    2 +
 apps/ossim-rpcgen/ossim-rpcgen.cpp                 |  278 ++
 cmake/CMakeLists.txt                               |   71 +-
 cmake/CMakeModules/FindAWS.cmake                   |   34 +-
 cmake/CMakeModules/FindCsmApi.cmake                |   50 +-
 cmake/CMakeModules/FindFFmpeg.cmake                |   67 +-
 cmake/CMakeModules/FindFreetype.cmake              |   17 +-
 cmake/CMakeModules/FindGEOS.cmake                  |   22 +-
 cmake/CMakeModules/FindGEOTIFF.cmake               |    7 +-
 cmake/CMakeModules/FindGeotrans.cmake              |   13 +-
 cmake/CMakeModules/FindHDF5.cmake                  |   25 +-
 cmake/CMakeModules/FindHDF5A.cmake                 |   30 +-
 cmake/CMakeModules/FindJPEG.cmake                  |   14 +-
 cmake/CMakeModules/FindJPEG12.cmake                |   14 +-
 cmake/CMakeModules/FindJsonCpp.cmake               |   32 +
 cmake/CMakeModules/FindLASzip.cmake                |   18 +-
 cmake/CMakeModules/FindLIBLAS.cmake                |   10 +-
 cmake/CMakeModules/FindMSP.cmake                   |  130 +-
 cmake/CMakeModules/FindOMS.cmake                   |   24 +-
 cmake/CMakeModules/FindOSG.cmake                   |   14 +-
 cmake/CMakeModules/FindOpenCV.cmake                |   20 +-
 cmake/CMakeModules/FindOpenJPEG.cmake              |   15 +-
 cmake/CMakeModules/FindOssimVideo.cmake            |   25 +-
 cmake/CMakeModules/FindOssimWMS.cmake              |   27 +-
 cmake/CMakeModules/FindPDAL.cmake                  |   28 +-
 cmake/CMakeModules/FindPodofo.cmake                |    5 +-
 cmake/CMakeModules/FindPotrace.cmake               |   26 +-
 cmake/CMakeModules/FindRapier.cmake                |   22 +-
 cmake/CMakeModules/FindSQLITE.cmake                |   11 +-
 cmake/CMakeModules/FindTIFF.cmake                  |   25 +-
 cmake/CMakeModules/Findossim.cmake                 |   19 +-
 cmake/CMakeModules/FindossimPlanet.cmake           |   24 +-
 cmake/CMakeModules/OssimCommonVariables.cmake      |   19 +-
 cmake/scripts/ossim-cmake-config.sh                |   10 +-
 include/ossim/base/Barrier.h                       |  126 +
 include/ossim/base/Block.h                         |  121 +
 .../base/{ossimBlockIStream.h => BlockIStream.h}   |    6 +-
 ...ssimBlockStreamBuffer.h => BlockStreamBuffer.h} |    2 +-
 include/ossim/base/FactoryListBase.h               |  152 +
 include/ossim/base/ItemCache.h                     |  409 ++
 include/ossim/base/RWLock.h                        |   88 +
 include/ossim/base/State.h                         |   48 +
 include/ossim/base/StateFactoryBase.h              |   19 +
 include/ossim/base/Thread.h                        |  223 +
 include/ossim/base/jsoncpp.h                       | 2085 --------
 include/ossim/base/ossim2dTo2dIdentityTransform.h  |    2 +-
 include/ossim/base/ossim2dTo2dMatrixTransform.h    |    2 +-
 include/ossim/base/ossim2dTo2dShiftTransform.h     |    2 +-
 include/ossim/base/ossim2dTo2dTransform.h          |    2 +-
 include/ossim/base/ossim2dTo2dTransformFactory.h   |    2 +-
 .../ossim/base/ossim2dTo2dTransformFactoryBase.h   |    2 +-
 include/ossim/base/ossim2dTo2dTransformRegistry.h  |    2 +-
 include/ossim/base/ossimBlockIStream.h             |    4 +-
 include/ossim/base/ossimCallback1.h                |    2 +-
 include/ossim/base/ossimCallback1wRet.h            |    2 +-
 include/ossim/base/ossimCallback2wRet.h            |    2 +-
 include/ossim/base/ossimCommon.h                   |    6 +-
 .../ossim/base/ossimConnectableDisplayListener.h   |    2 +-
 include/ossim/base/ossimConnectionEvent.h          |    2 +-
 include/ossim/base/ossimContainerEvent.h           |    2 +-
 include/ossim/base/ossimDataObject.h               |    2 +-
 include/ossim/base/ossimDate.h                     |    7 +-
 include/ossim/base/ossimDateProperty.h             |    2 +-
 include/ossim/base/ossimDatumFactoryRegistry.h     |    5 +-
 include/ossim/base/ossimDirectory.h                |    2 +-
 include/ossim/base/ossimDisplayInterface.h         |    2 +-
 include/ossim/base/ossimDpt3d.h                    |    2 +-
 include/ossim/base/ossimDrect.h                    |    2 +-
 include/ossim/base/ossimDuration.h                 |    2 +-
 include/ossim/base/ossimFactoryListInterface.h     |   56 +-
 include/ossim/base/ossimFileProcessorInterface.h   |    2 +-
 include/ossim/base/ossimGeoTiffDatumLut.h          |    2 +-
 include/ossim/base/ossimGeoidImage.h               |    2 +-
 include/ossim/base/ossimGrect.h                    |    2 +-
 include/ossim/base/ossimHistogramSource.h          |    2 +-
 include/ossim/base/ossimKeywordNames.h             |    1 +
 include/ossim/base/ossimKeywordlist.h              |    1 +
 include/ossim/base/ossimListener.h                 |    2 +-
 include/ossim/base/ossimLookUpTable.h              |    2 +-
 include/ossim/base/ossimMetadataInterface.h        |    2 +-
 include/ossim/base/ossimNBandLutDataObject.h       |    2 +-
 include/ossim/base/ossimNormRgbVector.h            |    2 +-
 include/ossim/base/ossimPointHash.h                |    2 +-
 include/ossim/base/ossimPolygon.h                  |    8 +-
 include/ossim/base/ossimProcessListener.h          |    2 +-
 include/ossim/base/ossimProcessProgressEvent.h     |    2 +-
 include/ossim/base/ossimPropertyInterface.h        |    2 +-
 include/ossim/base/ossimRectanglePartitioner.h     |    2 +-
 include/ossim/base/ossimRectilinearDataObject.h    |    2 +-
 include/ossim/base/ossimRefPtr.h                   |   29 +-
 include/ossim/base/ossimReferenced.h               |  123 +-
 include/ossim/base/ossimStdOutProgress.h           |    2 +-
 include/ossim/base/ossimStreamFactoryRegistry.h    |   16 +-
 include/ossim/base/ossimString.h                   |   23 +-
 include/ossim/base/ossimStringProperty.h           |    2 +-
 include/ossim/base/ossimTempFilename.h             |    2 +-
 include/ossim/base/ossimTerm.h                     |  240 +-
 .../base/ossimTieMeasurementGeneratorInterface.h   |    2 +-
 include/ossim/base/ossimTileHash.h                 |    2 +-
 include/ossim/base/ossimTiledImageHash.h           |    2 +-
 include/ossim/base/ossimTraceManager.h             |    2 +-
 include/ossim/base/ossimUnitConversionTool.h       |    2 +-
 include/ossim/base/ossimVrect.h                    |    2 +-
 .../ossim/elevation/ossimDtedElevationDatabase.h   |   17 +-
 include/ossim/elevation/ossimDtedFactory.h         |    2 +-
 include/ossim/elevation/ossimDtedHandler.h         |   76 +-
 include/ossim/elevation/ossimElevManager.h         |    4 +-
 include/ossim/elevation/ossimElevSourceFactory.h   |    2 +-
 .../ossim/elevation/ossimElevationCellDatabase.h   |    3 +-
 .../elevation/ossimElevationDatabaseFactory.h      |   79 +
 .../elevation/ossimElevationDatabaseRegistry.h     |   26 +
 .../elevation/ossimGeneralRasterElevHandler.h      |    5 +-
 .../ossimGeneralRasterElevationDatabase.h          |    2 +-
 .../ossim/elevation/ossimImageElevationDatabase.h  |    2 +-
 .../ossim/elevation/ossimImageElevationHandler.h   |    6 +-
 .../ossim/elevation/ossimSrtmElevationDatabase.h   |    2 +-
 include/ossim/elevation/ossimSrtmFactory.h         |    2 +-
 include/ossim/elevation/ossimSrtmHandler.h         |    3 +-
 .../ossim/elevation/ossimTiledElevationDatabase.h  |    2 +-
 include/ossim/font/ossimFontFactoryBase.h          |    2 +-
 include/ossim/hdf5/ossimHdf5GridModel.h            |    2 +-
 include/ossim/hdf5/ossimHdf5ImageDataset.h         |    2 +-
 include/ossim/hdf5/ossimHdf5ImageHandler.h         |    5 +-
 include/ossim/hdf5/ossimHdf5Info.h                 |    2 +-
 include/ossim/hdf5/ossimHdf5ProjectionFactory.h    |    2 +-
 include/ossim/imaging/ossim3x3ConvolutionFilter.h  |    2 +-
 include/ossim/imaging/ossimAOD.h                   |    2 +-
 include/ossim/imaging/ossimAdrgTileSource.h        |    2 +-
 include/ossim/imaging/ossimAppFixedTileCache.h     |    6 +-
 include/ossim/imaging/ossimAppTileCache.h          |    2 +-
 include/ossim/imaging/ossimAtCorrRemapper.h        |    2 +-
 include/ossim/imaging/ossimBandAverageFilter.h     |    2 +-
 include/ossim/imaging/ossimBandClipFilter.h        |    2 +-
 include/ossim/imaging/ossimBandLutFilter.h         |    2 +-
 include/ossim/imaging/ossimBandMergeSource.h       |    2 +-
 include/ossim/imaging/ossimBandSeparateHandler.h   |    2 +-
 include/ossim/imaging/ossimBitMaskTileSource.h     |    2 +-
 include/ossim/imaging/ossimBitMaskWriter.h         |    2 +-
 include/ossim/imaging/ossimBlendMosaic.h           |    2 +-
 include/ossim/imaging/ossimBrightnessMatch.h       |    2 +-
 include/ossim/imaging/ossimBumpShadeTileSource.h   |    2 +-
 include/ossim/imaging/ossimCacheTileSource.h       |    2 +-
 include/ossim/imaging/ossimCastTileSourceFilter.h  |    2 +-
 include/ossim/imaging/ossimCcfTileSource.h         |    2 +-
 .../ossim/imaging/ossimClosestToCenterCombiner.h   |    2 +-
 include/ossim/imaging/ossimCodecBase.h             |    3 +-
 include/ossim/imaging/ossimCodecFactory.h          |    2 +-
 include/ossim/imaging/ossimCodecFactoryInterface.h |    2 +-
 include/ossim/imaging/ossimColorNormalizedFusion.h |    2 +-
 include/ossim/imaging/ossimConvolutionFilter1D.h   |    2 +-
 include/ossim/imaging/ossimConvolutionSource.h     |    2 +-
 include/ossim/imaging/ossimDespeckleFilter.h       |    2 +-
 include/ossim/imaging/ossimDilationFilter.h        |    2 +-
 include/ossim/imaging/ossimDoqqTileSource.h        |    2 +-
 include/ossim/imaging/ossimDtedTileSource.h        |    2 +-
 include/ossim/imaging/ossimERSTileSource.h         |    2 +-
 include/ossim/imaging/ossimEdgeFilter.h            |    2 +-
 include/ossim/imaging/ossimElevImageSource.h       |    2 +-
 include/ossim/imaging/ossimElevationMosaic.h       |    2 +-
 include/ossim/imaging/ossimEnviHeaderFileWriter.h  |    2 +-
 include/ossim/imaging/ossimEnviTileSource.h        |    2 +-
 include/ossim/imaging/ossimEquationCombiner.h      |    2 +-
 include/ossim/imaging/ossimFeatherMosaic.h         |    2 +-
 include/ossim/imaging/ossimFftFilter.h             |    2 +-
 include/ossim/imaging/ossimFgdcFileWriter.h        |    2 +-
 include/ossim/imaging/ossimFilterResampler.h       |    2 +-
 include/ossim/imaging/ossimFilterTable.h           |    2 +-
 include/ossim/imaging/ossimFixedTileCache.h        |    6 +-
 include/ossim/imaging/ossimFusionCombiner.h        |    2 +-
 include/ossim/imaging/ossimGammaRemapper.h         |    2 +-
 include/ossim/imaging/ossimGeneralRasterInfo.h     |    4 +-
 include/ossim/imaging/ossimGeoAnnotationBitmap.h   |    2 +-
 include/ossim/imaging/ossimGeomFileWriter.h        |    2 +-
 include/ossim/imaging/ossimGridRemapEngine.h       |    2 +-
 include/ossim/imaging/ossimGridRemapSource.h       |    2 +-
 include/ossim/imaging/ossimHistoMatchRemapper.h    |    2 +-
 include/ossim/imaging/ossimHistogramEqualization.h |    2 +-
 .../ossim/imaging/ossimHistogramThreshholdFilter.h |    2 +-
 include/ossim/imaging/ossimHsiRemapper.h           |    2 +-
 include/ossim/imaging/ossimHsiToRgbSource.h        |    2 +-
 include/ossim/imaging/ossimHsvGridRemapEngine.h    |    2 +-
 include/ossim/imaging/ossimHsvToRgbSource.h        |    2 +-
 include/ossim/imaging/ossimImageChain.h            |    2 +-
 include/ossim/imaging/ossimImageData.h             |    6 +-
 include/ossim/imaging/ossimImageDataFactory.h      |    6 +-
 include/ossim/imaging/ossimImageGaussianFilter.h   |    2 +-
 include/ossim/imaging/ossimImageGeometry.h         |    2 +-
 include/ossim/imaging/ossimImageGeometryFactory.h  |    2 +-
 .../ossim/imaging/ossimImageGeometryFactoryBase.h  |    2 +-
 include/ossim/imaging/ossimImageGeometryRegistry.h |    2 +-
 include/ossim/imaging/ossimImageHandler.h          |   17 +-
 include/ossim/imaging/ossimImageHandlerFactory.h   |    1 +
 .../ossim/imaging/ossimImageHandlerFactoryBase.h   |    5 +
 include/ossim/imaging/ossimImageHandlerRegistry.h  |   26 +-
 .../imaging/ossimImageMetaDataWriterFactory.h      |    2 +-
 .../imaging/ossimImageMetaDataWriterFactoryBase.h  |    2 +-
 .../imaging/ossimImageMetaDataWriterRegistry.h     |    2 +-
 include/ossim/imaging/ossimImageModel.h            |    2 +-
 include/ossim/imaging/ossimImageMosaic.h           |    2 +-
 include/ossim/imaging/ossimImageRenderer.h         |    2 +-
 include/ossim/imaging/ossimImageSharpenFilter.h    |    2 +-
 include/ossim/imaging/ossimImageSource.h           |    2 +-
 include/ossim/imaging/ossimImageSourceFilter.h     |    2 +-
 include/ossim/imaging/ossimImageSourceSequencer.h  |    2 +-
 .../ossim/imaging/ossimImageToPlaneNormalFilter.h  |    2 +-
 include/ossim/imaging/ossimImageWriterFactory.h    |    2 +-
 .../imaging/ossimImageWriterFactoryRegistry.h      |    2 +-
 include/ossim/imaging/ossimIndexToRgbLutFilter.h   |    2 +-
 .../ossim/imaging/ossimIntensityAdjustmentFilter.h |    2 +-
 include/ossim/imaging/ossimJpegCodec.h             |   13 +-
 include/ossim/imaging/ossimJpegDefaultTable.h      |    2 +-
 include/ossim/imaging/ossimJpegTileSource.h        |    2 +-
 include/ossim/imaging/ossimJpegYCbCrToRgbSource.h  |    2 +-
 include/ossim/imaging/ossimLasReader.h             |    3 +-
 include/ossim/imaging/ossimLinearStretchRemapper.h |    2 +-
 include/ossim/imaging/ossimMapCompositionSource.h  |    2 +-
 include/ossim/imaging/ossimMaskFilter.h            |    2 +-
 include/ossim/imaging/ossimMaxMosaic.h             |    2 +-
 include/ossim/imaging/ossimMeanMedianFilter.h      |    2 +-
 include/ossim/imaging/ossimMetadataFileWriter.h    |    2 +-
 include/ossim/imaging/ossimMonoGridRemapEngine.h   |    2 +-
 include/ossim/imaging/ossimNBandToIndexFilter.h    |    2 +-
 include/ossim/imaging/ossimNitf20Writer.h          |    2 +-
 include/ossim/imaging/ossimNitfWriterBase.h        |    2 +-
 include/ossim/imaging/ossimNormalizedRemapTable.h  |    2 +-
 .../ossim/imaging/ossimNormalizedS16RemapTable.h   |    2 +-
 .../ossim/imaging/ossimNormalizedU11RemapTable.h   |    2 +-
 .../ossim/imaging/ossimNormalizedU12RemapTable.h   |    2 +-
 .../ossim/imaging/ossimNormalizedU13RemapTable.h   |    2 +-
 .../ossim/imaging/ossimNormalizedU14RemapTable.h   |    2 +-
 .../ossim/imaging/ossimNormalizedU15RemapTable.h   |    2 +-
 .../ossim/imaging/ossimNormalizedU16RemapTable.h   |    2 +-
 .../ossim/imaging/ossimNormalizedU8RemapTable.h    |    2 +-
 include/ossim/imaging/ossimNullPixelFlip.h         |    3 +-
 include/ossim/imaging/ossimOrthoImageMosaic.h      |    2 +-
 include/ossim/imaging/ossimOverviewBuilderBase.h   |    2 +-
 include/ossim/imaging/ossimPdfWriter.h             |    4 +-
 include/ossim/imaging/ossimPixelFlipper.h          |    6 +-
 include/ossim/imaging/ossimPolyCutter.h            |    2 +-
 include/ossim/imaging/ossimQbTileFilesHandler.h    |    2 +-
 .../ossim/imaging/ossimQuickbirdNitfTileSource.h   |    2 +-
 .../ossim/imaging/ossimQuickbirdTiffTileSource.h   |    2 +-
 include/ossim/imaging/ossimRLevelFilter.h          |    2 +-
 include/ossim/imaging/ossimRangeDomeTileSource.h   |    2 +-
 include/ossim/imaging/ossimReadmeFileWriter.h      |    2 +-
 include/ossim/imaging/ossimRectangleCutFilter.h    |    2 +-
 include/ossim/imaging/ossimRgbGridRemapEngine.h    |    2 +-
 include/ossim/imaging/ossimRgbToGreyFilter.h       |    2 +-
 include/ossim/imaging/ossimRgbToHsiSource.h        |    2 +-
 include/ossim/imaging/ossimRgbToHsvSource.h        |    2 +-
 include/ossim/imaging/ossimRgbToIndexFilter.h      |    2 +-
 include/ossim/imaging/ossimRgbToJpegYCbCrSource.h  |    2 +-
 include/ossim/imaging/ossimS16ImageData.h          |    2 +-
 include/ossim/imaging/ossimSFIMFusion.h            |    2 +-
 include/ossim/imaging/ossimScaleFilter.h           |    2 +-
 include/ossim/imaging/ossimShiftFilter.h           |    2 +-
 include/ossim/imaging/ossimSingleImageChain.h      |   31 +-
 include/ossim/imaging/ossimSrtmTileSource.h        |    2 +-
 include/ossim/imaging/ossimSubImageTileSource.h    |    2 +-
 include/ossim/imaging/ossimTiffOverviewBuilder.h   |    2 +-
 include/ossim/imaging/ossimTiffTileSource.h        |    7 +-
 include/ossim/imaging/ossimTileCache.h             |    2 +-
 include/ossim/imaging/ossimTilePatch.h             |    2 +-
 include/ossim/imaging/ossimTiledImageHandler.h     |    2 +-
 include/ossim/imaging/ossimTiling.h                |    2 +-
 include/ossim/imaging/ossimTilingPoly.h            |    2 +-
 include/ossim/imaging/ossimTilingRect.h            |    2 +-
 .../imaging/ossimTopographicCorrectionFilter.h     |    2 +-
 include/ossim/imaging/ossimTrimFilter.h            |    2 +-
 include/ossim/imaging/ossimTwoColorView.h          |    2 +-
 include/ossim/imaging/ossimU11ImageData.h          |    2 +-
 include/ossim/imaging/ossimU12ImageData.h          |    2 +-
 include/ossim/imaging/ossimU13ImageData.h          |    2 +-
 include/ossim/imaging/ossimU14ImageData.h          |    2 +-
 include/ossim/imaging/ossimU15ImageData.h          |    2 +-
 include/ossim/imaging/ossimU16ImageData.h          |    2 +-
 include/ossim/imaging/ossimU8ImageData.h           |    2 +-
 include/ossim/imaging/ossimUsgsDemTileSource.h     |    2 +-
 .../imaging/ossimValueAssignImageSourceFilter.h    |    2 +-
 .../ossim/imaging/ossimVpfAnnotationCoverageInfo.h |    2 +-
 .../ossim/imaging/ossimVpfAnnotationFeatureInfo.h  |    2 +-
 include/ossim/imaging/ossimVpfTileSource.h         |    2 +-
 include/ossim/imaging/ossimWatermarkFilter.h       |    2 +-
 include/ossim/parallel/ossimIgen.h                 |    2 +-
 include/ossim/parallel/ossimImageChainMtAdaptor.h  |    2 +-
 .../ossim/parallel/ossimImageHandlerMtAdaptor.h    |    5 +-
 .../ossimImageMpiMWriterSequenceConnection.h       |    2 +-
 .../ossimImageMpiSWriterSequenceConnection.h       |    2 +-
 include/ossim/parallel/ossimJob.h                  |  341 +-
 include/ossim/parallel/ossimJobMultiThreadQueue.h  |  137 +-
 include/ossim/parallel/ossimJobQueue.h             |  262 +-
 include/ossim/parallel/ossimJobThreadQueue.h       |  152 +-
 include/ossim/parallel/ossimMultiThreadSequencer.h |   27 +-
 include/ossim/plugin/ossimDynamicLibrary.h         |    2 +-
 include/ossim/plugin/ossimPluginConstants.h        |    2 +-
 .../point_cloud/ossimGenericPointCloudHandler.h    |    2 +-
 include/ossim/point_cloud/ossimPointBlock.h        |    2 +-
 .../ossim/point_cloud/ossimPointCloudGeometry.h    |    2 +-
 include/ossim/point_cloud/ossimPointCloudHandler.h |    2 +-
 .../point_cloud/ossimPointCloudHandlerFactory.h    |    2 +-
 .../point_cloud/ossimPointCloudHandlerRegistry.h   |    2 +-
 .../point_cloud/ossimPointCloudImageHandler.h      |    5 +-
 include/ossim/point_cloud/ossimPointCloudSource.h  |    2 +-
 .../point_cloud/ossimPointCloudUtilityFilter.h     |    2 +-
 include/ossim/point_cloud/ossimPointRecord.h       |    2 +-
 include/ossim/projection/ossimAdjMapModel.h        |    2 +-
 include/ossim/projection/ossimApplanixEcefModel.h  |    2 +-
 include/ossim/projection/ossimApplanixUtmModel.h   |    2 +-
 include/ossim/projection/ossimCadrgProjection.h    |    2 +-
 include/ossim/projection/ossimCoarseGridModel.h    |    2 +-
 .../ossim/projection/ossimEpsgProjectionDatabase.h |    5 +-
 include/ossim/projection/ossimGoogleProjection.h   |    2 +-
 include/ossim/projection/ossimIkonosRpcModel.h     |    2 +-
 .../ossim/projection/ossimImageProjectionModel.h   |    2 +-
 .../projection/ossimImageViewAffineTransform.h     |    2 +-
 include/ossim/projection/ossimLensDistortion.h     |    2 +-
 .../ossim/projection/ossimMapProjectionFactory.h   |    2 +-
 include/ossim/projection/ossimMapProjectionInfo.h  |    2 +-
 .../projection/ossimMeanRadialLensDistortion.h     |    2 +-
 .../ossim/projection/ossimNgaProjectionFactory.h   |    2 +-
 include/ossim/projection/ossimNitfRpcModel.h       |    2 +-
 include/ossim/projection/ossimQuickbirdRpcModel.h  |    2 +-
 include/ossim/projection/ossimRpcModel.h           |   22 +-
 include/ossim/projection/ossimRpcProjection.h      |    2 +-
 include/ossim/projection/ossimRpcSolver.h          |  143 +-
 include/ossim/projection/ossimUtmpt.h              |    4 +-
 include/ossim/support_data/ImageHandlerState.h     |  145 +
 .../ossim/support_data/ImageHandlerStateFactory.h  |   26 +
 .../ossim/support_data/ImageHandlerStateRegistry.h |   32 +
 include/ossim/support_data/TiffHandlerState.h      |  474 ++
 include/ossim/support_data/TiffStreamAdaptor.h     |   93 +
 include/ossim/support_data/ossimAuxFileHandler.h   |    2 +-
 .../ossim/support_data/ossimAuxXmlSupportData.h    |    2 +-
 include/ossim/support_data/ossimCcfInfo.h          |    2 +-
 include/ossim/support_data/ossimDemInfo.h          |    2 +-
 include/ossim/support_data/ossimDemStats.h         |    2 +-
 include/ossim/support_data/ossimDoqq.h             |    2 +-
 include/ossim/support_data/ossimDtedAcc.h          |    2 +-
 include/ossim/support_data/ossimDtedDsi.h          |    2 +-
 include/ossim/support_data/ossimDtedHdr.h          |    2 +-
 include/ossim/support_data/ossimDtedInfo.h         |    2 +-
 include/ossim/support_data/ossimDtedRecord.h       |    2 +-
 include/ossim/support_data/ossimDtedUhl.h          |    2 +-
 include/ossim/support_data/ossimDtedVol.h          |    2 +-
 include/ossim/support_data/ossimEnviInfo.h         |    2 +-
 include/ossim/support_data/ossimFgdcTxtDoc.h       |    2 +-
 include/ossim/support_data/ossimFgdcXmlDoc.h       |    2 +-
 include/ossim/support_data/ossimGeoTiff.h          |   16 +-
 include/ossim/support_data/ossimIkonosMetaData.h   |    2 +-
 .../{imaging => support_data}/ossimImageMetaData.h |    2 +-
 include/ossim/support_data/ossimInfoBase.h         |    2 +-
 .../ossim/support_data/ossimInfoFactoryRegistry.h  |    4 +-
 include/ossim/support_data/ossimJ2kInfo.h          |    2 +-
 include/ossim/support_data/ossimJp2Info.h          |    2 +-
 include/ossim/support_data/ossimJpipMessage.h      |    2 +-
 include/ossim/support_data/ossimLasHdr.h           |    2 +-
 include/ossim/support_data/ossimLasInfo.h          |    2 +-
 include/ossim/support_data/ossimNitfCommon.h       |    2 +-
 include/ossim/support_data/ossimNitfCscrnaTag.h    |    2 +-
 include/ossim/support_data/ossimNitfCsdidaTag.h    |    2 +-
 include/ossim/support_data/ossimNitfCsexraTag.h    |    2 +-
 .../ossim/support_data/ossimNitfDesInformation.h   |    2 +-
 .../ossim/support_data/ossimNitfEmbeddedRpfDes.h   |    2 +-
 include/ossim/support_data/ossimNitfEngrdaTag.h    |    2 +-
 .../support_data/ossimNitfGeoPositioningTag.h      |    2 +-
 include/ossim/support_data/ossimNitfJ2klraTag.h    |    2 +-
 .../support_data/ossimNitfLocalGeographicTag.h     |    2 +-
 include/ossim/support_data/ossimNitfMstgtaTag.h    |    2 +-
 .../support_data/ossimNitfNameConversionTables.h   |    2 +-
 include/ossim/support_data/ossimNitfPiaimcTag.h    |    2 +-
 .../support_data/ossimNitfProjectionParameterTag.h |    2 +-
 .../ossim/support_data/ossimNitfRegisteredDes.h    |    2 +-
 .../support_data/ossimNitfRegisteredDesFactory.h   |    2 +-
 .../support_data/ossimNitfRegisteredTagFactory.h   |    2 +-
 include/ossim/support_data/ossimNitfRpcATag.h      |    2 +-
 include/ossim/support_data/ossimNitfRpcBTag.h      |    2 +-
 include/ossim/support_data/ossimNitfRpcBase.h      |   16 +-
 .../ossim/support_data/ossimNitfRpfTagFactory.h    |    2 +-
 include/ossim/support_data/ossimNitfSensraTag.h    |    2 +-
 include/ossim/support_data/ossimNitfStdidcTag.h    |    2 +-
 include/ossim/support_data/ossimNitfStreobTag.h    |    2 +-
 include/ossim/support_data/ossimNitfUnknownTag.h   |    2 +-
 include/ossim/support_data/ossimNitfUse00aTag.h    |    2 +-
 .../support_data/ossimNitfVqCompressionHeader.h    |    2 +-
 .../support_data/ossimNitfXmlDataContentDes.h      |   14 +-
 include/ossim/support_data/ossimNmeaMessage.h      |    2 +-
 .../ossim/support_data/ossimQuickbirdMetaData.h    |    2 +-
 include/ossim/support_data/ossimRpfAttributes.h    |    2 +-
 .../ossim/support_data/ossimRpfCoverageSection.h   |    2 +-
 include/ossim/support_data/ossimRpfFrame.h         |    2 +-
 include/ossim/support_data/ossimRpfFrameEntry.h    |    2 +-
 include/ossim/support_data/ossimRpfHeader.h        |    2 +-
 .../ossimRpfImageDescriptionSubheader.h            |    2 +-
 include/ossim/support_data/ossimRpfInfo.h          |    2 +-
 .../ossim/support_data/ossimRpfLocationSection.h   |    2 +-
 include/ossim/support_data/ossimRpfToc.h           |    2 +-
 include/ossim/support_data/ossimRpfTocEntry.h      |    2 +-
 include/ossim/support_data/ossimSupportFilesList.h |    2 +-
 include/ossim/support_data/ossimWavelength.h       |    2 +-
 include/ossim/support_data/ossimWkt.h              |    2 +-
 include/ossim/support_data/ossimXmpInfo.h          |    2 +-
 include/ossim/util/ossimAutRegUtil.h               |    2 +-
 include/ossim/util/ossimChipperUtil.h              |    2 +-
 include/ossim/util/ossimFileWalker.h               |   19 +-
 include/ossim/util/ossimHlzTool.h                  |    9 +-
 include/ossim/util/ossimImageUtil.h                |    6 +-
 include/ossim/util/ossimInfo.h                     |    7 +
 include/ossim/util/ossimOrthoIgen.h                |    2 +-
 include/ossim/util/ossimRpfUtil.h                  |    2 +-
 include/ossim/util/ossimShorelineTool.h            |    8 +-
 include/ossim/util/ossimSubImageTool.h             |   68 +
 include/ossim/util/ossimViewshedTool.h             |   26 +-
 .../vec/ossimVpfDatabaseHeaderTableValidator.h     |    2 +-
 include/ossim/vec/ossimVpfTableValidator.h         |    2 +-
 include/ossim/vec/vpf.h                            |    2 +-
 share/ossim/templates/ossim_preferences_template   |   33 +
 src/CMakeLists.txt                                 |    9 +-
 src/base/Barrier.cpp                               |   72 +
 src/base/Block.cpp                                 |   84 +
 ...BlockStreamBuffer.cpp => BlockStreamBuffer.cpp} |   14 +-
 src/base/RWLock.cpp                                |   68 +
 src/base/State.cpp                                 |   16 +
 src/base/Thread.cpp                                |  132 +
 src/base/jsoncpp.cpp                               | 5206 --------------------
 src/base/ossimCommon.cpp                           |   17 +-
 src/base/ossimDate.cpp                             |    7 +-
 src/base/ossimEllipsoid.cpp                        |   19 +-
 src/base/ossimKeywordNames.cpp                     |    1 +
 src/base/ossimKeywordlist.cpp                      |   27 +-
 src/base/ossimNotify.cpp                           |   40 +-
 src/base/ossimPolyArea2d.cpp                       |    5 +-
 src/base/ossimPolygon.cpp                          |   13 +
 src/base/ossimPreferences.cpp                      |    6 +-
 src/base/ossimReferenced.cpp                       |   10 +-
 src/base/ossimStreamFactory.cpp                    |    2 +-
 src/base/ossimStreamFactoryRegistry.cpp            |   21 +-
 src/base/ossimString.cpp                           |    5 +-
 src/base/ossimTerm.cpp                             |    7 +-
 src/elevation/ossimDtedElevationDatabase.cpp       |   23 +-
 src/elevation/ossimDtedHandler.cpp                 |    2 +-
 src/elevation/ossimElevManager.cpp                 |    2 +-
 src/elevation/ossimElevationCellDatabase.cpp       |    4 +-
 src/elevation/ossimGeneralRasterElevHandler.cpp    |    5 +-
 src/elevation/ossimImageElevationDatabase.cpp      |    2 +-
 src/elevation/ossimImageElevationHandler.cpp       |    3 +-
 src/elevation/ossimSrtmHandler.cpp                 |    4 +-
 src/imaging/ossimAppFixedTileCache.cpp             |   29 +-
 src/imaging/ossimBandSelector.cpp                  |   12 +-
 src/imaging/ossimCacheTileSource.cpp               |    4 +-
 src/imaging/ossimCodecBase.cpp                     |    2 -
 src/imaging/ossimFixedTileCache.cpp                |   20 +-
 src/imaging/ossimGeneralRasterInfo.cpp             |    2 +-
 src/imaging/ossimImageDataFactory.cpp              |    2 +-
 src/imaging/ossimImageHandler.cpp                  |  276 +-
 src/imaging/ossimImageHandlerFactory.cpp           |   24 +
 src/imaging/ossimImageHandlerFactoryBase.cpp       |    5 +
 src/imaging/ossimImageHandlerRegistry.cpp          |  281 +-
 src/imaging/ossimImageRenderer.cpp                 |  320 +-
 src/imaging/ossimJpegCodec.cpp                     |   53 +-
 src/imaging/ossimNitfTileSource.cpp                |  110 +-
 src/imaging/ossimNitfWriterBase.cpp                |   15 +-
 src/imaging/ossimNullPixelFlip.cpp                 |    7 +-
 src/imaging/ossimOverviewSequencer.cpp             |    2 +-
 src/imaging/ossimPixelFlipper.cpp                  |   21 +-
 src/imaging/ossimSingleImageChain.cpp              |   54 +-
 src/imaging/ossimTiffTileSource.cpp                |  731 +--
 src/init/ossimInit.cpp                             |   27 +-
 src/ossimConfig.h.in                               |    3 +
 src/parallel/ossimImageHandlerMtAdaptor.cpp        |    6 +-
 src/parallel/ossimJob.cpp                          |   61 +-
 src/parallel/ossimJobMultiThreadQueue.cpp          |   61 +-
 src/parallel/ossimJobQueue.cpp                     |  145 +-
 src/parallel/ossimJobThreadQueue.cpp               |  140 +-
 src/parallel/ossimMultiThreadSequencer.cpp         |   36 +-
 src/plugin/ossimDynamicLibrary.cpp                 |    5 +-
 src/projection/ossimQuickbirdRpcModel.cpp          |   71 +-
 src/projection/ossimRpcModel.cpp                   |  145 +-
 src/projection/ossimRpcProjection.cpp              |  143 +-
 src/projection/ossimRpcSolver.cpp                  |  650 +--
 src/projection/ossimSensorModel.cpp                |    1 +
 src/projection/ossimSensorModelFactory.cpp         |   23 +-
 src/projection/ossimTiffProjectionFactory.cpp      |   39 +-
 src/support_data/ImageHandlerState.cpp             |  121 +
 src/support_data/ImageHandlerStateFactory.cpp      |   54 +
 src/support_data/ImageHandlerStateRegistry.cpp     |   43 +
 src/support_data/TiffHandlerState.cpp              |  822 ++++
 src/support_data/TiffStreamAdaptor.cpp             |   99 +
 src/support_data/ossimAlphaSensorSupportData.cpp   |   16 +-
 src/support_data/ossimGeoTiff.cpp                  |  234 +-
 .../ossimImageMetaData.cpp                         |    3 +-
 src/support_data/ossimInfoBase.cpp                 |    4 +-
 src/support_data/ossimNitfRpcBase.cpp              |   39 +
 src/support_data/ossimNitfXmlDataContentDes.cpp    |   72 +-
 src/support_data/ossimTiffInfo.cpp                 |   17 +-
 src/util/ossimBatchTest.cpp                        |    2 +-
 src/util/ossimChipperUtil.cpp                      |   12 +
 src/util/ossimFileWalker.cpp                       |   52 +-
 src/util/ossimHlzTool.cpp                          |   28 +-
 src/util/ossimInfo.cpp                             |  137 +-
 src/util/ossimShorelineTool.cpp                    |   10 +-
 src/util/ossimSubImageTool.cpp                     |  287 ++
 src/util/ossimToolFactory.cpp                      |    6 +
 src/util/ossimViewshedTool.cpp                     |   20 +-
 test/src/base/ossim-ref-ptr-test.cpp               |   31 +-
 test/src/base/ossim-string-test.cpp                |    8 +
 test/src/base/ossim-threaded-logfile-test.cpp      |   20 +-
 test/src/base/ossim-threaded-polyarea2d-test.cpp   |   20 +-
 .../elevation/ossim-threaded-elevation-test.cpp    |   27 +-
 test/src/imaging/CMakeLists.txt                    |    2 +
 .../src/imaging/ossim-image-handler-state-test.cpp |  185 +
 test/src/imaging/ossim-piecewise-remapper-test.cpp |    8 +-
 test/src/imaging/ossim-single-image-chain-test.cpp |    3 +-
 .../imaging/ossim-threaded-app-tile-cache-test.cpp |   18 +-
 test/src/imaging/ossim-threaded-chain-test.cpp     |    2 +-
 test/src/ossim-foo.cpp                             |   74 +-
 test/src/parallel/ossim-jobqueue-test.cpp          |   33 +-
 521 files changed, 9225 insertions(+), 10739 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 90f27e4..2eb0a66 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,6 +1,10 @@
 PROJECT(ossim)
 SET(CMAKE_MODULE_PATH "${${PROJECT_NAME}_SOURCE_DIR}/cmake/CMakeModules;${CMAKE_MODULE_PATH}")
 
+set(CMAKE_CXX_STANDARD 11)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
+set(CMAKE_CXX_EXTENSIONS OFF)
+
 Message("################## Setting up OSSIM core library #########################")
 
 IF(NOT OSSIM_BUILD_ADDITIONAL_OSSIM_DIRECTORIES)
@@ -16,10 +20,6 @@ include(CMakeDetermineSystem)
 INCLUDE(OssimVersion)
 INCLUDE(OssimCommonVariables)
 
-set(CMAKE_CXX_STANDARD 11)
-set(CMAKE_CXX_STANDARD_REQUIRED ON)
-set(CMAKE_CXX_EXTENSIONS OFF)
-
 # Expose some build options
 set(LIB_NAME ossim CACHE STRING "Name of ossim libray (default is ossim).")
 OPTION(BUILD_OSSIM_FREETYPE_SUPPORT "Set to ON to build OSSIM with freetype support.  Use OFF to turn off freetype support." ON)
@@ -65,6 +65,14 @@ else( GEOS_FOUND )
    message( FATAL_ERROR "Could not find geos package! Consider installing this as it will soon become a required package." )
 endif( GEOS_FOUND )
 
+find_package( JsonCpp QUIET)
+if( JSONCPP_FOUND )
+   include_directories( ${JSONCPP_INCLUDE_DIR} )
+   set( ossimDependentLibs ${ossimDependentLibs} ${JSONCPP_LIBRARY} )
+else( JSONCPP_FOUND )
+   message("Could not find JSONCPP package! Consider installing this as it will soon become a required package." )
+endif( JSONCPP_FOUND )
+
 # GEOFIFF - Required:
 set( OSSIM_HAS_GEOTIFF 0 )
 find_package( GEOTIFF )
@@ -94,15 +102,6 @@ else( JPEG_FOUND )
    message( FATAL_ERROR "Could not find required jpeg package!" )
 endif( JPEG_FOUND )
 
-# OpenThreads - Required:
-find_package( OpenThreads )
-if( OPENTHREADS_FOUND )
-   include_directories( ${OPENTHREADS_INCLUDE_DIR} )
-   set( ossimDependentLibs ${ossimDependentLibs} ${OPENTHREADS_LIBRARY} )
-else( OPENTHREADS_FOUND )
-   message( FATAL_ERROR "Could not find required OpenThreads package!" )
-endif( OPENTHREADS_FOUND )
-
 # TIFF - Required:
 find_package( TIFF )
 if( TIFF_FOUND )
@@ -187,6 +186,8 @@ else (BUILD_OSSIM_HDF5_SUPPORT)
 endif ( BUILD_OSSIM_HDF5_SUPPORT )
 
 
+find_package( Threads )
+set( ossimDependentLibs ${ossimDependentLibs} ${CMAKE_THREAD_LIBS_INIT} )
 
 #---
 # Call the OSSIM macros in OssimUtilities.cmake
@@ -200,6 +201,8 @@ if ( NOT ${Project_WC_REVISION} EQUAL 0 )
    set( OSSIM_GIT_REVISION_NUMBER ${Project_WC_REVISION} )
 endif()
 
+
+
 #####################################################################################
 # Call the configure files for ossimConfig and ossimVersion setup
 #####################################################################################
@@ -228,7 +231,7 @@ CONFIGURE_FILE("${OSSIM_VERSION_HEADER_CONFIG}"
 ##################################################################################################
 subdirs(src)
 
-set(TARGET_COMMON_LIBRARIES ossim ${OPENTHREADS_LIBRARY})
+set(TARGET_COMMON_LIBRARIES ossim)
 
 ##################################################################################################
 #
diff --git a/apps/CMakeLists.txt b/apps/CMakeLists.txt
index 46d05ca..a068560 100644
--- a/apps/CMakeLists.txt
+++ b/apps/CMakeLists.txt
@@ -3,12 +3,6 @@ FILE(GLOB OSSIM_CONFIG_DIR "ossim-config*")
 LIST(REMOVE_ITEM OSSIM_APP_DIRS ${OSSIM_CONFIG_DIR})
 
 # FIND_PACKAGE(ossim)
-# FIND_PACKAGE( OpenThreads )
-# if( OPENTHREADS_FOUND )
-#    include_directories( ${OPENTHREADS_INCLUDE_DIR} )
-# else( OPENTHREADS_FOUND )
-#    message( FATAL_ERROR "Could not find required OpenThreads package!" )
-# endif( OPENTHREADS_FOUND )
 
 # if( OSSIM_FOUND )
 #    include_directories( ${OSSIM_INCLUDE_DIR} )
@@ -19,4 +13,4 @@ LIST(REMOVE_ITEM OSSIM_APP_DIRS ${OSSIM_CONFIG_DIR})
 
 FOREACH(f ${OSSIM_APP_DIRS})
    ADD_SUBDIRECTORY(${f})
-ENDFOREACH(f)
\ No newline at end of file
+ENDFOREACH(f)
diff --git a/apps/curl_apps/CMakeLists.txt b/apps/curl_apps/CMakeLists.txt
index de08755..a434bac 100644
--- a/apps/curl_apps/CMakeLists.txt
+++ b/apps/curl_apps/CMakeLists.txt
@@ -14,15 +14,6 @@ else()
    set(LIBSUFFIX "")
 endif()
 
-# OpenThreads - Required:
-find_package( OpenThreads )
-if( OPENTHREADS_FOUND )
-   include_directories( ${OPENTHREADS_INCLUDE_DIR} )
-   set( requiredLibs ${requiredLibs} ${OPENTHREADS_LIBRARY} )
-else( OPENTHREADS_FOUND )
-   message( FATAL_ERROR "Could not find required OpenThreads package!" )
-endif( OPENTHREADS_FOUND )
-
 find_package( CURL )
 if( CURL_FOUND )
    include_directories( ${CURL_INCLUDE_DIR} )
@@ -45,8 +36,6 @@ include_directories(".")
 
 message( STATUS "CURL_INCLUDE_DIR    = ${CURL_INCLUDE_DIR}" )
 message( STATUS "CURL_LIBRARY        = ${CURL_LIBRARY}" )
-message( STATUS "OPENTHREADS_LIBRARY = ${OPENTHREADS_LIBRARY}" )
-message( STATUS "OPENTHREADS_INCLUDE = ${OPENTHREADS_INCLUDE_DIR}" )
 message( STATUS "OSSIM_INCLUDE_DIR   = ${OSSIM_INCLUDE_DIR}" )
 message( STATUS "OSSIM_LIBRARIES     = ${OSSIM_LIBRARIES}" )
 message( STATUS "Required libs       = ${requiredLibs}" )
diff --git a/apps/curl_apps/omarDataMgrUtil.h b/apps/curl_apps/omarDataMgrUtil.h
index d89f674..f36e375 100644
--- a/apps/curl_apps/omarDataMgrUtil.h
+++ b/apps/curl_apps/omarDataMgrUtil.h
@@ -22,9 +22,9 @@
 #include <ossim/base/ossimRefPtr.h>
 #include <ossim/util/ossimImageUtil.h>
 
-#include <OpenThreads/Mutex>
 #include <ostream>
 #include <vector>
+#include <mutex>
 
 class ossimArgumentParser;
 class ossimFileWalker;
@@ -268,7 +268,7 @@ private:
    ossimRefPtr<ossimKeywordlist> m_kwl;
 
    ossimFileWalker*   m_fileWalker;
-   OpenThreads::Mutex m_mutex;
+   std::mutex m_mutex;
 
    ossimRefPtr<ossimImageUtil> m_imageUtil;
    ossim_int32 m_errorStatus;
diff --git a/apps/ossim-ogeom2ogeom/ossim-ogeom2ogeom.cpp b/apps/ossim-ogeom2ogeom/ossim-ogeom2ogeom.cpp
index b501ac1..446fdb7 100644
--- a/apps/ossim-ogeom2ogeom/ossim-ogeom2ogeom.cpp
+++ b/apps/ossim-ogeom2ogeom/ossim-ogeom2ogeom.cpp
@@ -13,6 +13,7 @@
 #include <ossim/projection/ossimProjection.h>
 #include <ossim/projection/ossimRpcSolver.h>
 #include <sstream>
+
 int main(int argc, char* argv[])
 {
    ossimString tempString1;
@@ -143,16 +144,22 @@ int main(int argc, char* argv[])
       if(rpcFlag)
       {
          ossimRefPtr<ossimRpcSolver> solver = new ossimRpcSolver(enableElevFlag);
-         
-         solver->solveCoefficients(imageRect,
-                                  geom.get(),
-                                  rpcGridSize.x,
-                                  rpcGridSize.y);
-         
-         ossimRefPtr<ossimImageGeometry> outputProj = solver->createRpcProjection();
-         kwl.clear();
-         outputProj->saveState(kwl);
-         kwl.write(outputFile);
+         ossimDrect imageBounds;
+         geom->getBoundingRect(imageBounds);
+         bool converged = solver->solve(imageBounds, geom.get());
+         if (converged)
+         {
+            ossimRefPtr<ossimRpcModel> rpc = solver->getRpcModel();
+            ossimRefPtr<ossimImageGeometry> rpcgeom = new ossimImageGeometry(nullptr, rpc.get());
+            ossimKeywordlist kwl;
+            rpcgeom->saveState(kwl);
+            kwl.write(outputFile);
+         }
+         else
+         {
+            ossimNotify(ossimNotifyLevel_FATAL) << "ERROR: Unable to converge on desired error tolerance." << std::endl;
+            exit(1);
+         }
       }
       else if(cgFlag)
       {
diff --git a/apps/ossim-rpcgen/CMakeLists.txt b/apps/ossim-rpcgen/CMakeLists.txt
new file mode 100644
index 0000000..b452dcf
--- /dev/null
+++ b/apps/ossim-rpcgen/CMakeLists.txt
@@ -0,0 +1,2 @@
+FILE(GLOB SOURCE_FILES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp")
+OSSIM_SETUP_APPLICATION(ossim-rpcgen INSTALL COMMAND_LINE COMPONENT_NAME ossim SOURCE_FILES ${SOURCE_FILES})
diff --git a/apps/ossim-rpcgen/ossim-rpcgen.cpp b/apps/ossim-rpcgen/ossim-rpcgen.cpp
new file mode 100644
index 0000000..b9832da
--- /dev/null
+++ b/apps/ossim-rpcgen/ossim-rpcgen.cpp
@@ -0,0 +1,278 @@
+#include <ossim/init/ossimInit.h>
+#include <ossim/base/ossimNotifyContext.h>
+#include <ossim/base/ossimArgumentParser.h>
+#include <ossim/base/ossimApplicationUsage.h>
+#include <ossim/base/ossimTrace.h>
+#include <ossim/base/ossimKeywordNames.h>
+#include <ossim/base/ossimRefPtr.h>
+#include <ossim/imaging/ossimImageGeometry.h>
+#include <ossim/imaging/ossimImageHandler.h>
+#include <ossim/imaging/ossimImageHandlerRegistry.h>
+#include <ossim/projection/ossimProjectionFactoryRegistry.h>
+#include <ossim/projection/ossimProjection.h>
+#include <ossim/projection/ossimRpcSolver.h>
+#include <sstream>
+#include <ossim/base/ossimXmlDocument.h>
+
+using namespace std;
+
+int main(int argc, char* argv[])
+{
+   ossimString tempString1;
+   ossimString tempString2;
+   ossimString tempString3;
+   ossimString tempString4;
+   ossimArgumentParser::ossimParameter tempParam1(tempString1);
+   ossimArgumentParser::ossimParameter tempParam2(tempString2);
+   ossimArgumentParser::ossimParameter tempParam3(tempString3);
+   ossimArgumentParser::ossimParameter tempParam4(tempString4);
+   ossimArgumentParser argumentParser(&argc, argv);
+   ossimInit::instance()->addOptions(argumentParser);
+   ossimInit::instance()->initialize(argumentParser);
+   bool rpcFlag       = false;
+   bool cgFlag       = false;
+   ossimDrect imageRect;
+   double error = 0.1;
+
+   imageRect.makeNan();
+   ossimApplicationUsage* au = argumentParser.getApplicationUsage();
+
+   au->setApplicationName(argumentParser.getApplicationName());
+   au->setDescription(
+         argumentParser.getApplicationName() + " takes an input image and generates a "
+         "corresponding RPC geometry in a variety of formats. If a bounding box is specified, the "
+         "default output filename (based on the input filename) will be appended with the bbox spec"
+         ", unless an output filename is explicitely provided.");
+   au->setCommandLineUsage(
+         argumentParser.getApplicationName() + " [options] <input-file> [<output-file>]");
+   au->addCommandLineOption(
+         "-h | --help","Display this information");
+   au->addCommandLineOption(
+         "--bbox <ulx> <uly> <lrx> <lry>","Subimage rectangle in image space for constraining "
+         "RPC computation over the AOI only. Note that the RPC image space UL corner will "
+         "correspond to (0,0), i.e., the model will be shifted from the original full-image model.");
+   au->addCommandLineOption(
+         "--tolerance <double>","Used as an RMS error tolerance in meters between original model "
+         "and RPC.");
+   au->addCommandLineOption(
+         "--geom <format>", "Specifies format of the subimage RPC geometry file."
+         " Possible values are: \"OGEOM\" (OSSIM geometry, default), \"DG\" (DigitalGlobe WV/QB "
+         ".RPB format), \"JSON\" (MSP-style JSON), or \"XML\". Case insensitive.");
+   
+   int numArgs = argumentParser.argc();
+   if (argumentParser.read("-h") || argumentParser.read("--help") || (numArgs == 1))
+   {
+      au->write(ossimNotify(ossimNotifyLevel_INFO));
+      ossimInit::instance()->finalize();
+      exit(0);
+   }
+
+   enum RpcGeomFormat { OGEOM, DG, JSON, XML } rpcGeomFormat=OGEOM;
+
+   ossimFilename geomFile, jsonFile, xmlFile, rpbFile;
+   ossimString suffix;
+   ossimIpt rpcGridSize(10,10);
+
+   if(argumentParser.read("--tolerance", tempParam1))
+      error = tempString1.toDouble();
+
+   if(argumentParser.read("--bbox", tempParam1,tempParam2,tempParam3,tempParam4 ))
+   {
+      double ulx,uly,lrx,lry,flip;
+      ulx = tempString1.toDouble();
+      uly = tempString2.toDouble();
+      lrx = tempString3.toDouble();
+      lry = tempString4.toDouble();
+
+      if (lrx < ulx)
+      {
+         flip = ulx; ulx = lrx; lrx = flip;
+      }
+      if (lry < uly)
+      {
+         flip = uly; uly = lry; lry = flip;
+      }
+
+      imageRect = ossimDrect(ulx,uly,lrx,lry);
+      ostringstream s;
+      s<<"_bbox-"<<ulx<<"-"<<uly<<"-"<<lrx<<"-"<<lry;
+      suffix = s.str();
+   }
+
+   if ( argumentParser.read("--geom", tempParam1))
+   {
+      ossimString formatStr (tempString1);
+      formatStr.upcase();
+      if (formatStr == "OGEOM")
+         rpcGeomFormat = OGEOM;
+      else if (formatStr == "DG")
+         rpcGeomFormat = DG;
+      else if (formatStr == "JSON")
+         rpcGeomFormat = JSON;
+      else if (formatStr == "XML")
+         rpcGeomFormat = XML;
+      else
+      {
+         ostringstream errMsg;
+         errMsg << " ERROR: ossimSubImageTool ["<<__LINE__<<"] Unknown geometry format <"
+               <<formatStr<<"> specified. Aborting." << endl;
+         throw ossimException( errMsg.str() );
+      }
+   }
+   argumentParser.reportRemainingOptionsAsUnrecognized();
+   if (argumentParser.errors())
+   {
+      argumentParser.writeErrorMessages(std::cout);
+      exit(1);
+   }
+
+   // Read remaining args as input and optional output filenames:
+   if (argumentParser.argc() < 2)
+   {
+      ossimNotify(ossimNotifyLevel_WARN)<<"ERROR: Need an input filename."<<endl;
+      au->write(ossimNotify(ossimNotifyLevel_INFO));
+      ossimInit::instance()->finalize();
+      exit(0);
+   }
+   ossimFilename inputFile (argumentParser[1]);
+   ossimFilename outputFile;
+   if (argumentParser.argc() > 2)
+      outputFile = argumentParser[2];
+
+   // Establish input geometry:
+   ossimRefPtr<ossimImageHandler> h = ossimImageHandlerRegistry::instance()->open(inputFile);
+   ossimRefPtr<ossimProjection> inputProj = 0;
+   ossim_int32 minSpacing = 100;
+   ossimRefPtr<ossimImageGeometry> geom;
+   if(h.valid())
+   {
+      geom = h->getImageGeometry();
+      if(imageRect.hasNans())
+         imageRect = h->getBoundingRect();
+   }
+   else
+   {
+      ossimNotify(ossimNotifyLevel_FATAL) << "ERROR: Unable to open the image file <"<<inputFile<<">" << std::endl;
+      au->write(ossimNotify(ossimNotifyLevel_INFO));
+      exit(1);
+   }
+   if (!geom || !geom->getProjection())
+   {
+      ossimNotify(ossimNotifyLevel_FATAL) << "ERROR: Unable to obtain an input projection. " << std::endl;
+      exit(1);
+   }
+   if(imageRect.hasNans())
+   {
+      ossimNotify(ossimNotifyLevel_FATAL) << "ERROR: Unable to establish the image bounding rect." << std::endl;
+      exit(1);
+   }
+
+   // First consider if the input is already an RPC (type B), and if so, simply copy it:
+   ossimRefPtr<ossimRpcModel> rpc;
+   ossimRpcModel* inputRpc = dynamic_cast<ossimRpcModel*>(geom->getProjection());
+   if (inputRpc)
+   {
+      ossimNotify(ossimNotifyLevel_INFO) << "\nThe input image is already using RPC. Simply copying "
+            "the coefficients to the output with offset (if any) applied..." << std::endl;
+      rpc = inputRpc;
+   }
+   else
+   {
+      // Solve for replacement RPC:
+      ossimNotify(ossimNotifyLevel_INFO) << "\nSolving for RPC coefficients..." << std::endl;
+      ossimRefPtr<ossimRpcSolver> solver = new ossimRpcSolver(true, false);
+      bool converged = solver->solve(imageRect, geom.get(), error);
+      double meanResidual = solver->getRmsError();
+      double maxResidual = solver->getMaxError();
+      rpc = solver->getRpcModel();
+   }
+
+   // Apply the offset to the bbox so that the RPC image-space coordinates will start at 0,0:
+   rpc->setImageOffset(imageRect.ul());
+   ossimRefPtr<ossimImageGeometry> rpcgeom = new ossimImageGeometry(nullptr, rpc.get());
+   rpcgeom->setImageSize(imageRect.size());
+   ossimKeywordlist kwl;
+   rpcgeom->saveState(kwl);
+
+   // Write output file(s):
+   bool write_ok = false;
+   switch (rpcGeomFormat)
+   {
+   case JSON:
+   {
+#if OSSIM_HAS_JSONCPP
+      if (outputFile)
+         jsonFile = outputFile;
+      else
+         jsonFile = inputFile.fileNoExtension()+suffix;
+      jsonFile.setExtension("json");
+      ossimNotify(ossimNotifyLevel_INFO) << "\nWriting RPC JSON file to <"<<jsonFile<<">." << endl;
+      ofstream jsonStream (jsonFile.string());
+      if (!jsonStream.fail())
+      {
+         write_ok = rpc->toJSON(jsonStream);
+         jsonStream.close();
+      }
+#else
+      ossimNotify(ossimNotifyLevel_FATAL) << "ERROR: JSON output requested but JSON is not "
+            "available in this build! <"<< std::endl;
+      exit(1);
+#endif
+      break;
+   }
+
+   case DG:
+   {
+      if (outputFile)
+         rpbFile = outputFile;
+      else
+         rpbFile = inputFile.fileNoExtension()+suffix;
+      rpbFile.setExtension("RPB");
+      ossimNotify(ossimNotifyLevel_INFO) << "\nWriting RPB file to <"<<rpbFile<<">." << endl;
+      ofstream rpbStream (rpbFile.string());
+      if (!rpbStream.fail())
+      {
+         write_ok = rpc->toRPB(rpbStream);
+         rpbStream.close();
+      }
+      break;
+   }
+
+   case XML:
+   {
+      if (outputFile)
+         xmlFile = outputFile;
+      else
+         xmlFile = inputFile.fileNoExtension()+suffix;
+      xmlFile.setExtension("xml");
+      ossimNotify(ossimNotifyLevel_INFO) << "\nWriting RPC XML file to <"<<xmlFile<<">." << endl;
+      ossimXmlDocument xmlDocument;
+      xmlDocument.fromKwl(kwl);
+      write_ok = xmlDocument.write(xmlFile);
+      break;
+   }
+
+   case OGEOM:
+   default:
+   {
+      if (outputFile)
+         geomFile = outputFile;
+      else
+         geomFile = inputFile.fileNoExtension()+suffix;
+      geomFile.setExtension("geom");
+      ossimNotify(ossimNotifyLevel_INFO) << "\nWriting RPC geometry file to <"<<geomFile<<">." << endl;
+      write_ok = kwl.write(geomFile);
+      break;
+   }
+   }
+
+   if (write_ok)
+      ossimNotify(ossimNotifyLevel_INFO)<<"Finished.\n"<<endl;
+   else
+   {
+      ossimNotify(ossimNotifyLevel_FATAL) << "Error encountered writing output RPC file." << std::endl;
+      exit(1);
+   }
+
+   return 0;
+}
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
index ca74d92..1dd79f1 100644
--- a/cmake/CMakeLists.txt
+++ b/cmake/CMakeLists.txt
@@ -1,6 +1,7 @@
 PROJECT(ossimlabs)
 
 # Allows developer to customize compiler with their own flags (e.g., "-std=c++11")
+
 SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} $ENV{OSSIM_CXX_FLAGS}" )
 
 IF ("${OSSIM_DEV_HOME}"  STREQUAL "")
@@ -11,25 +12,25 @@ IF ("${OSSIM_DEV_HOME}"  STREQUAL "")
   ENDIF()
 ENDIF()
 
-IF ("$ENV{OSSIM_INSTALL_PREFIX}"  STREQUAL "")
-  SET(OSSIM_INSTALL_PREFIX "${OSSIM_DEV_HOME}/install" CACHE STRING "Cache the OSSIM install prefix" FORCE)
-ELSE()
-  SET(OSSIM_INSTALL_PREFIX "$ENV{OSSIM_INSTALL_PREFIX}" CACHE STRING "Cache the OSSIM install prefix" FORCE)
+if(NOT EXISTS ${OSSIM_DEV_HOME})
+   MESSAGE(FATAL_ERROR "Please pass in or define a valid OSSIM_DEV_HOME root path where all modules are located. This includes ossim, ossim-planet, ... etc.")
 ENDIF()
 
-IF ("$ENV{OSSIM_DEPENDENCIES}"  STREQUAL "")
-  SET(OSSIM_DEPENDENCIES "${OSSIM_INSTALL_PREFIX}" CACHE STRING "Cache the OSSIM dependency dir" FORCE)
+IF ("$ENV{OSSIM_INSTALL_PREFIX}"  STREQUAL "")
+   IF (EXISTS "$ENV{OSSIM_BUILD_DIR}")
+      SET(OSSIM_INSTALL_PREFIX "$ENV{OSSIM_BUILD_DIR}" CACHE STRING "Cache the OSSIM install prefix" FORCE)
+   ELSE()
+      SET(OSSIM_INSTALL_PREFIX "${OSSIM_DEV_HOME}/install" CACHE STRING "Cache the OSSIM install prefix" FORCE)
+   ENDIF()
 ELSE()
-  SET(OSSIM_DEPENDENCIES "$ENV{OSSIM_DEPENDENCIES}" CACHE STRING "Cache the OSSIM dependency dir" FORCE)
+  SET(OSSIM_INSTALL_PREFIX "$ENV{OSSIM_INSTALL_PREFIX}" CACHE STRING "Cache the OSSIM install prefix" FORCE)
 ENDIF()
 
-SET(CMAKE_MODULE_PATH "${OSSIM_DEV_HOME}/ossim/cmake/CMakeModules")
-SET(CMAKE_INSTALL_PREFIX ${OSSIM_INSTALL_PREFIX})
-
 IF(NOT OSSIM_BUILD_ADDITIONAL_DIRECTORIES)
    SET(OSSIM_BUILD_ADDITIONAL_DIRECTORIES "" CACHE PATH "Specify full paths separated by ; to additional libraries you wish to include into the ossim build framework" FORCE)
 ENDIF(NOT OSSIM_BUILD_ADDITIONAL_DIRECTORIES)
 
+SET(CMAKE_MODULE_PATH "${OSSIM_DEV_HOME}/ossim/cmake/CMakeModules")
 INCLUDE(OssimVersion)
 INCLUDE(OssimUtilities)
 INCLUDE(OssimCommonVariables)
@@ -40,23 +41,32 @@ ELSE(NOT APPLE)
     cmake_minimum_required(VERSION 2.8)
 ENDIF(NOT APPLE)
 
-
-if(NOT OSSIM_DEV_HOME)
-   MESSAGE(FATAL_ERROR "Please pass in or define the OSSIM_DEV_HOME root path where all modules are located. This includes ossim, ossim-planet, ... etc.")
-ENDIF(NOT OSSIM_DEV_HOME)
-
-#IF(NOT APPLE)
-#  cmake_minimum_required(VERSION 2.6)
-#ELSE(NOT APPLE)
-#  cmake_minimum_required(VERSION 2.8)
-#ENDIF(NOT APPLE)
-
 IF(EXISTS "$ENV{OSSIM_DEPENDENCIES}")
-   SET(CMAKE_INCLUDE_PATH "${CMAKE_INCLUDE_PATH};$ENV{OSSIM_DEPENDENCIES}/include")
-   SET(CMAKE_LIBRARY_PATH "${CMAKE_LIBRARY_PATH};$ENV{OSSIM_DEPENDENCIES}/lib")
+   SET(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} ${OSSIM_DEPENDENCIES}/include )
+   SET(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} ${OSSIM_DEPENDENCIES}/lib${LIBSUFFIX})
    SET(CMAKE_FRAMEWORK_PATH "${CMAKE_FRAMEWORK_PATH};$ENV{OSSIM_DEPENDENCIES}/Frameworks")
 ENDIF(EXISTS "$ENV{OSSIM_DEPENDENCIES}")
 
+SET(CMAKE_INSTALL_PREFIX ${OSSIM_INSTALL_PREFIX})
+
+MESSAGE( STATUS "\n========================== CMAKE FINAL SETTINGS ==========================" )
+MESSAGE( STATUS "CMAKE_MODULE_PATH           = ${CMAKE_MODULE_PATH}")
+MESSAGE( STATUS "CMAKE_IGNORE_PATH           = ${CMAKE_IGNORE_PATH}")
+MESSAGE( STATUS "CMAKE_INCLUDE_PATH          = ${CMAKE_INCLUDE_PATH}")
+MESSAGE( STATUS "CMAKE_LIBRARY_PATH          = ${CMAKE_LIBRARY_PATH}")
+MESSAGE( STATUS "CMAKE_PREFIX_PATH           = ${CMAKE_PREFIX_PATH}")
+MESSAGE( STATUS "CMAKE_INSTALL_PREFIX        = ${CMAKE_INSTALL_PREFIX}")
+MESSAGE( STATUS "CMAKE_FRAMEWORK_PATH        = ${CMAKE_FRAMEWORK_PATH}")
+MESSAGE( STATUS "CMAKE_FIND_ROOT_PATH        = ${CMAKE_FIND_ROOT_PATH}")
+MESSAGE( STATUS "CMAKE_FIND_LIBRARY_PREFIXES = ${CMAKE_FIND_LIBRARY_PREFIXES}")
+MESSAGE( STATUS "CMAKE_FIND_LIBRARY_SUFFIXES = ${CMAKE_FIND_LIBRARY_SUFFIXES}")
+MESSAGE( STATUS "CMAKE_SYSTEM_IGNORE_PATH    = ${CMAKE_SYSTEM_IGNORE_PATH}")
+MESSAGE( STATUS "CMAKE_SYSTEM_INCLUDE_PATH   = ${CMAKE_SYSTEM_INCLUDE_PATH}")
+MESSAGE( STATUS "CMAKE_SYSTEM_LIBRARY_PATH   = ${CMAKE_SYSTEM_LIBRARY_PATH}")
+MESSAGE( STATUS "CMAKE_SYSTEM_PREFIX_PATH    = ${CMAKE_SYSTEM_PREFIX_PATH}")
+MESSAGE( STATUS "CMAKE_SYSTEM_IGNORE_PATH    = ${CMAKE_SYSTEM_IGNORE_PATH}")
+MESSAGE( STATUS "\n" )
+
 
 #######################################################################################################
 #  Initialize the libraries to be the cmake targets and initialize the includes to the proper dev paths
@@ -112,8 +122,12 @@ IF(BUILD_OSSIM_VIDEO AND EXISTS ${OSSIM_DEV_HOME}/ossim-video)
   add_subdirectory(${OSSIM_DEV_HOME}/ossim-video ${CMAKE_CURRENT_BINARY_DIR}/ossim-video)
 ENDIF()
 
-IF(BUILD_OSSIM_ISA AND EXISTS ${OSSIM_DEV_HOME}/ossim-isa)
-  add_subdirectory(${OSSIM_DEV_HOME}/ossim-isa ${CMAKE_CURRENT_BINARY_DIR}/ossim-isa)
+IF(BUILD_ISA_PLUGIN AND EXISTS ${OSSIM_DEV_HOME}/ossim-isa-plugin)
+  add_subdirectory(${OSSIM_DEV_HOME}/ossim-isa-plugin ${CMAKE_CURRENT_BINARY_DIR}/ossim-isa-plugin)
+ENDIF()
+
+IF(BUILD_CSM_PLUGIN AND EXISTS ${OSSIM_DEV_HOME}/ossim-csm-plugin)
+  add_subdirectory(${OSSIM_DEV_HOME}/ossim-csm-plugin ${CMAKE_CURRENT_BINARY_DIR}/ossim-csm-plugin)
 ENDIF()
 
 IF(BUILD_OMS AND EXISTS ${OSSIM_DEV_HOME}/ossim-oms)
@@ -170,10 +184,6 @@ IF(OSSIM_BUILD_ADDITIONAL_DIRECTORIES)
     ENDFOREACH(it)
 ENDIF()
 
-IF(BUILD_CSMAPI AND EXISTS ${OSSIM_DEV_HOME}/csmApi)
-    add_subdirectory(${OSSIM_DEV_HOME}/csmApi ${CMAKE_CURRENT_BINARY_DIR}/csmApi)
-ENDIF()
-
 IF(BUILD_DSMG AND EXISTS ${OSSIM_DEV_HOME}/ossim-dsmg)
   add_subdirectory(${OSSIM_DEV_HOME}/ossim-dsmg ${CMAKE_CURRENT_BINARY_DIR}/ossim-dsmg)
 ENDIF()
@@ -355,5 +365,6 @@ MESSAGE( STATUS "BUILD_OSSIM_WMS                 = ${BUILD_OSSIM_WMS}" )
 MESSAGE( STATUS "BUILD_LIBRARY_DIR               = ${BUILD_LIBRARY_DIR}" )
 MESSAGE( STATUS "BUILD_RUNTIME_DIR               = ${BUILD_RUNTIME_DIR}" )
 MESSAGE( STATUS "BUILD_DSMG                      = ${BUILD_DSMG}" )
-MESSAGE( STATUS "BUILD_OSSIM_ISA                 = ${BUILD_OSSIM_ISA}" )
+MESSAGE( STATUS "BUILD_ISA_PLUGIN                = ${BUILD_ISA_PLUGIN}" )
+MESSAGE( STATUS "BUILD_CSM_PLUGIN                = ${BUILD_CSM_PLUGIN}" )
 MESSAGE( STATUS "Use OSSIM_BUILD_ADDITIONAL_DIRECTORIES to add other cmake builds." )
diff --git a/cmake/CMakeModules/FindAWS.cmake b/cmake/CMakeModules/FindAWS.cmake
index cb5c0d2..b998724 100644
--- a/cmake/CMakeModules/FindAWS.cmake
+++ b/cmake/CMakeModules/FindAWS.cmake
@@ -25,23 +25,15 @@
 # Find include path:
 #---
 find_path( AWS_CORE_INCLUDE_DIR aws/core/Aws.h
-           PATHS 
-           ${CMAKE_INSTALL_PREFIX}/include
-           $ENV{AWS_DIR}/include
-           ${AWS_DIR}/include
-           /usr/include
-           /usr/local/include
-           /usr/local/ossim/include )
+         PATHS 
+            $ENV{AWS_DIR}/include
+            ${AWS_DIR}/include)
 
 # We need this so check for it:
 find_path( AWS_S3_INCLUDE_DIR aws/s3/S3Client.h
-           PATHS 
-           ${CMAKE_INSTALL_PREFIX}/include
-           $ENV{AWS_DIR}/include
-           ${AWS_DIR}/include
-           /usr/include
-           /usr/local/include
-           /usr/local/ossim/include )
+          PATHS 
+            $ENV{AWS_DIR}/include
+            ${AWS_DIR}/include)
 
 # Set the AWS_INCLUDE_DIR:
 if( AWS_CORE_INCLUDE_DIR AND AWS_S3_INCLUDE_DIR )
@@ -49,20 +41,10 @@ if( AWS_CORE_INCLUDE_DIR AND AWS_S3_INCLUDE_DIR )
 endif( AWS_CORE_INCLUDE_DIR AND AWS_S3_INCLUDE_DIR )
 
 # Find AWS CPP SDK CORE library:
-find_library( AWS_CORE_LIB NAMES aws-cpp-sdk-core 
-              PATHS
-              ${CMAKE_INSTALL_PREFIX}/lib64
-              ${CMAKE_INSTALL_PREFIX}/lib
-              /usr/lib64 
-              /usr/lib )
+find_library( AWS_CORE_LIB NAMES aws-cpp-sdk-core )
 
 # Find AWS CPP SDK S3 library:
-find_library( AWS_S3_LIB NAMES aws-cpp-sdk-s3
-              PATHS 
-              ${CMAKE_INSTALL_PREFIX}/lib64
-              ${CMAKE_INSTALL_PREFIX}/lib
-              /usr/lib64 
-              /usr/lib )
+find_library( AWS_S3_LIB NAMES aws-cpp-sdk-s3)
 
 # Set the AWS_LIBRARY:
 if( AWS_CORE_LIB AND AWS_S3_LIB )
diff --git a/cmake/CMakeModules/FindCsmApi.cmake b/cmake/CMakeModules/FindCsmApi.cmake
index 1e80ad1..d975699 100644
--- a/cmake/CMakeModules/FindCsmApi.cmake
+++ b/cmake/CMakeModules/FindCsmApi.cmake
@@ -1,27 +1,23 @@
 # - Find csmApi library
 # Find the native csmApi includes and library
 # This module defines
-#  CSMAPI_INCLUDE_DIRS, where to find cam api headers, etc.
-#  CSMAPI_LIBRARIES, libraries to link against to use csmApi.
+#  CSMAPI_INCLUDE_DIR, where to find cam api headers, etc.
+#  CSMAPI_LIBRARY, where to find the CSMAPI library.
 #  CSMAPI_FOUND, If false, do not try to use csmApi.
 # also defined, but not for general use are
-#  CSMAPI_LIBRARY, where to find the CSMAPI library.
+#
+# NOTE: If MSP Distro is available, CSM can be found there.
+
 SET(CMAKE_FIND_FRAMEWORK "LAST")
-FIND_PATH(CSMAPI_INCLUDE_DIRS csm/csm.h
+FIND_PATH(CSMAPI_INCLUDE_DIR csm/csm.h
         PATHS
-        $ENV{MSP_HOME}/include/common
-        ${OSSIM_DEPENDENCIES}/include
-		${OSSIM_INSTALL_PREFIX}/include
-)
+   		${MSP_HOME}/include/common
+	     	${CSM_HOME}/include)
 
-set(CSMAPI_NAMES ${CSMAPI_NAMES} MSPcsm csmapi )
-find_library(CSMAPI_LIBRARY NAMES ${CSMAPI_NAMES}
-   PATHS
-      $ENV{MSP_HOME}/lib
-      ${OSSIM_INSTALL_PREFIX}/lib${LIBSUFFIX}
-      ${OSSIM_DEPENDENCIES}/lib
-      ${OSSIM_INSTALL_PREFIX}
-)
+find_library(CSMAPI_LIBRARY NAMES MSPcsmapi csmapi
+	     PATHS
+		    ${MSP_HOME}/lib
+		    ${CSM_HOME}/lib)
 
 #---
 # This function sets CSMAPI_FOUND if variables are valid.
@@ -29,20 +25,14 @@ find_library(CSMAPI_LIBRARY NAMES ${CSMAPI_NAMES}
 include(FindPackageHandleStandardArgs)
 find_package_handle_standard_args( CSMAPI DEFAULT_MSG 
                                    CSMAPI_LIBRARY 
-                                   CSMAPI_INCLUDE_DIRS )
-
-if(CSMAPI_FOUND)
-   set( CSMAPI_LIBRARIES ${CSMAPI_LIBRARY} )
-   set( CSMAPI_INCLUDES  ${CSMAPI_INCLUDE_DIRS} )
-else( CSMAPI_FOUND )
+                                   CSMAPI_INCLUDE_DIR )
+if ( NOT CSMAPI_FOUND )
+   message( WARNING "Could not find CSMAPI" )
+else ()
    if( NOT CSMAPI_FIND_QUIETLY )
-      message( WARNING "Could not find CSMAPI" )
+      message( STATUS "CSMAPI_INCLUDE_DIR=${CSMAPI_INCLUDE_DIR}" )
+      message( STATUS "CSMAPI_LIBRARY=${CSMAPI_LIBRARY}" )
    endif( NOT CSMAPI_FIND_QUIETLY )
-endif(CSMAPI_FOUND)
-
-if( NOT CSMAPI_FIND_QUIETLY )
-   message( STATUS "CSMAPI_INCLUDE_DIRS=${CSMAPI_INCLUDE_DIRS}" )
-   message( STATUS "CSMAPI_LIBRARIES=${CSMAPI_LIBRARIES}" )
-endif( NOT CSMAPI_FIND_QUIETLY )
+endif (NOT CSMAPI_FOUND)
 
-mark_as_advanced(CSMAPI_INCLUDES CSMAPI_INCLUDE_DIRS CSMAPI_LIBRARIES)
+mark_as_advanced(CSMAPI_INCLUDE_DIR CSMAPI_LIBRARY)
diff --git a/cmake/CMakeModules/FindFFmpeg.cmake b/cmake/CMakeModules/FindFFmpeg.cmake
index 5d6cbb1..9ce2fde 100644
--- a/cmake/CMakeModules/FindFFmpeg.cmake
+++ b/cmake/CMakeModules/FindFFmpeg.cmake
@@ -29,17 +29,15 @@ MACRO(FFMPEG_FIND varname shortname headername)
 
     FIND_PATH(FFMPEG_${varname}_INCLUDE_DIRS lib${shortname}/${headername}
         PATHS
-        ${FFMPEG_ROOT}/include
-        $ENV{FFMPEG_DIR}/include
-        ~/Library/Frameworks
-        /Library/Frameworks
-        /usr/local/include
-        /usr/include
-        /sw/include # Fink
-        /opt/local/include # DarwinPorts
-        /opt/csw/include # Blastwave
-        /opt/include
-        /usr/freeware/include
+           ${FFMPEG_ROOT}/include
+           $ENV{FFMPEG_DIR}/include
+           ~/Library/Frameworks
+           /Library/Frameworks
+           /sw/include # Fink
+           /opt/local/include # DarwinPorts
+           /opt/csw/include # Blastwave
+           /opt/include
+           /usr/freeware/include
         PATH_SUFFIXES ffmpeg
         DOC "Location of FFMPEG Headers"
     )
@@ -47,40 +45,31 @@ MACRO(FFMPEG_FIND varname shortname headername)
     if( FFMPEG_${varname}_INCLUDE_DIRS-NOTFOUND )
        FIND_PATH(FFMPEG_${varname}_INCLUDE_DIRS ${headername}
           PATHS
-          ${FFMPEG_ROOT}/include
-          $ENV{FFMPEG_DIR}/include
-          ~/Library/Frameworks
-          /Library/Frameworks
-          /usr/local/include
-          /usr/include
-          /sw/include # Fink
-          /opt/local/include # DarwinPorts
-          /opt/csw/include # Blastwave
-          /opt/include
-          /usr/freeware/include
+             ${FFMPEG_ROOT}/include
+             $ENV{FFMPEG_DIR}/include
+             ~/Library/Frameworks
+             /Library/Frameworks
+             /sw/include # Fink
+             /opt/local/include # DarwinPorts
+             /opt/csw/include # Blastwave
+             /opt/include
+             /usr/freeware/include
           PATH_SUFFIXES ffmpeg
           DOC "Location of FFMPEG Headers"
        )
     endif ( FFMPEG_${varname}_INCLUDE_DIRS-NOTFOUND )
 
     FIND_LIBRARY(FFMPEG_${varname}_LIBRARIES
-        NAMES ${shortname}
-        PATHS
-        ${FFMPEG_ROOT}/lib
-        $ENV{FFMPEG_DIR}/lib
-        ~/Library/Frameworks
-        /Library/Frameworks
-        /usr/local/lib
-        /usr/local/lib64
-        /usr/lib
-        /usr/lib64
-        /sw/lib
-        /opt/local/lib
-        /opt/csw/lib
-        /opt/lib
-        /usr/freeware/lib64
-        DOC "Location of FFMPEG Libraries"
-    )
+         NAMES ${shortname}
+      	PATHS
+      		${FFMPEG_ROOT}
+      		$ENV{FFMPEG_DIR}
+      		~/Library
+      		/Library
+      	PATH_SUFFIXES
+      		lib64
+      		lib
+      		Frameworks )
 
     IF (FFMPEG_${varname}_LIBRARIES AND FFMPEG_${varname}_INCLUDE_DIRS)
         SET(FFMPEG_${varname}_FOUND 1)
diff --git a/cmake/CMakeModules/FindFreetype.cmake b/cmake/CMakeModules/FindFreetype.cmake
index 7d46d15..8e57112 100644
--- a/cmake/CMakeModules/FindFreetype.cmake
+++ b/cmake/CMakeModules/FindFreetype.cmake
@@ -56,12 +56,9 @@ find_path(
   ft2build.h
   HINTS
     ENV FREETYPE_DIR
+    ENV GTKMM_BASEPATH
   PATHS
-    /usr/X11R6
-    /usr/local/X11R6
-    /usr/local/X11
     /usr/freeware
-    ENV GTKMM_BASEPATH
     [HKEY_CURRENT_USER\\SOFTWARE\\gtkmm\\2.4;Path]
     [HKEY_LOCAL_MACHINE\\SOFTWARE\\gtkmm\\2.4;Path]
   PATH_SUFFIXES
@@ -70,19 +67,15 @@ find_path(
     freetype2
 )
 
-find_path(
-  FREETYPE_INCLUDE_DIR_freetype2
+find_path(FREETYPE_INCLUDE_DIR_freetype2
   NAMES
     freetype/config/ftheader.h
     config/ftheader.h
   HINTS
     ENV FREETYPE_DIR
+    ENV GTKMM_BASEPATH
   PATHS
-    /usr/X11R6
-    /usr/local/X11R6
-    /usr/local/X11
     /usr/freeware
-    ENV GTKMM_BASEPATH
     [HKEY_CURRENT_USER\\SOFTWARE\\gtkmm\\2.4;Path]
     [HKEY_LOCAL_MACHINE\\SOFTWARE\\gtkmm\\2.4;Path]
   PATH_SUFFIXES
@@ -99,15 +92,13 @@ find_library(FREETYPE_LIBRARY
   HINTS
     ENV FREETYPE_DIR
   PATHS
-    /usr/X11R6
-    /usr/local/X11R6
-    /usr/local/X11
     /usr/freeware
     ENV GTKMM_BASEPATH
     [HKEY_CURRENT_USER\\SOFTWARE\\gtkmm\\2.4;Path]
     [HKEY_LOCAL_MACHINE\\SOFTWARE\\gtkmm\\2.4;Path]
   PATH_SUFFIXES
     lib
+    lib64
 )
 
 # set the user variables
diff --git a/cmake/CMakeModules/FindGEOS.cmake b/cmake/CMakeModules/FindGEOS.cmake
index d4f5ec8..461d46d 100644
--- a/cmake/CMakeModules/FindGEOS.cmake
+++ b/cmake/CMakeModules/FindGEOS.cmake
@@ -29,36 +29,20 @@
 
 find_path( GEOS_INCLUDE_DIR geos/geom/Geometry.h
            PATHS 
-           ${CMAKE_INSTALL_PREFIX}/include
            $ENV{GEOS_DIR}/include
-           ${GEOS_DIR}/include
-           /usr/include
-           /usr/local/include
-           /usr/local/ossim/include )
+           ${GEOS_DIR}/include)
 
 # Find GEOS library:
 find_library( GEOS_LIB NAMES geos 
               PATHS
-              ${CMAKE_INSTALL_PREFIX}/lib
-              ${OSSIM_DEPENCIES}/lib
               $ENV{GEOS_DIR}/lib
-              ${GEOS_DIR}/lib
-              /usr/lib64 
-              /usr/lib
-              /usr/local/lib
-              /usr/local/ossim/lib )
+              ${GEOS_DIR}/lib)
 
 # Find GEOS C library:
 find_library( GEOS_C_LIB NAMES geos_c 
               PATHS 
-              ${CMAKE_INSTALL_PREFIX}/lib
-              ${OSSIM_DEPENCIES}/lib
               $ENV{GEOS_DIR}/lib
-              ${GEOS_DIR}/lib
-              /usr/lib64 
-              /usr/lib 
-              /usr/local/lib
-              /usr/local/ossim/lib )
+              ${GEOS_DIR}/lib)
 
 # Set the GEOS_LIBRARY:
 if( GEOS_LIB AND GEOS_C_LIB )
diff --git a/cmake/CMakeModules/FindGEOTIFF.cmake b/cmake/CMakeModules/FindGEOTIFF.cmake
index a06a151..c84639e 100644
--- a/cmake/CMakeModules/FindGEOTIFF.cmake
+++ b/cmake/CMakeModules/FindGEOTIFF.cmake
@@ -10,7 +10,6 @@
 FIND_PATH(GEOTIFF_INCLUDE_DIR geotiff.h 
           PATHS 
           $ENV{GEOTIFF_DIR}/include
-          ${CMAKE_INSTALL_PREFIX}/include
           /usr/include/geotiff 
           /usr/include/libgeotiff 
           /usr/local/include/libgeotiff 
@@ -21,11 +20,7 @@ FIND_LIBRARY(GEOTIFF_LIBRARY
              NAMES ${GEOTIFF_NAMES}
              PATHS 
              $ENV{GEOTIFF_DIR}/lib
-             $ENV{GEOTIFF_DIR}/lib64
-             ${CMAKE_INSTALL_PREFIX}/lib 
-             /usr/local/lib 
-             /usr/lib 
-             /usr/lib/x86_64-linux-gnu)
+             $ENV{GEOTIFF_DIR}/lib64)
 
 # handle the QUIETLY and REQUIRED arguments and set GEOTIFF_FOUND to TRUE if 
 # all listed variables are TRUE
diff --git a/cmake/CMakeModules/FindGeotrans.cmake b/cmake/CMakeModules/FindGeotrans.cmake
index 9816af3..19fd55e 100644
--- a/cmake/CMakeModules/FindGeotrans.cmake
+++ b/cmake/CMakeModules/FindGeotrans.cmake
@@ -26,19 +26,10 @@
 # Note: Version < 3.3.0 do not have geos.h in the geos sub directory; hence,
 # the check for both "geos/geos.h" and "geos.h".
 #---
-find_path( GEOTRANS_INCLUDE_DIR geotrans/geotrans_config.h
-           PATHS 
-           /usr/include
-           /usr/local/include
-           /usr/local/ossim/include )
+find_path( GEOTRANS_INCLUDE_DIR geotrans/geotrans_config.h)
 
 # Find Geotrans library:
-find_library( Geotrans_LIB NAMES geotrans 
-              PATHS 
-              /usr/lib64 
-              /usr/lib 
-              /usr/local/lib
-              /usr/local/ossim/lib )
+find_library( Geotrans_LIB NAMES geotrans )
 
 # Set the Geotrans_LIBRARY:
 if( Geotrans_LIB )
diff --git a/cmake/CMakeModules/FindHDF5.cmake b/cmake/CMakeModules/FindHDF5.cmake
index d65e32b..a18df13 100644
--- a/cmake/CMakeModules/FindHDF5.cmake
+++ b/cmake/CMakeModules/FindHDF5.cmake
@@ -18,32 +18,13 @@
 #---
 
 # Find include path:
-find_path( HDF5_INCLUDE_DIR hdf5.h
-           PATHS 
-           $ENV{HDF5_DIR}/include
-           /usr/include
-           /usr/local/include
-           /usr/local/ossim/include )
+find_path( HDF5_INCLUDE_DIR hdf5.h PATHS $ENV{HDF5_DIR}/include)
 
 # Find HDF5 library:
-find_library( HDF5_LIB NAMES hdf5
-              PATHS
-              $ENV{HDF5_DIR}/lib64
-              $ENV{HDF5_DIR}/lib
-              /usr/lib64
-              /usr/lib
-              /usr/local/lib
-              /usr/local/ossim/lib )
+find_library( HDF5_LIB NAMES hdf5 PATHS $ENV{HDF5_DIR})
 
 # Find HDF5 CPP library:
-find_library( HDF5_CPP_LIB NAMES hdf5_cpp
-              PATHS
-              $ENV{HDF5_DIR}/lib64
-              $ENV{HDF5_DIR}/lib
-              /usr/lib64
-              /usr/lib
-              /usr/local/lib
-              /usr/local/ossim/lib )
+find_library( HDF5_CPP_LIB NAMES hdf5_cpp PATHS $ENV{HDF5_DIR})
 
 # Set the HDF5_LIBRARIES:
 if( HDF5_LIB AND HDF5_CPP_LIB )
diff --git a/cmake/CMakeModules/FindHDF5A.cmake b/cmake/CMakeModules/FindHDF5A.cmake
index c2c25b8..e92a257 100644
--- a/cmake/CMakeModules/FindHDF5A.cmake
+++ b/cmake/CMakeModules/FindHDF5A.cmake
@@ -18,37 +18,19 @@
 #---
 
 # Find include path:
-find_path( HDF5A_INCLUDE_DIR hdf5.h
-           PATHS 
-           ${CMAKE_INSTALL_PREFIX}/include
-           $ENV{HDF5_DIR}/include
-           /usr/include
-           /usr/local/include
-           /usr/local/ossim/include )
+find_path( HDF5A_INCLUDE_DIR hdf5.h PATHS  $ENV{HDF5_DIR}/include)
 
 # Find HDF5A library:
-find_library( HDF5A_LIB NAMES hdf5a hdf5
+find_library( HDF5A_LIB NAMES hdf5a hdf5 
               PATHS
-              $ENV{HDF5_DIR}/lib64
-              $ENV{HDF5_DIR}/lib
-              ${CMAKE_INSTALL_PREFIX}/lib64
-              /usr/lib64
-              ${CMAKE_INSTALL_PREFIX}/lib
-              /usr/lib
-              /usr/local/lib
-              /usr/local/ossim/lib )
+               $ENV{HDF5_DIR}/lib64
+               $ENV{HDF5_DIR}/lib)
 
 # Find HDF5A CPP library:
 find_library( HDF5A_CPP_LIB NAMES hdf5a_cpp hdf5_cpp
               PATHS
-              $ENV{HDF5_DIR}/lib64
-              $ENV{HDF5_DIR}/lib
-              ${CMAKE_INSTALL_PREFIX}/lib64
-              /usr/lib64
-              ${CMAKE_INSTALL_PREFIX}/lib
-              /usr/lib
-              /usr/local/lib
-              /usr/local/ossim/lib )
+                $ENV{HDF5_DIR}/lib64
+                $ENV{HDF5_DIR}/lib)
 
 # Set the HDF5A_LIBRARIES:
 if( HDF5A_LIB AND HDF5A_CPP_LIB )
diff --git a/cmake/CMakeModules/FindJPEG.cmake b/cmake/CMakeModules/FindJPEG.cmake
index 2fa98ba..bda6081 100644
--- a/cmake/CMakeModules/FindJPEG.cmake
+++ b/cmake/CMakeModules/FindJPEG.cmake
@@ -20,22 +20,12 @@
 # (To distributed this file outside of CMake, substitute the full
 #  License text for the above reference.)
 
-FIND_PATH(JPEG_INCLUDE_DIR jpeglib.h
-           PATHS
-           ${CMAKE_INSTALL_PREFIX}/include
-           /usr/local/include
-           /usr/include )
+FIND_PATH(JPEG_INCLUDE_DIR jpeglib.h)
 
 SET(JPEG_NAMES ${JPEG_NAMES} jpeg libjpeg)
 
 # Added x86_64-linux-gnu path for Ubuntu install
-FIND_LIBRARY(JPEG_LIBRARY
-             NAMES ${JPEG_NAMES}
-             PATHS
-             ${CMAKE_INSTALL_PREFIX}/include
-             /usr/local/lib
-             /usr/lib
-             /usr/lib/x86_64-linux-gnu)
+FIND_LIBRARY(JPEG_LIBRARY NAMES ${JPEG_NAMES})
 
 # handle the QUIETLY and REQUIRED arguments and set JPEG_FOUND to TRUE if
 # all listed variables are TRUE
diff --git a/cmake/CMakeModules/FindJPEG12.cmake b/cmake/CMakeModules/FindJPEG12.cmake
index 0b66d10..43fd3bd 100644
--- a/cmake/CMakeModules/FindJPEG12.cmake
+++ b/cmake/CMakeModules/FindJPEG12.cmake
@@ -29,21 +29,11 @@
 # (To distributed this file outside of CMake, substitute the full
 #  License text for the above reference.)
 
-find_path( JPEG12_INCLUDE_DIR jpeg12/jpeglib.h
-           PATHS
-           ${CMAKE_INSTALL_PREFIX}/include
-           /usr/include
-           /usr/local/include )
+find_path( JPEG12_INCLUDE_DIR jpeg12/jpeglib.h)
 
 set( JPEG12_NAMES ${JPEG12_NAMES} jpeg12 libjpeg12 )
 
-find_library( JPEG12_LIBRARY
-              NAMES ${JPEG12_NAMES}
-              PATHS
-              /usr/lib64
-              /usr/local/lib64
-              /usr/lib
-              /usr/local/lib )
+find_library( JPEG12_LIBRARY NAMES ${JPEG12_NAMES})
 
 #---
 # This function sets JPEG12_FOUND if variables are valid.
diff --git a/cmake/CMakeModules/FindJsonCpp.cmake b/cmake/CMakeModules/FindJsonCpp.cmake
new file mode 100644
index 0000000..0b2a87a
--- /dev/null
+++ b/cmake/CMakeModules/FindJsonCpp.cmake
@@ -0,0 +1,32 @@
+########################################################################
+#
+# Find the JSON CPP include and library.
+#
+# This module defines:
+#
+# JSONCPP_INCLUDE_DIR, where to find json.h, etc.
+# JSONCPP_LIBRARY, library to link against to use jsoncpp.
+# JSONCPP_FOUND, True if found, false if one of the above are not found.
+# USE_OSSIM_JSONCPP, Set to "YES" if no external package detected.
+#    Directs cmake to include the jsoncpp subirectories in ossim build.
+#
+########################################################################
+
+set(JSONCPP_FOUND "NO")
+set(OSSIM_HAS_JSONCPP 0)
+
+find_path( JSONCPP_INCLUDE_DIR json/json.h
+          PATHS /usr/include/jsoncpp )
+
+find_library( JSONCPP_LIBRARY NAMES "jsoncpp")
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args( JSONCPP DEFAULT_MSG 
+                                   JSONCPP_LIBRARY 
+                                   JSONCPP_INCLUDE_DIR )
+
+if (JSONCPP_FOUND)
+   set(OSSIM_HAS_JSONCPP 1)
+endif (JSONCPP_FOUND)
+
+MARK_AS_ADVANCED(JSONCPP_LIBRARY JSONCPP_INCLUDE_DIR )
diff --git a/cmake/CMakeModules/FindLASzip.cmake b/cmake/CMakeModules/FindLASzip.cmake
index b405ceb..1b758be 100644
--- a/cmake/CMakeModules/FindLASzip.cmake
+++ b/cmake/CMakeModules/FindLASzip.cmake
@@ -36,25 +36,15 @@ IF(WIN32)
 ENDIF()
 
 
-FIND_PATH(LASZIP_INCLUDE_DIR
-  laszip.hpp
+FIND_PATH(LASZIP_INCLUDE_DIR laszip.hpp
   PATH_PREFIXES laszip
-  PATHS
-  /usr/include
-  /usr/local/include
-  /tmp/lasjunk/include
-  ${OSGEO4W_ROOT_DIR}/include)
+  PATHS ${OSGEO4W_ROOT_DIR}/include)
 
 SET(LASZIP_NAMES ${OSGEO4W_IMPORT_LIBRARY} laszip)
 
 FIND_LIBRARY(LASZIP_LIBRARY
-  NAMES ${LASZIP_NAMES}
-  PATHS
-  /usr/lib64
-  /usr/lib
-  /usr/local/lib
-  /tmp/lasjunk/lib
-  ${OSGEO4W_ROOT_DIR}/lib)
+   NAMES ${LASZIP_NAMES}
+	PATHS	${OSGEO4W_ROOT_DIR})
 
 IF(LASZIP_INCLUDE_DIR)
   SET(LASZIP_VERSION 0)
diff --git a/cmake/CMakeModules/FindLIBLAS.cmake b/cmake/CMakeModules/FindLIBLAS.cmake
index 9d1dd15..c691e09 100644
--- a/cmake/CMakeModules/FindLIBLAS.cmake
+++ b/cmake/CMakeModules/FindLIBLAS.cmake
@@ -34,15 +34,11 @@ macro(FIND_LIBLAS_LIBRARY MYLIBRARY MYLIBRARYNAME)
     PATHS
     ~/Library/Frameworks
     /Library/Frameworks
-    /usr/local/lib
-    /usr/local/lib64
-    /usr/lib
-    /usr/lib64
     /sw/lib
     /opt/local/lib
     /opt/csw/lib
     /opt/lib
-    [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;LIBLAS_ROOT]/lib
+     [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;LIBLAS_ROOT]/lib
     /usr/freeware/lib64
   )
     
@@ -73,10 +69,6 @@ macro(FIND_LIBLAS_LIBRARY MYLIBRARY MYLIBRARYNAME)
     PATHS
     ~/Library/Frameworks
     /Library/Frameworks
-    /usr/local/lib
-    /usr/local/lib64
-    /usr/lib
-    /usr/lib64
     /sw/lib
     /opt/local/lib
     /opt/csw/lib
diff --git a/cmake/CMakeModules/FindMSP.cmake b/cmake/CMakeModules/FindMSP.cmake
index 752aa3b..4bd9c08 100644
--- a/cmake/CMakeModules/FindMSP.cmake
+++ b/cmake/CMakeModules/FindMSP.cmake
@@ -6,32 +6,21 @@ SET(CMAKE_FIND_FRAMEWORK "LAST")
 
 ##############################################################
 
-macro(FIND_MSP_LIBRARY LIBS_OK MYLIBRARYNAME)
-  if (LIBS_OK)
-     find_library( TARGET_LIBRARY_${MYLIBRARYNAME}
-        NAMES "${MYLIBRARYNAME}"
-        PATHS
-        $ENV{MSP_HOME}/lib 
-        /usr/lib64
-        /usr/lib
-        /usr/local/lib )
-     if (TARGET_LIBRARY_${MYLIBRARYNAME})
-         set (MSP_LIBRARIES ${MSP_LIBRARIES} ${TARGET_LIBRARY_${MYLIBRARYNAME}})
-     else()
-       set(LIBS_OK "NO")
-     endif()
-   endif()
-endmacro(FIND_MSP_LIBRARY LIBS_OK MYLIBRARYNAME)
+function(FIND_MSP_LIBRARY LIBNAME LIBSOK)
+  find_library( TARGET_LIBRARY_${LIBNAME} NAMES "${LIBNAME}" PATHS ${MSP_HOME}/lib)
+  if (TARGET_LIBRARY_${LIBNAME})
+    set (MSP_LIBRARIES ${MSP_LIBRARIES} ${TARGET_LIBRARY_${LIBNAME}} PARENT_SCOPE)
+  else()
+    set(${LIBSOK} "NO" PARENT_SCOPE)
+  endif()
+endfunction(FIND_MSP_LIBRARY)
 
 ##############################################################
 
 set(MSP_FOUND "NO")
+set(OSSIM_HAS_MSP 0)
 
-FIND_PATH(MSP_INCLUDE_DIRS Mensuration/MensurationService.h
-        PATHS
-        $ENV{MSP_HOME}/include
-        /usr/include
-		    /usr/local/include)
+FIND_PATH(MSP_INCLUDE_DIRS Mensuration/MensurationService.h PATHS ${MSP_HOME}/include)
 
 if (MSP_INCLUDE_DIRS)
   set (MSP_INCLUDE_DIRS ${MSP_INCLUDE_DIRS} 
@@ -48,56 +37,61 @@ if (MSP_INCLUDE_DIRS)
                         ${MSP_INCLUDE_DIRS}/common/dtcc
                         ${MSP_INCLUDE_DIRS}/common/csm)
   set(LIBS_OK "YES")
-  FIND_MSP_LIBRARY(LIBS_OK MSPPointExtractionService)
-  FIND_MSP_LIBRARY(LIBS_OK MSPSensorModelService)
-  FIND_MSP_LIBRARY(LIBS_OK MSPSourceSelectionService)
-  FIND_MSP_LIBRARY(LIBS_OK MSPCovarianceService)
-  FIND_MSP_LIBRARY(LIBS_OK MSPSupportDataService)
-  FIND_MSP_LIBRARY(LIBS_OK MSPTerrainService)
-  FIND_MSP_LIBRARY(LIBS_OK MSPCCSUtils)
-  FIND_MSP_LIBRARY(LIBS_OK MSPCoordinateConversionService)
-  FIND_MSP_LIBRARY(LIBS_OK MSPOutputMethodService)
-  FIND_MSP_LIBRARY(LIBS_OK MSPasdetre)
-  FIND_MSP_LIBRARY(LIBS_OK MSPcoordconverter)
-  FIND_MSP_LIBRARY(LIBS_OK MSPcsisd)
-  FIND_MSP_LIBRARY(LIBS_OK MSPcsm)
-  FIND_MSP_LIBRARY(LIBS_OK MSPcsmutil)
-  FIND_MSP_LIBRARY(LIBS_OK MSPdtcc)
-  FIND_MSP_LIBRARY(LIBS_OK MSPlas)
-  FIND_MSP_LIBRARY(LIBS_OK MSPgeometry)
-  FIND_MSP_LIBRARY(LIBS_OK MSPmath)
-  FIND_MSP_LIBRARY(LIBS_OK MSPnitf)
-  FIND_MSP_LIBRARY(LIBS_OK MSPntmtre)
-  FIND_MSP_LIBRARY(LIBS_OK MSPrage)
-  FIND_MSP_LIBRARY(LIBS_OK MSPRageServiceUtils)
-  FIND_MSP_LIBRARY(LIBS_OK MSPrageutilities)
-  FIND_MSP_LIBRARY(LIBS_OK MSPSScovmodel)
-  FIND_MSP_LIBRARY(LIBS_OK MSPSSrutil)
-  FIND_MSP_LIBRARY(LIBS_OK MSPutilities)
-  FIND_MSP_LIBRARY(LIBS_OK CSM_PCAPI)
-  FIND_MSP_LIBRARY(LIBS_OK MSPrsme)
-  FIND_MSP_LIBRARY(LIBS_OK MSPRsmGeneratorService)
-  FIND_MSP_LIBRARY(LIBS_OK MSPdei)
-  FIND_MSP_LIBRARY(LIBS_OK MSPrsmg)
-  FIND_MSP_LIBRARY(LIBS_OK MSPDEIUtil)
-  FIND_MSP_LIBRARY(LIBS_OK MSPrutil)
-  FIND_MSP_LIBRARY(LIBS_OK MSPSensorSpecificService)
-  FIND_MSP_LIBRARY(LIBS_OK MSPImagingGeometryService)
-  FIND_MSP_LIBRARY(LIBS_OK MSPjson)
-  FIND_MSP_LIBRARY(LIBS_OK MSPmens)
-  FIND_MSP_LIBRARY(LIBS_OK MSPTerrainService)
-  FIND_MSP_LIBRARY(LIBS_OK MSPMensurationService)
-  FIND_MSP_LIBRARY(LIBS_OK MSPMensurationSessionRecordService)
-  FIND_MSP_LIBRARY(LIBS_OK MSPwriteRsmNitf)
-  FIND_MSP_LIBRARY(LIBS_OK MSPMSPVersionUtils)
-  FIND_MSP_LIBRARY(LIBS_OK MSPmtdCommon)
-  FIND_MSP_LIBRARY(LIBS_OK pthread )
-  FIND_MSP_LIBRARY(LIBS_OK dl  )
+  FIND_MSP_LIBRARY(MSPPointExtractionService LIBS_OK)
+  FIND_MSP_LIBRARY(MSPSensorModelService LIBS_OK)
+  FIND_MSP_LIBRARY(MSPSourceSelectionService LIBS_OK)
+  FIND_MSP_LIBRARY(MSPCovarianceService LIBS_OK)
+  FIND_MSP_LIBRARY(MSPSupportDataService LIBS_OK)
+  FIND_MSP_LIBRARY(MSPTerrainService LIBS_OK)
+  FIND_MSP_LIBRARY(MSPCCSUtils LIBS_OK)
+  FIND_MSP_LIBRARY(MSPCoordinateConversionService LIBS_OK)
+  FIND_MSP_LIBRARY(MSPOutputMethodService LIBS_OK)
+  FIND_MSP_LIBRARY(MSPasdetre LIBS_OK)
+  FIND_MSP_LIBRARY(MSPcoordconverter LIBS_OK)
+  FIND_MSP_LIBRARY(MSPcsisd LIBS_OK)
+  FIND_MSP_LIBRARY(MSPcsm LIBS_OK)
+  FIND_MSP_LIBRARY(MSPcsmutil LIBS_OK)
+  FIND_MSP_LIBRARY(MSPdtcc LIBS_OK)
+  FIND_MSP_LIBRARY(MSPlas LIBS_OK)
+  FIND_MSP_LIBRARY(MSPgeometry LIBS_OK)
+  FIND_MSP_LIBRARY(MSPmath LIBS_OK)
+  FIND_MSP_LIBRARY(MSPnitf LIBS_OK)
+  FIND_MSP_LIBRARY(MSPntmtre LIBS_OK)
+  FIND_MSP_LIBRARY(MSPrage LIBS_OK)
+  FIND_MSP_LIBRARY(MSPRageServiceUtils LIBS_OK)
+  FIND_MSP_LIBRARY(MSPrageutilities LIBS_OK)
+  FIND_MSP_LIBRARY(MSPSScovmodel LIBS_OK)
+  FIND_MSP_LIBRARY(MSPSSrutil LIBS_OK)
+  FIND_MSP_LIBRARY(MSPutilities LIBS_OK)
+  FIND_MSP_LIBRARY(CSM_PCAPI LIBS_OK)
+  FIND_MSP_LIBRARY(MSPrsme LIBS_OK)
+  FIND_MSP_LIBRARY(MSPRsmGeneratorService LIBS_OK)
+  FIND_MSP_LIBRARY(MSPdei LIBS_OK)
+  FIND_MSP_LIBRARY(MSPrsmg LIBS_OK)
+  FIND_MSP_LIBRARY(MSPDEIUtil LIBS_OK)
+  FIND_MSP_LIBRARY(MSPrutil LIBS_OK)
+  FIND_MSP_LIBRARY(MSPSensorSpecificService LIBS_OK)
+  FIND_MSP_LIBRARY(MSPImagingGeometryService LIBS_OK)
+  FIND_MSP_LIBRARY(MSPjson LIBS_OK)
+  FIND_MSP_LIBRARY(MSPmens LIBS_OK)
+  FIND_MSP_LIBRARY(MSPTerrainService LIBS_OK)
+  FIND_MSP_LIBRARY(MSPMensurationService LIBS_OK)
+  FIND_MSP_LIBRARY(MSPMensurationSessionRecordService LIBS_OK)
+  FIND_MSP_LIBRARY(MSPwriteRsmNitf LIBS_OK)
+  FIND_MSP_LIBRARY(MSPMSPVersionUtils LIBS_OK)
+  FIND_MSP_LIBRARY(MSPmtdCommon LIBS_OK)
+  FIND_MSP_LIBRARY(pthread  LIBS_OK)
+  FIND_MSP_LIBRARY(dl   LIBS_OK)
+
+# These are optional. Include only if present:
+  FIND_MSP_LIBRARY(MSPsupportdata DUMMY_ARG) 
+  FIND_MSP_LIBRARY(MSPHardCopyService DUMMY_ARG)
 
   if( LIBS_OK )
     set(MSP_FOUND "YES")
-    #message("-- MSP_INCLUDE_DIRS = ${MSP_INCLUDE_DIRS}")
-    #message("-- MSP_LIBRARIES = ${MSP_LIBRARIES}")
+    set(OSSIM_HAS_MSP 1)
+    message("-- MSP_INCLUDE_DIRS = ${MSP_INCLUDE_DIRS}")
+    message("-- MSP_LIBRARIES = ${MSP_LIBRARIES}")
   endif()
 
 endif()
diff --git a/cmake/CMakeModules/FindOMS.cmake b/cmake/CMakeModules/FindOMS.cmake
index 69c44c5..b071cef 100644
--- a/cmake/CMakeModules/FindOMS.cmake
+++ b/cmake/CMakeModules/FindOMS.cmake
@@ -9,28 +9,10 @@
 
 SET(CMAKE_FIND_FRAMEWORK "LAST")
 FIND_PATH(OMS_INCLUDE_DIR oms/ossimVersion.h
-	HINTS 
-		$ENV{OSSIM_DEV_HOME}/oms/coms/include
-		$ENV{OSSIM_DEV_HOME}/oms/lib
-		$ENV{OSSIM_INSTALL_PREFIX}/include
-	PATHS
-		$ENV{OSSIM_DEV_HOME}/oms/coms
-		$ENV{OSSIM_INSTALL_PREFIX}
-    	PATH_SUFFIXES 
-		lib
-		include
-)
+	PATHS $ENV{OSSIM_DEV_HOME}/ossim-oms/coms/include)
+
 SET(OSSIM_NAMES ${OSSIM_NAMES} oms )
-FIND_LIBRARY(OSSIM_LIBRARY NAMES ${OSSIM_NAMES}
-	HINTS 
-		$ENV{OSSIM_DEV_HOME}/ossim/lib
-	PATHS
-		$ENV{OSSIM_DEV_HOME}/ossim/lib
-		$ENV{OSSIM_INSTALL_PREFIX}
-    	PATH_SUFFIXES 
-		lib
-		Frameworks
-)
+FIND_LIBRARY(OSSIM_LIBRARY NAMES ${OSSIM_NAMES})
 
 # handle the QUIETLY and REQUIRED arguments and set OSSIM_FOUND to TRUE if 
 # all listed variables are TRUE
diff --git a/cmake/CMakeModules/FindOSG.cmake b/cmake/CMakeModules/FindOSG.cmake
index b910d31..78bd8fe 100644
--- a/cmake/CMakeModules/FindOSG.cmake
+++ b/cmake/CMakeModules/FindOSG.cmake
@@ -51,18 +51,12 @@ MACRO(FIND_OSG_LIBRARY MYLIBRARY MYLIBRARYNAME)
         PATHS
         ~/Library/Frameworks
         /Library/Frameworks
-        /usr/local/lib
-        /usr/local/lib64
-        /usr/lib
-        /usr/lib64
         /sw/lib
         /opt/local/lib
         /opt/csw/lib
         /opt/lib
         [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSG_ROOT]/lib
         /usr/freeware/lib64
-        ${CMAKE_INSTALL_PREFIX}/lib
-        ${CMAKE_INSTALL_PREFIX}/lib64
     )
     
     FIND_LIBRARY(${MYLIBRARY}
@@ -92,16 +86,10 @@ MACRO(FIND_OSG_LIBRARY MYLIBRARY MYLIBRARYNAME)
         PATHS
         ~/Library/Frameworks
         /Library/Frameworks
-        /usr/local/lib
-        /usr/local/lib64
-        /usr/lib
-        /usr/lib64
-        /sw/lib
+       /sw/lib
         /opt/local/lib
         /opt/csw/lib
         /opt/lib
-        ${CMAKE_INSTALL_PREFIX}/lib
-        ${CMAKE_INSTALL_PREFIX}/lib64
         [HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session\ Manager\\Environment;OSG_ROOT]/lib
         /usr/freeware/lib64
     )
diff --git a/cmake/CMakeModules/FindOpenCV.cmake b/cmake/CMakeModules/FindOpenCV.cmake
index 11fdbd6..c4b388e 100644
--- a/cmake/CMakeModules/FindOpenCV.cmake
+++ b/cmake/CMakeModules/FindOpenCV.cmake
@@ -3,7 +3,7 @@
 # 
 # Locate OPENCV
 #
-# The environment is referenced for $OPENCV_HOME first before the 
+# The cmake variable space is referenced for $OPENCV_HOME first before the 
 # standard install locations to perit sandbox installations of OpenCV.
 #
 # This module defines:
@@ -29,24 +29,12 @@
 # $Id$
 
 # Find include path:
-find_path(OPENCV_INCLUDE_DIR opencv/cv.hpp 
-          PATHS
-          $ENV{OPENCV_HOME}/include
-          /usr/local/opencv-3.2/include
-          /usr/include
-          /usr/local/include)
+find_path(OPENCV_INCLUDE_DIR opencv/cv.hpp  PATHS ${OPENCV_HOME}/include)
 
 macro(FIND_OPENCV_LIBRARY MYLIBRARY MYLIBRARYNAME)
-
    find_library( ${MYLIBRARY}
-      NAMES "${MYLIBRARYNAME}${OPENCV_RELEASE_POSTFIX}"
-      PATHS
-      $ENV{OPENCV_HOME}/lib
-      /usr/local/opencv-3.2/lib   
-      /usr/lib64
-      /usr/lib
-      /usr/local/lib)
-
+        NAMES "${MYLIBRARYNAME}${OPENCV_RELEASE_POSTFIX}"
+   	  PATHS ${OPENCV_HOME}/lib)
 endmacro(FIND_OPENCV_LIBRARY MYLIBRARY MYLIBRARYNAME)
 
 # Required
diff --git a/cmake/CMakeModules/FindOpenJPEG.cmake b/cmake/CMakeModules/FindOpenJPEG.cmake
index f02c967..d05673b 100644
--- a/cmake/CMakeModules/FindOpenJPEG.cmake
+++ b/cmake/CMakeModules/FindOpenJPEG.cmake
@@ -19,13 +19,9 @@
 #  OPENJPEG_LIBRARY, where to find the OpenJPEG library.
 
 FIND_PATH(OPENJPEG_INCLUDE_DIR openjpeg.h
-  PATHS
-    /usr/local/include/openjpeg
-    /usr/local/include/openjpeg-1.5
-    /usr/local/include
-    /usr/include/openjpeg
-    /usr/include
   PATH_SUFFIXES
+    openjpeg
+    openjpeg-1.5
     openjpeg-2.1
   DOC "Location of OpenJPEG Headers"
 )
@@ -34,11 +30,8 @@ MARK_AS_ADVANCED( MINIZIP_LIBRARY MINIZIP_INCLUDE_DIR )
 
 SET(OPENJPEG_NAMES ${OPENJPEG_NAMES} openjp2)
 SET(OPENJPEG_NAMES ${OPENJPEG_NAMES} openjpeg)
-FIND_LIBRARY(OPENJPEG_LIBRARY
-  NAMES ${OPENJPEG_NAMES}
-  PATHS /usr/lib /usr/local/lib
-  )
-
+FIND_LIBRARY(OPENJPEG_LIBRARY NAMES ${OPENJPEG_NAMES})
+  
 IF (OPENJPEG_LIBRARY AND OPENJPEG_INCLUDE_DIR)
     SET(OPENJPEG_LIBRARIES ${OPENJPEG_LIBRARY})
     SET(OPENJPEG_FOUND "YES")
diff --git a/cmake/CMakeModules/FindOssimVideo.cmake b/cmake/CMakeModules/FindOssimVideo.cmake
index febbc2c..50292aa 100644
--- a/cmake/CMakeModules/FindOssimVideo.cmake
+++ b/cmake/CMakeModules/FindOssimVideo.cmake
@@ -8,28 +8,11 @@
 #  OSSIMVIDEO_LIBRARY, where to find the ossimPredator library.
 SET(CMAKE_FIND_FRAMEWORK "LAST")
 FIND_PATH(OSSIMVIDEO_INCLUDE_DIR ossimPredator/ossimPredatorExport.h
-	HINTS 
-		$ENV{OSSIM_DEV_HOME}/ossim-video/include
-		$ENV{OSSIM_DEV_HOME}/ossim-video/lib
-		$ENV{OSSIM_INSTALL_PREFIX}/include
-	PATHS
-		$ENV{OSSIM_DEV_HOME}/ossim
-		$ENV{OSSIM_INSTALL_PREFIX}
-    	PATH_SUFFIXES 
-		lib
-		include
-)
+	PATHS ${OSSIM_DEV_HOME}/ossim-video/include)
+		
 SET(OSSIMVIDEO_NAMES ${OSSIMVIDEO_NAMES} ossim-video )
-FIND_LIBRARY(OSSIMVIDEO_LIBRARY NAMES ${OSSIMVIDEO_NAMES}
-	HINTS 
-		$ENV{OSSIM_DEV_HOME}/ossim-video/lib
-	PATHS
-		$ENV{OSSIM_DEV_HOME}/ossim-video/lib
-		$ENV{OSSIM_INSTALL_PREFIX}
-    	PATH_SUFFIXES 
-		lib
-		Frameworks
-)
+FIND_LIBRARY(OSSIMVIDEO_LIBRARY NAMES ${OSSIMVIDEO_NAMES})
+
 
 # handle the QUIETLY and REQUIRED arguments and set OSSIMVIDEO_FOUND to TRUE if 
 # all listed variables are TRUE
diff --git a/cmake/CMakeModules/FindOssimWMS.cmake b/cmake/CMakeModules/FindOssimWMS.cmake
index c629039..73e572d 100644
--- a/cmake/CMakeModules/FindOssimWMS.cmake
+++ b/cmake/CMakeModules/FindOssimWMS.cmake
@@ -8,33 +8,10 @@
 #  WMS_LIBRARY, where to find the WMS library.
 SET(CMAKE_FIND_FRAMEWORK "LAST")
 FIND_PATH(OSSIMWMS_INCLUDE_DIR wms/wms.h
-	HINTS 
-		$ENV{OSSIM_DEV_HOME}/ossim-wms/include
-		$ENV{OSSIM_DEV_HOME}/ossim-wms/lib
-		$ENV{OSSIM_INSTALL_PREFIX}/include
-	PATHS
-		$ENV{OSSIM_DEV_HOME}/ossim-wms
-		$ENV{OSSIM_INSTALL_PREFIX}
-    	PATH_SUFFIXES 
-		lib
-		include
-
-)
+	PATHS	$ENV{OSSIM_DEV_HOME}/ossim-wms/include)
 
 SET(OSSIMWMS_NAMES ${OSSIMWMS_NAMES} wms ossim-wms)
-FIND_LIBRARY(OSSIMWMS_LIBRARY NAMES ${OSSIMWMS_NAMES} 
-	HINTS 
-		$ENV{OSSIM_DEV_HOME}/ossim-wms/lib
-		$ENV{OSSIM_DEV_HOME}/ossim-wms
-		$ENV{OSSIM_INSTALL_PREFIX}
-	PATHS
-		$ENV{OSSIM_DEV_HOME}/ossim-wms/lib
-		$ENV{OSSIM_DEV_HOME}/ossim-wms
-		$ENV{OSSIM_INSTALL_PREFIX}
-    	PATH_SUFFIXES 
-		lib
-		Frameworks
-)
+FIND_LIBRARY(OSSIMWMS_LIBRARY NAMES ${OSSIMWMS_NAMES})
 
 # handle the QUIETLY and REQUIRED arguments and set OSSIMWMS_FOUND to TRUE if 
 # all listed variables are TRUE
diff --git a/cmake/CMakeModules/FindPDAL.cmake b/cmake/CMakeModules/FindPDAL.cmake
index f3a97df..6bfbe7a 100644
--- a/cmake/CMakeModules/FindPDAL.cmake
+++ b/cmake/CMakeModules/FindPDAL.cmake
@@ -18,30 +18,12 @@
 # Find include path:  "pdal_defines.h" installs to install "prefix" with pdal 
 # includes under "pdal" sub directory.
 #---
-find_path( PDAL_INCLUDE_DIR pdal/pdal.hpp
-           PATHS 
-           ${OSSIM_DEPENDENCIES}/include
-           /usr/include
-           /usr/local/include
-           /usr/local/ossim/include )
+find_path( PDAL_INCLUDE_DIR pdal/pdal.hpp)
 
-macro(FIND_PDAL_LIBRARY MYLIBRARY MYLIBRARYNAME)
-
-   find_library( ${MYLIBRARY}
-      NAMES "${MYLIBRARYNAME}"
-      PATHS
-      ${OSSIM_DEPENDENCIES}/lib
-      /usr/lib64
-      /usr/lib
-     /usr/local/lib
-   )
-
-endmacro(FIND_PDAL_LIBRARY MYLIBRARY MYLIBRARYNAME)
-
-FIND_PDAL_LIBRARY(PDAL_CPP_LIBRARY pdalcpp)
-FIND_PDAL_LIBRARY(PDAL_UTIL_LIBRARY pdal_util)
-FIND_PDAL_LIBRARY(RIALTO_LIBRARY rialto)
-FIND_PDAL_LIBRARY(LASZIP_LIBRARY laszip)
+find_library(PDAL_CPP_LIBRARY NAMES pdalcpp)
+find_library(PDAL_UTIL_LIBRARY NAMES pdal_util)
+find_library(RIALTO_LIBRARY NAMES rialto)
+find_library(LASZIP_LIBRARY NAMES laszip)
 
 message( STATUS "PDAL_INCLUDE_DIR             = ${PDAL_INCLUDE_DIR}" )
 message( STATUS "PDAL_CPP_LIBRARY             = ${PDAL_CPP_LIBRARY}" )
diff --git a/cmake/CMakeModules/FindPodofo.cmake b/cmake/CMakeModules/FindPodofo.cmake
index 266c66b..1a0c845 100644
--- a/cmake/CMakeModules/FindPodofo.cmake
+++ b/cmake/CMakeModules/FindPodofo.cmake
@@ -12,11 +12,10 @@
 #---
 
 # Find include path:
-find_path(PODOFO_INCLUDE_DIR podofo/podofo.h PATHS /usr/include /usr/local/include
-)
+find_path(PODOFO_INCLUDE_DIR podofo/podofo.h )
 
 # Find library:
-find_library(PODOFO_LIBRARY NAMES podofo PATHS /usr/lib64 /usr/lib /usr/local/lib)
+find_library(PODOFO_LIBRARY NAMES podofo )
 
 #---
 # This function sets PODOFO_FOUND if variables are valid.
diff --git a/cmake/CMakeModules/FindPotrace.cmake b/cmake/CMakeModules/FindPotrace.cmake
index 68a12de..8401954 100644
--- a/cmake/CMakeModules/FindPotrace.cmake
+++ b/cmake/CMakeModules/FindPotrace.cmake
@@ -9,25 +9,13 @@
 # POTRACE_LIBRARIES, libraries to link against to use Potrace and rialto.
 # POTRACE_FOUND, True if found, false if one of the above are not found.
 # 
-find_path( POTRACE_INCLUDE_DIR potracelib.h
-           PATHS 
-           ${OSSIM_DEPENDENCIES}/include
-           /usr/include
-           /usr/local/include
-           /usr/local/ossim/include )
-
-find_library( POTRACE_LIBRARY
-      NAMES "potrace"
-      PATHS
-      ${OSSIM_DEPENDENCIES}/lib
-      /usr/lib64
-      /usr/lib
-     /usr/local/lib
-   )
-
-
-message( STATUS "POTRACE_INCLUDE_DIR             = ${POTRACE_INCLUDE_DIR}" )
-message( STATUS "POTRACE_LIBRARY                 = ${POTRACE_LIBRARY}" )
+find_path( POTRACE_INCLUDE_DIR potracelib.h)
+
+find_library( POTRACE_LIBRARY NAMES "potrace")
+
+
+message( STATUS "POTRACE_INCLUDE_DIR = ${POTRACE_INCLUDE_DIR}" )
+message( STATUS "POTRACE_LIBRARY     = ${POTRACE_LIBRARY}" )
 
 set(POTRACE_FOUND "NO")
 
diff --git a/cmake/CMakeModules/FindRapier.cmake b/cmake/CMakeModules/FindRapier.cmake
index 067ccc1..45673f3 100644
--- a/cmake/CMakeModules/FindRapier.cmake
+++ b/cmake/CMakeModules/FindRapier.cmake
@@ -14,27 +14,9 @@
 #---
 
 find_path(RAPIER_INCLUDE_DIR rapier/common/rapierConstants.h
-   HINTS	
-      $ENV{OSSIM_DEV_HOME}/Rapier/include
-      $ENV{OSSIM_INSTALL_PREFIX}/include
-   PATHS
-      $ENV{OSSIM_DEV_HOME}/Rapier
-      $ENV{OSSIM_INSTALL_PREFIX}
-   PATH_SUFFIXES 
-      include
-)
+   PATHS $ENV{OSSIM_DEV_HOME}/Rapier/include)
 
-find_library(RAPIER_LIBRARY
-   NAMES rapier
-   HINTS 
-      $ENV{OSSIM_DEV_HOME}/Rapier/lib
-      $ENV{OSSIM_DEV_HOME}/build/lib
-   PATHS
-      $ENV{OSSIM_DEV_HOME}/Rapier/lib
-      $ENV{OSSIM_INSTALL_PREFIX}
-   PATH_SUFFIXES 
-      lib
-)
+find_library(RAPIER_LIBRARY NAMES rapier)
 
 #---
 # This function sets RAPIER_FOUND if variables are valid.
diff --git a/cmake/CMakeModules/FindSQLITE.cmake b/cmake/CMakeModules/FindSQLITE.cmake
index cedcb83..1965148 100644
--- a/cmake/CMakeModules/FindSQLITE.cmake
+++ b/cmake/CMakeModules/FindSQLITE.cmake
@@ -20,17 +20,10 @@
 #---
 # Find include path:
 #---
-find_path( SQLITE_INCLUDE_DIR sqlite3.h
-           PATHS 
-           /usr/include
-           /usr/local/include )
+find_path( SQLITE_INCLUDE_DIR sqlite3.h)
 
 # Find SQLITE library:
-find_library( SQLITE_LIB NAMES sqlite3
-              PATHS 
-              /usr/lib64 
-              /usr/lib 
-              /usr/local/lib )
+find_library( SQLITE_LIB NAMES sqlite3)
 
 # Set the SQLITE_LIBRARY:
 if( SQLITE_LIB )
diff --git a/cmake/CMakeModules/FindTIFF.cmake b/cmake/CMakeModules/FindTIFF.cmake
index a4afe8f..95f7fdb 100644
--- a/cmake/CMakeModules/FindTIFF.cmake
+++ b/cmake/CMakeModules/FindTIFF.cmake
@@ -22,27 +22,14 @@
 
 FIND_PATH(TIFF_INCLUDE_DIR tiff.h
           PATHS 
-          $ENV{TIFF_DIR}/include
-          $ENV{TIFF_DIR}/include/tiff
-          ${CMAKE_INSTALL_PREFIX}/include
-          /usr/local/include 
-          /usr/local/include/tiff
-          /usr/include/
-          /usr/include/tiff)
-
+            $ENV{TIFF_DIR}/include 
+            $ENV{TIFF_DIR}/include/tiff)
 
 SET(TIFF_NAMES ${TIFF_NAMES} tiff libtiff_i libtiff tiff3 libtiff3)
-
-# Added x86_64-linux-gnu path for Ubuntu install
-FIND_LIBRARY(TIFF_LIBRARY 
-             NAMES ${TIFF_NAMES} 
-             PATHS 
-             $ENV{TIFF_DIR}/lib
-             $ENV{TIFF_DIR}/lib64
-             ${CMAKE_INSTALL_PREFIX}/lib
-             /usr/local/lib
-             /usr/lib 
-             /usr/lib/x86_64-linux-gnu)
+FIND_LIBRARY(TIFF_LIBRARY NAMES ${TIFF_NAMES} 
+            PATHS 
+               $ENV{TIFF_DIR}/lib
+               $ENV{TIFF_DIR}/lib64)
 
 # handle the QUIETLY and REQUIRED arguments and set TIFF_FOUND to TRUE if 
 # all listed variables are TRUE
diff --git a/cmake/CMakeModules/Findossim.cmake b/cmake/CMakeModules/Findossim.cmake
index ad12e12..b113d2c 100644
--- a/cmake/CMakeModules/Findossim.cmake
+++ b/cmake/CMakeModules/Findossim.cmake
@@ -16,25 +16,10 @@
 # Find include path:
 #---
 set(CMAKE_FIND_FRAMEWORK "LAST")
-find_path(OSSIM_INCLUDE_DIR ossim/ossimVersion.h ossimVersion.h
-   PATHS
-      $ENV{OSSIM_DEV_HOME}/ossim/include
-      $ENV{OSSIM_INSTALL_PREFIX}/include
-   PATH_SUFFIXES 
-      include
-      lib
-)
+find_path(OSSIM_INCLUDE_DIR ossim/ossimVersion.h ossimVersion.h)
 
 set(OSSIM_NAMES ${OSSIM_NAMES} ossim libossim)
-find_library(OSSIM_LIBRARY NAMES ${OSSIM_NAMES}
-   PATHS
-      $ENV{OSSIM_BUILD_DIR}/lib${LIBSUFFIX}
-      $ENV{OSSIM_INSTALL_PREFIX}/lib${LIBSUFFIX}
-      $ENV{OSSIM_INSTALL_PREFIX}
-   PATH_SUFFIXES 
-      lib
-      Frameworks
-)
+find_library(OSSIM_LIBRARY NAMES ${OSSIM_NAMES})
 
 #---
 # This function sets OSSIM_FOUND if variables are valid.
diff --git a/cmake/CMakeModules/FindossimPlanet.cmake b/cmake/CMakeModules/FindossimPlanet.cmake
index 3fdface..5adf3a5 100644
--- a/cmake/CMakeModules/FindossimPlanet.cmake
+++ b/cmake/CMakeModules/FindossimPlanet.cmake
@@ -7,30 +7,10 @@
 # also defined, but not for general use are
 #  OSSIMPLANET_LIBRARY, where to find the OSSIM library.
 SET(CMAKE_FIND_FRAMEWORK "LAST")
-FIND_PATH(OSSIMPLANET_INCLUDE_DIR ossimPlanet/ossimPlanetExport.h ossimPlanetExport.h
-	HINTS 
-		$ENV{OSSIM_DEV_HOME}/ossimPlanet/include
-		$ENV{OSSIM_DEV_HOME}/ossimPlanet/lib
-		$ENV{OSSIM_INSTALL_PREFIX}/include
-	PATHS
-		$ENV{OSSIM_DEV_HOME}/ossimPlanet
-		$ENV{OSSIM_INSTALL_PREFIX}
-    	PATH_SUFFIXES 
-		lib
-		include
-)
+FIND_PATH(OSSIMPLANET_INCLUDE_DIR ossimPlanet/ossimPlanetExport.h ossimPlanetExport.h)
 
 SET(OSSIMPLANET_NAMES ${OSSIMPLANET_NAMES} ossimPlanet )
-FIND_LIBRARY(OSSIMPLANET_LIBRARY NAMES ${OSSIMPLANET_NAMES}
-	HINTS 
-		$ENV{OSSIM_DEV_HOME}/ossimPlanet/lib
-	PATHS
-		$ENV{OSSIM_DEV_HOME}/ossimPlanet/lib
-		$ENV{OSSIM_INSTALL_PREFIX}
-    	PATH_SUFFIXES 
-		lib
-		Frameworks
-)
+FIND_LIBRARY(OSSIMPLANET_LIBRARY NAMES ${OSSIMPLANET_NAMES})
 
 # handle the QUIETLY and REQUIRED arguments and set OSSIMPLANET_FOUND to TRUE if 
 # all listed variables are TRUE
diff --git a/cmake/CMakeModules/OssimCommonVariables.cmake b/cmake/CMakeModules/OssimCommonVariables.cmake
index fb7c32f..4d45d5f 100644
--- a/cmake/CMakeModules/OssimCommonVariables.cmake
+++ b/cmake/CMakeModules/OssimCommonVariables.cmake
@@ -1,4 +1,3 @@
-
 ##################################################################################
 # This currently sets up the options for the WARNING FLAGS for the compiler we are generating for.
 # Currently only have gnu
@@ -6,7 +5,7 @@
 MACRO(OSSIM_ADD_COMMON_LIBRARY_FLAGS)
    OPTION(OSSIM_COMPILE_WITH_FULL_WARNING "OSSIM developers : Compilation with FULL warning (use only for ossim developers)." OFF)
    MARK_AS_ADVANCED(OSSIM_COMPILE_WITH_FULL_WARNING)
-
+   
    IF(OSSIM_COMPILE_WITH_FULL_WARNING)
      IF(CMAKE_COMPILER_IS_GNUCXX)
        SET(OSSIM_COMMON_COMPILER_FLAGS "${OSSIM_COMMON_COMPILER_FLAGS} -Wall -Wunused  -Wunused-function  -Wunused-label  -Wunused-parameter -Wunused-value -Wunused-variable -Wuninitialized -Wsign-compare -Wparentheses -Wunknown-pragmas -Wswitch" CACHE STRING "List of compilation parameters.")
@@ -78,7 +77,9 @@ MACRO(USE_CXX11)
       set (CMAKE_CXX_FLAGS "--std=gnu++11 ${CMAKE_CXX_FLAGS}")
     endif()
   else ()
-    set (CMAKE_CXX_STANDARD 11)
+   set(CMAKE_CXX_STANDARD 11)
+   set(CMAKE_CXX_STANDARD_REQUIRED ON)
+   set(CMAKE_CXX_EXTENSIONS OFF)
   endif ()
 ENDMACRO(USE_CXX11)
 
@@ -256,6 +257,18 @@ MACRO(OSSIM_ADD_COMMON_SETTINGS)
       GET_FILENAME_COMPONENT(OSSIM_DEPENDENCIES "${OSSIM_DEPENDENCIES}" ABSOLUTE)
    ENDIF(NOT OSSIM_DEPENDENCIES)
 
+   # Define paths used by package finders defined in this directory:
+   IF(OSSIM_INSTALL_PREFIX)
+      SET(CMAKE_LIBRARY_PATH "${CMAKE_LIBRARY_PATH};${OSSIM_INSTALL_PREFIX}/lib${LIBSUFFIX}")
+      SET(CMAKE_INCLUDE_PATH "${CMAKE_INCLUDE_PATH};${OSSIM_INSTALL_PREFIX}/include")
+   ENDIF()
+   IF(OSSIM_DEPENDENCIES)
+      SET(CMAKE_LIBRARY_PATH "${CMAKE_LIBRARY_PATH};${OSSIM_DEPENDENCIES}/lib${LIBSUFFIX}")
+      SET(CMAKE_INCLUDE_PATH "${CMAKE_INCLUDE_PATH};${OSSIM_DEPENDENCIES}/include")
+   ENDIF()
+   SET(CMAKE_LIBRARY_PATH "${CMAKE_LIBRARY_PATH};/usr/lib;/usr/local/lib;/usr/lib64;/usr/lib/x86_64-linux-gnu")
+   SET(CMAKE_INCLUDE_PATH "${CMAKE_INCLUDE_PATH};${OSSIM_DEV_HOME}/ossim/include;/usr/include;/usr/local/include")
+   
    #################################### ADd some common options for all modules to use ###################################
    OPTION(BUILD_OSSIM_VIDEO "Set to ON to build the video decoding library.  Use OFF to skip this module." OFF)
    OPTION(BUILD_OSSIM_PLANET "Set to ON to build the 3-D visualization module.  Use OFF to skip this module." OFF)
diff --git a/cmake/scripts/ossim-cmake-config.sh b/cmake/scripts/ossim-cmake-config.sh
index fa2ec64..799ed18 100755
--- a/cmake/scripts/ossim-cmake-config.sh
+++ b/cmake/scripts/ossim-cmake-config.sh
@@ -98,8 +98,9 @@ fi
 # Additional stuff for ECLIPSE CDT4 users:
 CMAKE_G_ARG="Unix Makefiles"
 if [ "$BUILD_TYPE_ARG" == "ECLIPSE" ]; then
-  CMAKE_ECLIPSE_VERSION=4.7.0
+  CMAKE_ECLIPSE_VERSION=4.7.1
   CMAKE_G_ARG="Eclipse CDT4 - Unix Makefiles"
+  CMAKE_CXX_FLAGS="-std=c++11"
   cp -f $CMAKE_DIR/CMakeLists.txt $OSSIM_DEV_HOME
   CMAKE_DIR=$OSSIM_DEV_HOME
   echo "Generating eclipse project files for Eclipse $CMAKE_ECLIPSE_VERSION."
@@ -164,6 +165,9 @@ fi
 if [ -z $BUILD_HDF5_PLUGIN ]; then
   BUILD_HDF5_PLUGIN=OFF
 fi
+if [ -z $BUILD_ISA_PLUGIN ]; then
+  BUILD_ISA_PLUGIN=OFF
+fi
 if [ -z $BUILD_KAKADU_PLUGIN ]; then
   BUILD_KAKADU_PLUGIN=OFF
 fi
@@ -240,6 +244,8 @@ echo "Generating Makefiles in" $OSSIM_BUILD_DIR
 
 # CMAKE command 
 cmake -G "$CMAKE_G_ARG" \
+-DCMAKE_CXX_FLAGS=$CMAKE_CXX_FLAGS \
+-DCMAKE_ECLIPSE_VERSION=$CMAKE_ECLIPSE_VERSION \
 -DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE \
 -DOSSIM_DEV_HOME=$OSSIM_DEV_HOME \
 -DCMAKE_OSX_ARCHITECTURES="x86_64" \
@@ -257,6 +263,7 @@ cmake -G "$CMAKE_G_ARG" \
 -DBUILD_GEOPDF_PLUGIN=$BUILD_GEOPDF_PLUGIN \
 -DBUILD_GDAL_PLUGIN=$BUILD_GDAL_PLUGIN \
 -DBUILD_HDF5_PLUGIN=$BUILD_HDF5_PLUGIN \
+-DBUILD_ISA_PLUGIN=$BUILD_ISA_PLUGIN \
 -DBUILD_KAKADU_PLUGIN=$BUILD_KAKADU_PLUGIN \
 -DBUILD_JPEG12_PLUGIN=$BUILD_JPEG12_PLUGIN \
 -DKAKADU_ROOT_SRC=$KAKADU_ROOT_SRC \
@@ -266,6 +273,7 @@ cmake -G "$CMAKE_G_ARG" \
 -DBUILD_MRSID_PLUGIN=$BUILD_MRSID_PLUGIN \
 -DMRSID_DIR=$MRSID_DIR \
 -DOPENCV_HOME=$OPENCV_HOME \
+-DCSM_HOME=$CSM_HOME \
 -DMSP_HOME=$MSP_HOME \
 -DOSSIM_PLUGIN_LINK_TYPE=SHARED \
 -DBUILD_OPENCV_PLUGIN=$BUILD_OPENCV_PLUGIN \
diff --git a/include/ossim/base/Barrier.h b/include/ossim/base/Barrier.h
new file mode 100644
index 0000000..0de3bfa
--- /dev/null
+++ b/include/ossim/base/Barrier.h
@@ -0,0 +1,126 @@
+#ifndef ossimBarrier_HEADER
+#define ossimBarrier_HEADER 1
+#include <ossim/base/ossimConstants.h>
+#include <mutex>
+#include <condition_variable>
+#include <atomic>
+
+namespace ossim{
+
+   /**
+   * Barrier is a class used to block threads so we can synchronize and entry point.
+   *
+   * In this example we show how to block the threads so they all start at the 
+   * same time when executing their work.
+   * Example:
+   *
+   * @code
+   * #include <ossim/base/Thread.h>
+   * #include <ossim/base/Barrier.h>
+   * int nThreads = 2;
+   * ossim::Barrier barrierStart(nThreads)
+   * // one more for main thread
+   * ossim::Barrier barrierFinished(nThreads+1);
+   *
+   * class TestThread : public ossim::Thread
+   *  {
+   *  public:
+   *      TestThread():ossim::Thread(){}
+   *      ~TestThread(){
+   *         waitForCompletion();
+   *      }
+   *
+   *   protected:
+   *      virtual void run()
+   *      {
+   *         barrierStart.block();
+   *         for(int x =0 ; x < 10;++x){
+   *            std::cout << "THREAD: " << getCurrentThreadId() << "\n";
+   *            sleepInMilliSeconds(10);
+   *            interrupt();
+   *         }
+   *         barrierFinished.block();
+   *      }
+   *   };
+   *
+   * int main(int agrc, char* argv[])
+   * {
+   *    std::vector<std::shared_ptr<TestThread> > threads(nThreads);
+   *    for(auto& thread:threads)
+   *    {
+   *      thread = std::make_shared<TestThread>();
+   *      thread->start();
+   *    }
+   *    // block main until barrier enters their finished state
+   *    barrierFinished.block();
+   *
+   *    // you can also reset the barriers and run again
+   *    barrierFinished.reset();
+   *    barrierStart.reset();
+   *    for(auto& thread:threads)
+   *    {
+   *      thread->start();
+   *    }
+   *    barrierFinished.block();
+   * }
+   *
+   * @endcode
+   */
+   class OSSIM_DLL Barrier 
+   {
+   public:
+      /**
+      * Constructor
+      * 
+      * @param n is the number of threads you wish to block
+      */
+      Barrier(ossim_int32 n);
+
+      /**
+      * Destructor will reset and release all blocked threads.
+      */
+      ~Barrier();
+
+      /**
+      * block will block the thread based on a wait condition.  it will verify 
+      * if the thread can be blocked by testing if the number
+      * of blocked threads is less than the total number to blocked threads.  If 
+      * the total is reached then all threads are notified and woken up and released  
+      */
+      void block();
+
+      /**
+      * Will reset the barrier to the original values.  
+      * It will also release all blocked threads and wait for their release
+      * before resetting.
+      */
+      void reset();
+
+      /**
+      * Will reset the barrier to a new block count.  
+      * It will also release all blocked threads and wait for their release
+      * before resetting.
+      *
+      * @param maxCount is the max number of threads to block
+      */
+      void reset(ossim_int32 maxCount);
+
+      ossim_int32 getMaxCount()const;
+      ossim_int32 getBlockedCount()const;
+   protected:
+      ossim_int32              m_maxCount;
+      ossim_int32              m_blockedCount;
+      std::atomic<ossim_int32> m_waitCount;
+      mutable std::mutex       m_mutex;
+      std::condition_variable  m_conditionalBlock;
+
+      /**
+      * Will be used for destructing and resetting.
+      * resetting should only happen in the main 
+      * thread
+      */ 
+      std::condition_variable m_conditionalWait;
+   };
+}
+
+#endif
\ No newline at end of file
diff --git a/include/ossim/base/Block.h b/include/ossim/base/Block.h
new file mode 100644
index 0000000..b56883f
--- /dev/null
+++ b/include/ossim/base/Block.h
@@ -0,0 +1,121 @@
+#ifndef ossimBlock_HEADER
+#define ossimBlock_HEADER 1
+#include <ossim/base/ossimConstants.h>
+#include <mutex>
+#include <condition_variable>
+#include <atomic>
+
+namespace ossim{
+
+   /**
+   * This is a very simple block interface.  This allows one to control 
+   * how their threads are blocked
+   *
+   * There is a release state flag that tells the call to block to block the calling
+   * thread or release the thread(s) that are currently blocked
+   *
+   * For a very simple use case we will start a thread and call block and have
+   * the main sleep for 2 seconds before releasing the thread
+   * @code
+   * #include <ossim/base/Block.h>
+   * #include <ossim/base/Thread.h>
+   * std::shared_ptr<ossim::Block> block = std::make_shared<ossim::Block>();
+   * class TestThread : public ossim::Thread
+   * {
+   * public:
+   * 
+   * protected:
+   *    virtual void run(){
+   *      block->block();
+   *       std::cout << "STARING!!!!!!!\n";
+   *    }
+   * };
+   * int main(int argc, char *argv[])
+   * {
+   *    TestThread t1;
+   *    t1.start();
+   * 
+   *    std::cout << "WAITING 2 SECOND to release block\n";
+   *    ossim::Thread::sleepInSeconds(2);
+   *    block->release();
+   *    ossim::Thread::sleepInSeconds(2);
+   * }
+   * @endcode
+   */
+   class OSSIM_DLL Block
+   {
+   public:
+      /**
+      * Allows one the construct a Block with a release state.
+      */
+      Block(bool releaseFlag=false);
+
+      /**
+      * Destructor
+      *
+      * Will set internally call release
+      */
+      ~Block();
+
+      /**
+      * Will set the relase flag and wake up all threads to test the condition again.
+      */
+      void set(bool releaseFlag);
+
+      /**
+      * Will block the calling thread based on the internal condition.  If the internal
+      * condition is set to release then it will return without blocking.
+      */
+      void block();
+
+      /**
+      * Will block the calling thread base on the internal condition.  If the internal 
+      * condition is set to release the it will return without blocking.  If the internal
+      * condition is set to not release then it will block for the specified time in 
+      * milliseconds
+      *
+      * @param waitTimeMillis specifies the amount of time to wait for the release
+      */
+      void block(ossim_uint64 waitTimeMillis);
+
+      /**
+      * Releases the threads and will not return until all threads are released
+      */
+      void release();
+
+      /**
+      * Simple reset the values.  Will not do any releasing
+      */
+      void reset();
+
+   private:
+      /**
+      * Used by the conditions
+      */
+      mutable std::mutex      m_mutex;
+
+      /**
+      * The release state.
+      */
+      std::atomic<bool>       m_release;
+
+      /**
+      * Condition that tests the release state
+      */
+      std::condition_variable m_conditionVariable;
+
+      /**
+      * Used to count the number of threads blocked or
+      * waiting on the condition
+      */
+      std::atomic<ossim_int32> m_waitCount;
+
+      /**
+      * Will be used for destructing and releasing.
+      * resetting should only happen in the main 
+      * thread
+      */ 
+      std::condition_variable m_conditionalWait;
+   };
+}
+#endif
\ No newline at end of file
diff --git a/include/ossim/base/ossimBlockIStream.h b/include/ossim/base/BlockIStream.h
similarity index 94%
copy from include/ossim/base/ossimBlockIStream.h
copy to include/ossim/base/BlockIStream.h
index b6be7b0..fb92039 100644
--- a/include/ossim/base/ossimBlockIStream.h
+++ b/include/ossim/base/BlockIStream.h
@@ -1,6 +1,6 @@
-#ifndef ossimBlockReader_HEADER
-#define ossimBlockReader_HEADER 1
-#include <ossim/base/ossimBlockStreamBuffer.h>
+#ifndef ossimBlockStream_HEADER
+#define ossimBlockStream_HEADER 1
+#include <ossim/base/BlockStreamBuffer.h>
 
 namespace ossim {
    /**
diff --git a/include/ossim/base/ossimBlockStreamBuffer.h b/include/ossim/base/BlockStreamBuffer.h
similarity index 99%
rename from include/ossim/base/ossimBlockStreamBuffer.h
rename to include/ossim/base/BlockStreamBuffer.h
index c9992ce..7d09892 100644
--- a/include/ossim/base/ossimBlockStreamBuffer.h
+++ b/include/ossim/base/BlockStreamBuffer.h
@@ -20,8 +20,8 @@ namespace ossim{
       BlockBufInfo():
       m_startByte(0),
       m_blockSize(0),
+      m_validSize(0),         
       m_blockBufferPtr(0),
-      m_validSize(0),
       m_blockLoaded(false){
 
       }
diff --git a/include/ossim/base/FactoryListBase.h b/include/ossim/base/FactoryListBase.h
new file mode 100644
index 0000000..a5083bb
--- /dev/null
+++ b/include/ossim/base/FactoryListBase.h
@@ -0,0 +1,152 @@
+//**************************************************************************************************
+//
+// License:  MIT
+// 
+// See LICENSE.txt file in the top level directory for more details.
+//
+// Description: Class declaration of ossimFactoryListInterface.
+//
+//**************************************************************************************************
+// $Id$
+#ifndef ossimFactoryListBase_HEADER
+#define ossimFactoryListBase_HEADER 1
+#include <vector>
+#include <ossim/base/ossimString.h>
+#include <ossim/base/RWLock.h>
+
+namespace ossim
+{
+  template <class T>
+  class FactoryListBase
+     {
+     public:
+        typedef std::vector<T> FactoryListType;
+        typedef std::vector<ossimString> TypeNameList;
+
+        FactoryListBase(){}
+        
+        /**
+         * This is for backward compatability and calls registerFactory for simple adds.
+         */
+        void addFactory(T factory)
+        {
+           registerFactory(factory);
+        }
+        
+        /**
+         * Public access method to determine if a factory is already registered to this
+         * list
+         */
+        bool isFactoryRegistered(T factory)const
+        {
+           if(!factory) return false;
+           ScopeReadLock scopedReadLock(m_rwlock);
+           
+           return findFactory(factory);
+        }
+        
+        /**
+         * Will register a factory to the factory list.  Will append the passed in factory if not
+         * already registered to the list.
+         */
+        void registerFactory(T factory, bool pushToFrontFlag=false)
+        {
+           if(!factory) return;
+           ScopeWriteLock scopedWriteLock(m_rwlock);
+           if(!findFactory(factory))
+           {
+              if (pushToFrontFlag)
+              {
+                 m_factoryList.insert(m_factoryList.begin(), factory);
+              }
+              else
+              {
+                 m_factoryList.push_back(factory);
+              }
+           }
+        }
+        /**
+         * Will remove the factory from the registry.
+         */
+        void unregisterFactory(T factory)
+        {
+          ScopeWriteLock scopedWriteLock(m_rwlock);
+          ossim_uint32 idx = 0;
+          for(idx = 0; idx < m_factoryList.size(); ++idx)
+          {
+            if(factory == m_factoryList[idx])
+            {
+               m_factoryList.erase(m_factoryList.begin() + idx);
+               return;
+            }
+          }
+        }
+        
+        /**
+         * Will remove all factories from the registry.
+         */
+        void unregisterAllFactories()
+        {
+          ScopeWriteLock scopedWriteLock(m_rwlock);
+          m_factoryList.clear();
+        }
+        
+        /**
+         * Inserts the factory to the front of the list.
+         */
+        void registerFactoryToFront(T factory)
+        {
+          ScopeWriteLock scopedWriteLock(m_rwlock);
+          if(!findFactory(factory))
+          {
+            m_factoryList.insert(m_factoryList.begin(), factory);
+          }
+        }
+        
+        /**
+         * Will insert the factory before the beforeThisFactory.  If not found
+         * it will do a simple append.
+         */
+        void registerFactoryBefore(T factory, T beforeThisFactory)
+        {
+          ScopeWriteLock scopedWriteLock(m_rwlock);
+
+           if(!findFactory(factory))
+           {
+              ossim_uint32 idx = 0;
+              for(idx = 0; idx < m_factoryList.size(); ++idx)
+              {
+                 if(beforeThisFactory == m_factoryList[idx])
+                 {
+                    m_factoryList.insert(m_factoryList.begin() + idx, factory);
+                    return;
+                 }
+              }
+              m_factoryList.push_back(factory);
+           }
+        }
+        
+     protected:
+        /**
+         * Utility to find a factory in the list
+         */
+        bool findFactory(T factory)const
+        {
+           if(!factory) return false;
+           ossim_uint32 idx = 0;
+           for(const auto& testFactory:m_factoryList)
+           {
+              if(factory == testFactory)
+              {
+                return true;
+              }
+           }
+           return false;
+        }
+
+        mutable ossim::RWLock m_rwlock;
+        FactoryListType m_factoryList;
+     };
+}
+
+#endif
diff --git a/include/ossim/base/ItemCache.h b/include/ossim/base/ItemCache.h
new file mode 100644
index 0000000..49ee2d6
--- /dev/null
+++ b/include/ossim/base/ItemCache.h
@@ -0,0 +1,409 @@
+#ifndef ossimItemCache_HEADER
+#define ossimItemCache_HEADER
+#include <ossim/base/RWLock.h>
+#include <map>
+#include <memory>
+#include <mutex>
+
+namespace ossim
+{
+   /**
+   * This is a generic cache.  The only requirement is that it expects 
+   * the item to support shared_ptr.  The ItemCache allows one to specify the
+   * maximum items to cache and will use a "Least Recently Used" (LRU) to purge old
+   * items from the cache back to a minimum cache size.
+   *
+   * Example Use:
+   *
+   * @code
+    #include <ossim/base/ItemCache.h>
+    #include <ossim/support_data/TiffHandlerState.h>
+    int main(int argc, char *argv[])
+    {
+      int returnCode = 0;
+       
+       ossimArgumentParser ap(&argc, argv);
+       ossimInit::instance()->addOptions(ap);
+       ossimInit::instance()->initialize(ap);
+    
+       try
+       {
+          ossim_uint32 maxStates=10;
+          ossim::ItemCache<ossim::ImageHandlerState> stateCache;
+          ossim_uint32 idx = 0;
+          stateCache.setMaxItemsToCache(maxStates);
+          while(idx < maxStates)
+          {
+            ossimString id = ossimString::toString(idx);
+            stateCache.addItem(id, std::make_shared<ossim::TiffHandlerState>()); 
+            ++idx;  
+         }
+         stateCache.getItem(ossimString::toString(0)
+         stateCache.getItem(ossimString::toString(maxStates-1);
+
+         // should be shrinking cache size back to a minimum size of default
+         // 80% capacity
+         stateCache.addItem(ossimString::toString(idx++), std::make_shared<ossim::TiffHandlerState>()); 
+         stateCache.addItem(ossimString::toString(idx++), std::make_shared<ossim::TiffHandlerState>()); 
+         stateCache.addItem(ossimString::toString(idx++), std::make_shared<ossim::TiffHandlerState>()); 
+
+      }
+      catch(const ossimException& e)
+      {
+         ossimNotify(ossimNotifyLevel_WARN) << e.what() << std::endl;
+         returnCode = 1;
+      }
+      catch( ... )
+      {
+         ossimNotify(ossimNotifyLevel_WARN)
+            << "ossim-foo caught unhandled exception!" << std::endl;
+         returnCode = 1;
+      }
+      
+      return returnCode;
+   }
+   * @endCode
+   */
+   template<class ItemType>
+   class ItemCache
+   {
+   public:
+      typename std::shared_ptr<ItemType> SharedItemType;
+      /**
+      * Holds information about the Item we are chaching.  
+      * Holds the current lruId and the cacheId and the item we
+      * are caching
+      *
+      * Lru is adjusted when the item is searched with the getItem
+      * 
+      */
+      struct Node
+      {
+         ossim_uint64              m_lruId;
+         ossimString               m_cacheId;
+         std::shared_ptr<ItemType> m_item;
+      };
+      typedef std::map<ossimString,  std::shared_ptr<Node> > CacheType;
+      typedef std::map<ossim_uint64, std::shared_ptr<Node> > LruType;
+   
+      /**
+      * Get item will adjust the LRU if the item is present.
+      *
+      * @param key Is the key used to identify the item you are
+      *            trying to retrieve.
+      * @return the shared pointer to the item you are returning or
+      *         null otherwise
+      */
+      std::shared_ptr<ItemType> getItem(const ossimString& key);
+      std::shared_ptr<const ItemType> getItem(const ossimString& key)const;
+
+      /**
+      * Add an item to the cache given the key or id
+      *
+      * @param key Is the identifier for the Item
+      * @param item Is the item to cache
+      */ 
+      void addItem(const ossimString& key, 
+                   std::shared_ptr<ItemType> item);
+
+      /**
+      * Will remove an item from the cache
+      *
+      * @param key is the identifier for the item to remove
+      * @return the removed item from the cache
+      */ 
+      std::shared_ptr<ItemType> removeItem(const ossimString& key);
+
+      /**
+      * will reset the cache back to empty clearing both the LRU 
+      * map and the cache map.
+      */
+      void reset();
+
+      /**
+      * Sets the min and max cavche size.  If the cache reaches max size
+      * it uses the min setting to flush values based on an LRU back to the
+      * minimum size
+      */
+      void setMinAndMaxItemsToCache(ossim_uint32 minItemsToCache, ossim_uint32 maxItemsToCache);
+      
+      /**
+      * @return the setting for the max items to cache
+      */
+      ossim_uint32 getMaxItemsToCache()const;
+
+      /**
+      * @return the setting for the min items to cache
+      */
+      ossim_uint32 getMinItemsToCache()const;
+      
+   protected:
+      mutable RWLock       m_itemCacheMutex;
+      mutable RWLock       m_lruCacheMutex;
+      mutable ossim_uint64 m_currentId{0};
+      CacheType            m_cache;
+      mutable LruType      m_lruCache;
+      ossim_uint32         m_maxItemsToCache{100};
+      ossim_uint32         m_minItemsToCache{80};
+
+      /**
+      * The public methods locks the cache down to a read 
+      * or write access.  This will not lock and will assume
+      * that a lock has already been done for the Cache
+      *
+      * @param key identifies the item to cache
+      * @param item the item to cache.
+      */ 
+      void protectedAddItem(const ossimString& key, 
+                             std::shared_ptr<ItemType> item);
+
+      /**
+      * Will shrink the cache based on an LRU back to 
+      * the min cache size.
+      */
+      void shrinkCache();
+
+      /**
+      * Will bump the LRU id so that the node is marked
+      * newest
+      *
+      *  @param node the node to mark as new for LRU
+      */
+      void touchNode(std::shared_ptr<Node> node)const;
+      
+      /**
+      * Removes a node from the item cache
+      *
+      * @param key the identifier for the node to remove
+      * @return shared ptr to the node removed
+      */
+      std::shared_ptr<Node> removeItemFromCache(const ossimString& key);
+
+      /**
+      * Removes a node from the LRU cache
+      *
+      * @param key the identifier for the node to remove
+      * @return shared ptr to the node removed
+      */
+      std::shared_ptr<Node> removeItemFromLruCache(ossim_uint64 key)const;
+      
+      /**
+      * This is an LRU id generator.  It will bump the id and return the
+      * value
+      *
+      * @return the next LRU id for a node to use.
+      */
+      ossim_uint64 nextId()const;
+   };
+
+   template<class ItemType>
+   typename std::shared_ptr<ItemType> ItemCache<ItemType>::getItem(const ossimString& key)
+   {
+      ossim::ScopeReadLock lock(m_itemCacheMutex);
+      std::shared_ptr<ItemType> result;
+      typename CacheType::iterator iter = m_cache.find(key);
+      if(iter != m_cache.end())
+      {
+         result = iter->second->m_item;
+         touchNode(iter->second);
+      }
+      return result;
+   }
+
+   template<class ItemType>
+   typename std::shared_ptr<const ItemType> ItemCache<ItemType>::getItem(const ossimString& key)const
+   {
+      ossim::ScopeReadLock lock(m_itemCacheMutex);
+      std::shared_ptr<const ItemType> result;
+      typename CacheType::const_iterator iter = m_cache.find(key);
+      if(iter != m_cache.end())
+      {
+         result = iter->second->m_item;
+         touchNode(iter->second);
+      }
+      return result;
+   }
+
+   template<class ItemType>
+   void ItemCache<ItemType>::addItem(const ossimString& key, 
+                                                  std::shared_ptr<ItemType> item)
+   {
+      ossim::ScopeWriteLock lock(m_itemCacheMutex);
+      protectedAddItem(key, item);
+   }
+   template<class ItemType>
+   typename std::shared_ptr<ItemType> ItemCache<ItemType>::removeItem(const ossimString& key)
+   {
+      ossim::ScopeWriteLock lock(m_itemCacheMutex);
+      std::shared_ptr<ItemType> result;
+      std::shared_ptr<Node> node = removeItemFromCache(key);
+      if(node)
+      {
+         result = node->m_item;
+         removeItemFromLruCache(node->m_lruId);
+      }
+
+      return result;
+   }
+
+   template<class ItemType>
+   void ItemCache<ItemType>::protectedAddItem(const ossimString& key, 
+                                                     std::shared_ptr<ItemType> item)
+   {
+      if(m_cache.size() > m_maxItemsToCache)
+      {
+         shrinkCache();
+      }
+      typename CacheType::iterator iter = m_cache.find(key);
+      if(iter!= m_cache.end())
+      {
+         // update the item and LRU
+         //
+         std::shared_ptr<Node> node = iter->second;
+         node->m_item = item;
+
+         touchNode(node);
+      }
+      else
+      {
+         std::shared_ptr<Node> nodePtr = std::make_shared<Node>();
+         nodePtr->m_cacheId = key;
+         nodePtr->m_item = item;
+         nodePtr->m_lruId = nextId();
+         m_cache.insert(std::make_pair(key, nodePtr));
+         {
+            ossim::ScopeWriteLock lock(m_lruCacheMutex);
+            if(m_lruCache.size() > 0)
+            {
+               m_lruCache.insert(--m_lruCache.end(), 
+                                 std::make_pair(nodePtr->m_lruId, 
+                                                nodePtr));
+            }
+            else
+            {
+               m_lruCache.insert(std::make_pair(nodePtr->m_lruId, 
+                                                nodePtr));            
+            }
+         }
+      }
+   }
+
+   template<class ItemType>
+   void ItemCache<ItemType>::touchNode(std::shared_ptr<Node> node)const
+   {
+      m_lruCache.erase(node->m_lruId);
+      node->m_lruId = nextId();
+      {
+         ossim::ScopeWriteLock lock(m_lruCacheMutex);
+         if(m_lruCache.size() > 0)
+         {
+            m_lruCache.insert(m_lruCache.end(), std::make_pair(node->m_lruId, node));
+         }
+         else
+         {
+            m_lruCache.insert(std::make_pair(node->m_lruId, node));
+         }
+      }
+   }
+
+   template<class ItemType>
+   ossim_uint64 ItemCache<ItemType>::nextId()const
+   {
+      return m_currentId++;
+   }
+
+   template<class ItemType>
+   void ItemCache<ItemType>::setMinAndMaxItemsToCache(ossim_uint32 maxItemsToCache, 
+                                                ossim_uint32 minItemsToCache)
+   {
+     ossim::ScopeWriteLock lock(m_itemCacheMutex);
+     m_maxItemsToCache = maxItemsToCache;
+     m_minItemsToCache = minItemsToCache;
+   }
+   template<class ItemType>
+   void ItemCache<ItemType>::reset()
+   {
+     ossim::ScopeWriteLock lock(m_itemCacheMutex);
+     m_cache.clear();
+     m_lruCache.clear();
+     m_currentId = 0;      
+   }
+
+   template<class ItemType>
+   void ItemCache<ItemType>::shrinkCache()
+   {
+      if(m_minItemsToCache < 1)
+      {
+         m_lruCache.clear();
+         m_cache.clear();
+      }
+      else
+      {
+         typename LruType::iterator iter = m_lruCache.begin();
+         ossim_uint32 previousSize = m_cache.size();
+         while((m_cache.size() > m_minItemsToCache)&&
+               (iter != m_lruCache.end()))
+         {
+            removeItemFromCache(iter->second->m_cacheId);
+            iter = m_lruCache.erase(iter);
+
+            // sanity check to make sure we continue to shrink at
+            // each iteration
+            // avoids infinite loop
+            if(m_cache.size() >= previousSize)
+            {
+               break;
+            }
+         }
+      }
+   }
+
+   template<class ItemType>
+   ossim_uint32 ItemCache<ItemType>::getMaxItemsToCache()const
+   {
+      ossim::ScopeReadLock lock(m_itemCacheMutex);
+      return m_maxItemsToCache;
+   }
+
+   template<class ItemType>
+   ossim_uint32 ItemCache<ItemType>::getMinItemsToCache()const
+   {
+      ossim::ScopeReadLock lock(m_itemCacheMutex);
+      return m_minItemsToCache;
+   }
+
+   template<class ItemType>
+   std::shared_ptr< typename ItemCache<ItemType>::Node> ItemCache<ItemType>::removeItemFromCache(const ossimString& key)
+   {
+      std::shared_ptr<Node> result;
+
+      typename CacheType::iterator iter = m_cache.find(key);
+      if(iter != m_cache.end())
+      {
+         result = iter->second;
+         m_cache.erase(iter);
+      }   
+
+      return result;
+   }
+
+   template<class ItemType>
+   std::shared_ptr<typename ItemCache<ItemType>::Node> ItemCache<ItemType>::removeItemFromLruCache(ossim_uint64 key)const
+   {
+      std::shared_ptr<Node> result;
+
+      typename LruType::iterator iter = m_lruCache.find(key);
+      if(iter != m_lruCache.end())
+      {
+         result = iter->second;
+         m_lruCache.erase(iter);
+      }   
+
+      return result;
+   } 
+
+}
+
+
+
+#endif
diff --git a/include/ossim/base/RWLock.h b/include/ossim/base/RWLock.h
new file mode 100644
index 0000000..29d7e4a
--- /dev/null
+++ b/include/ossim/base/RWLock.h
@@ -0,0 +1,88 @@
+/**
+* This code was derived from https://gist.github.com/mshockwave
+*
+*/
+#ifndef ossimRWLockHEADER
+#define ossimRWLockHEADER 1
+
+#include <condition_variable>
+#include <mutex>
+#include <atomic>
+#include <limits>
+
+namespace ossim {
+
+    /**
+    * Code was derived from https://gist.github.com/mshockwave
+    *
+    * Has a pure c++11 implementation for read/write locks
+    * allowing one to choose the locking technique to use.
+    *
+    * At the bottom we added typedefs so you do not have
+    * to specify the template values.
+    *
+    *
+    * Example:
+    * @code
+    *  ossim::RWLock mutex;
+    *  // enter a section that just needs read only access 
+    *  {
+    *       ossim::ScopeReadLock  lock(mutex);
+    *  }
+    *  // enter some section that requires write
+    *  {
+    *      ossim::ScopeWriteLock  lock(mutex); 
+    *  }
+    * @endcode
+    */
+    class RWLock {
+    private:
+        std::mutex m_waitMutex;
+        std::condition_variable m_waitConditional;
+        std::atomic_int m_refCounter;
+        const int MIN_INT;
+
+    public:
+
+        RWLock();
+
+        void lockWrite();
+
+        bool tryLockWrite();
+
+        void unlockWrite();
+
+        void lockRead();
+
+        bool tryLockRead();
+
+        void unlockRead();
+    };
+
+
+    class ScopeReadLock {
+        RWLock& m_lock;
+    public:
+        ScopeReadLock(RWLock &lock) : m_lock(lock) {
+            m_lock.lockRead();
+        }
+
+        ~ScopeReadLock() {
+            m_lock.unlockRead();
+        }
+    };
+
+    class ScopeWriteLock {
+        RWLock& m_lock;
+    public:
+        ScopeWriteLock(RWLock& lock) : m_lock(lock) {
+            m_lock.lockWrite();
+        }
+
+        ~ScopeWriteLock() {
+            m_lock.unlockWrite();
+        }
+    };
+};
+
+#endif
\ No newline at end of file
diff --git a/include/ossim/base/State.h b/include/ossim/base/State.h
new file mode 100644
index 0000000..5d16805
--- /dev/null
+++ b/include/ossim/base/State.h
@@ -0,0 +1,48 @@
+//*******************************************************************
+//
+// License:  See top level LICENSE.txt file.
+// 
+//*****************************************************************************
+#ifndef ossimState_HEADER
+#define ossimState_HEADER 1
+#include <ossim/base/ossimConstants.h>
+#include <ossim/base/ossimKeywordlist.h>
+#include <ossim/base/ossimString.h>
+
+namespace ossim
+{ 
+  /**
+  * This is the base for all state objects.  We started a new state
+  * object for our first step will be using this interface to cache 
+  * the state of ImageHandlers.  It is very expensive to keep opening
+  * a resource and then parsing all the meta information that describes
+  * the image.  We should be able to do this once and then allow for it
+  * to be saved and reloaded witout ever having to parse the state again
+  * unless the state changes
+  *
+  */
+  class OSSIM_DLL State   
+  {
+  public:
+    State(){}
+    virtual ~State(){}
+    /**
+    * @return the typename of the state that uniquely identifies
+    *         the name.  Usually the class name will be used
+    */
+    virtual const ossimString& getTypeName()const=0;
+
+    /**
+    * Allows a state to be loaded from keywordlist.
+    */
+    virtual bool load(const ossimKeywordlist& kwl,
+                           const ossimString& prefix="")=0;
+
+    /**
+    * Allows a state to be saved to a keywordlist.
+    */
+    virtual bool save(ossimKeywordlist& kwl,
+                           const ossimString& prefix="")const=0;
+  };
+}
+#endif
diff --git a/include/ossim/base/StateFactoryBase.h b/include/ossim/base/StateFactoryBase.h
new file mode 100644
index 0000000..00bf3ea
--- /dev/null
+++ b/include/ossim/base/StateFactoryBase.h
@@ -0,0 +1,19 @@
+#ifndef ossimStateFactoryBase_HEADER
+#define ossimStateFactoryBase_HEADER 1
+#include <ossim/base/ossimKeywordlist.h>
+#include <ossim/base/ossimString.h>
+
+namespace ossim 
+{
+   template< class T >
+   class OSSIM_DLL StateFactoryBase
+   {
+   public:
+      StateFactoryBase(){}
+      virtual T createState(const ossimKeywordlist& kwl, 
+                            const ossimString& prefix="")const=0;
+      virtual T createState(const ossimString& typeName)const=0; 
+   };
+}
+
+#endif
\ No newline at end of file
diff --git a/include/ossim/base/Thread.h b/include/ossim/base/Thread.h
new file mode 100644
index 0000000..efcc385
--- /dev/null
+++ b/include/ossim/base/Thread.h
@@ -0,0 +1,223 @@
+#ifndef ossimThread_HEADER
+#define ossimThread_HEADER 1
+#include <ossim/base/ossimConstants.h>
+#include <ossim/base/Barrier.h>
+#include <thread>
+#include <mutex>
+#include <condition_variable>
+#include <atomic>
+#include <string>
+
+namespace ossim{
+
+   /**
+   * Thread is an abstract class.  It provides a 
+   * general purpose thread interface that handles preliminary setup
+   * of the std c++11 thread.  It allows one to derive
+   * from Thread and override the run method.  Your thread should have calls
+   * to interrupt() whenever your thread is in a location that is
+   * interruptable.  If cancel is called then any thread that is interruptable will 
+   * throw an Interrupt and be caught in the base Thread class and then exit 
+   * the thread.
+   *
+   * Example:
+   * @code
+   * #include <ossim/base/Thread.h>
+   * #include <ossim/base/Barrier.h>
+   * class TestThread : public ossim::Thread
+   *  {
+   *  public:
+   *      TestThread():ossim::Thread(){}
+   *      ~TestThread(){
+   *         waitForCompletion();
+   *      }
+   *
+   *   protected:
+   *      virtual void run()
+   *      {
+   *         barrierStart.block();
+   *         for(int x =0 ; x < 10;++x){
+   *            std::cout << "THREAD: " << getCurrentThreadId() << "\n";
+   *            // simulate 10 milliseconds of uninterruptable work
+   *            sleepInMilliSeconds(10);
+   *            interrupt();
+   *         }
+   *         barrierFinished.block();
+   *      }
+   *   };
+   * int main(int agrc, char* argv[])
+   * {
+   *    std::vector<std::shared_ptr<TestThread> > threads(nThreads);
+   *    for(auto& thread:threads)
+   *    {
+   *      thread = std::make_shared<TestThread>();
+   *      thread->start();
+   *    }
+   *
+   *    // now let's wait for each thread to finish 
+   *    // before exiting
+   *    for(auto& thread:threads)
+   *    {
+   *      thread->waitForCompletion();
+   *    }
+   * }
+   * @endcode
+   */ 
+   class OSSIM_DLL Thread
+   {
+   public:
+      /**
+      * This is an Interrupt exception that is thrown if the @see cancel()
+      * is called and a call to @see interrupt() is made.
+      */
+      class Interrupt : public std::exception{
+      public:
+         Interrupt(const std::string& what=""):m_what(what){}
+         virtual const char* what() const throw(){return m_what.c_str();}
+      protected:
+         std::string m_what;
+      };
+      /**
+      * Constructor for this thread
+      */
+      Thread();
+
+      /**
+      * Destructor for this thread.  It will determine if this thread is joinable
+      * to the main thread and if so it will do a join before continuing.  If
+      * this is not done then an exeption is thrown by the std.
+      */
+      virtual ~Thread();
+
+      /**
+      * Will actually start the thread and will call the @see internalRun.
+      */
+      void start();
+
+      /**
+      * @return true if the current thread is running and false otherwise.
+      */
+      bool isRunning()const{return m_running.load(std::memory_order_relaxed);}
+
+      /**
+      * This is typically set if @see cancel() is called or if @see setCancel
+      * is called with argument set to true.
+      *
+      * @return true if the thread is interruptable and false otherwise.
+      */
+      bool isInterruptable()const{return m_interrupt.load(std::memory_order_relaxed);}
+
+      /**
+      * This basically requests that the thread be canceled.  @see setCancel.  Note,
+      * cancellation is not done immediately and a thread is only cancleed if derived
+      * classes call the interrupt().
+      *
+      * we will make these virtual just in case derived classes want to set conditions
+      */
+      virtual void cancel(){setCancel(true);}
+
+      /**
+      * @param flag if true will enable the thread to be interruptable and if false
+      *        the thread is not interruptable.
+      */
+      virtual void setCancel(bool flag);
+
+      /**
+      * Convenience to allow one to wait for this thread to finish it's work.
+      *
+      * Allow this to be overriden.
+      */
+      virtual void waitForCompletion();
+
+      /**
+      * Enables the thread to be paused.  If the interrupt is called
+      * it will block the thread
+      */
+      void pause();
+
+      /**
+      * This will resume a blocked thread.
+      */
+      void resume();
+
+      /**
+      * @return true if the thread is blocked and false otherwise
+      */
+      bool isPaused()const;
+
+      /**
+      * Utility method to allow one to sleep in seconds
+      *
+      * @param seconds to sleep
+      */
+      static void sleepInSeconds(ossim_uint64 seconds);
+
+      /**
+      * Utility method to allow one to sleep in milliseconds
+      *
+      * @param millis to sleep
+      */
+      static void sleepInMilliSeconds(ossim_uint64 millis);
+
+      /**
+      * Utility method to allow one to sleep in microseconds
+      *
+      * @param micros to sleep
+      */
+      static void sleepInMicroSeconds(ossim_uint64 micros);
+
+      /**
+      * Utility method to get the current thread ID
+      *
+      * @return current thread ID
+      */
+      static std::thread::id getCurrentThreadId();
+
+      /**
+      * Utility to return the number of processors  (concurrent threads)
+      */
+      static ossim_uint64 getNumberOfProcessors();
+      /**
+      * Will yield the current thread.
+      */
+      static void yieldCurrentThread();
+
+   protected:
+      /**
+      * This method must be overriden and is the main entry
+      * point for any work that needs to be done
+      */
+      virtual void run()=0;
+
+      /**
+      * This is the interrupt interface and will cause an internal exception that
+      * is caught by @see runInternal
+      */
+      virtual void interrupt();
+
+      /**
+      * runInternal sets up internal flags such as setting m_running to true and checks
+      * to make sure it's not interrupted and will then call the @see run() method.
+      *
+      * runInternal also will trap any Interrupt exceptions.  If the thread is interruptable
+      * and the work calls interrupt then an exception is thrown and the work is stopped and 
+      * the execution of the thread is marked as not running and returns.
+      */
+      virtual void runInternal();
+
+   private:
+      std::shared_ptr<std::thread>    m_thread;
+      std::atomic<bool>               m_running;
+      std::atomic<bool>               m_interrupt;
+      std::shared_ptr<ossim::Barrier> m_pauseBarrier;
+      std::condition_variable         m_runningCondition;
+      mutable std::mutex              m_runningMutex;
+
+      /**
+      * @see cancel and @see setCancel
+      */
+      void setInterruptable(bool flag);
+   };
+}
+
+#endif
diff --git a/include/ossim/base/jsoncpp.h b/include/ossim/base/jsoncpp.h
deleted file mode 100644
index 585de1d..0000000
--- a/include/ossim/base/jsoncpp.h
+++ /dev/null
@@ -1,2085 +0,0 @@
-/// Json-cpp amalgated header (http://jsoncpp.sourceforge.net/).
-/// It is intended to be used with #include "json/json.h"
-
-// //////////////////////////////////////////////////////////////////////
-// Beginning of content of file: LICENSE
-// //////////////////////////////////////////////////////////////////////
-
-/*
-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.
-
- */
-
-// //////////////////////////////////////////////////////////////////////
-// End of content of file: LICENSE
-// //////////////////////////////////////////////////////////////////////
-
-
-
-
-
-#ifndef JSON_AMALGATED_H_INCLUDED
-# define JSON_AMALGATED_H_INCLUDED
-/// If defined, indicates that the source file is amalgated
-/// to prevent private header inclusion.
-#define JSON_IS_AMALGAMATION
-
-// //////////////////////////////////////////////////////////////////////
-// Beginning of content of file: include/json/version.h
-// //////////////////////////////////////////////////////////////////////
-
-// DO NOT EDIT. This file (and "version") is generated by CMake.
-// Run CMake configure step to update it.
-#ifndef JSON_VERSION_H_INCLUDED
-# define JSON_VERSION_H_INCLUDED
-
-# define JSONCPP_VERSION_STRING "1.7.0"
-# define JSONCPP_VERSION_MAJOR 1
-# define JSONCPP_VERSION_MINOR 7
-# define JSONCPP_VERSION_PATCH 0
-# define JSONCPP_VERSION_QUALIFIER
-# define JSONCPP_VERSION_HEXA ((JSONCPP_VERSION_MAJOR << 24) | (JSONCPP_VERSION_MINOR << 16) | (JSONCPP_VERSION_PATCH << 8))
-
-#endif // JSON_VERSION_H_INCLUDED
-
-// //////////////////////////////////////////////////////////////////////
-// End of content of file: include/json/version.h
-// //////////////////////////////////////////////////////////////////////
-
-
-
-
-
-
-// //////////////////////////////////////////////////////////////////////
-// Beginning of content of file: include/json/config.h
-// //////////////////////////////////////////////////////////////////////
-
-// 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
-#include <stddef.h>
-#include <string> //typdef String
-
-/// If defined, indicates that json library is embedded in CppTL library.
-//# define JSON_IN_CPPTL 1
-
-/// If defined, indicates that json may leverage CppTL library
-//#  define JSON_USE_CPPTL 1
-/// If defined, indicates that cpptl vector based map should be used instead of
-/// std::map
-/// as Value container.
-//#  define JSON_USE_CPPTL_SMALLMAP 1
-
-// If non-zero, the library uses exceptions to report bad input instead of C
-// assertion macros. The default is to use exceptions.
-#ifndef JSON_USE_EXCEPTION
-#define JSON_USE_EXCEPTION 1
-#endif
-
-/// If defined, indicates that the source file is amalgated
-/// to prevent private header inclusion.
-/// Remarks: it is automatically defined in the generated amalgated header.
-// #define JSON_IS_AMALGAMATION
-
-#ifdef JSON_IN_CPPTL
-#include <cpptl/config.h>
-#ifndef JSON_USE_CPPTL
-#define JSON_USE_CPPTL 1
-#endif
-#endif
-
-#ifdef JSON_IN_CPPTL
-#define JSON_API CPPTL_API
-#elif defined(JSON_DLL_BUILD)
-#if defined(_MSC_VER)
-#define JSON_API __declspec(dllexport)
-#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
-#endif // if defined(_MSC_VER)
-#elif defined(JSON_DLL)
-#if defined(_MSC_VER)
-#define JSON_API __declspec(dllimport)
-#define JSONCPP_DISABLE_DLL_INTERFACE_WARNING
-#endif // if defined(_MSC_VER)
-#endif // ifdef JSON_IN_CPPTL
-#if !defined(JSON_API)
-#define JSON_API
-#endif
-
-// If JSON_NO_INT64 is defined, then Json only support C++ "int" type for
-// integer
-// Storages, and 64 bits integer support is disabled.
-// #define JSON_NO_INT64 1
-
-#if defined(_MSC_VER) // MSVC
-#  if _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
-// Disable warning 4786 for VS6 caused by STL (identifier was truncated to '255'
-// characters in the debug information)
-// All projects I've ever seen with VS6 were using this globally (not bothering
-// with pragma push/pop).
-#    pragma warning(disable : 4786)
-#  endif // MSVC 6
-
-#  if _MSC_VER >= 1500 // MSVC 2008
-/// Indicates that the following function is deprecated.
-#    define JSONCPP_DEPRECATED(message) __declspec(deprecated(message))
-#  endif
-
-#endif // defined(_MSC_VER)
-
-
-#ifndef JSON_HAS_RVALUE_REFERENCES
-
-#if defined(_MSC_VER) && _MSC_VER >= 1600 // MSVC >= 2010
-#define JSON_HAS_RVALUE_REFERENCES 1
-#endif // MSVC >= 2010
-
-#ifdef __clang__
-#if __has_feature(cxx_rvalue_references)
-#define JSON_HAS_RVALUE_REFERENCES 1
-#endif  // has_feature
-
-#elif defined __GNUC__ // not clang (gcc comes later since clang emulates gcc)
-#if defined(__GXX_EXPERIMENTAL_CXX0X__) || (__cplusplus >= 201103L)
-#define JSON_HAS_RVALUE_REFERENCES 1
-#endif  // GXX_EXPERIMENTAL
-
-#endif // __clang__ || __GNUC__
-
-#endif // not defined JSON_HAS_RVALUE_REFERENCES
-
-#ifndef JSON_HAS_RVALUE_REFERENCES
-#define JSON_HAS_RVALUE_REFERENCES 0
-#endif
-
-#ifdef __clang__
-#elif defined __GNUC__ // not clang (gcc comes later since clang emulates gcc)
-#  if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5))
-#    define JSONCPP_DEPRECATED(message)  __attribute__ ((deprecated(message)))
-#  elif (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
-#    define JSONCPP_DEPRECATED(message)  __attribute__((__deprecated__))
-#  endif  // GNUC version
-#endif // __clang__ || __GNUC__
-
-#if !defined(JSONCPP_DEPRECATED)
-#define JSONCPP_DEPRECATED(message)
-#endif // if !defined(JSONCPP_DEPRECATED)
-
-#if __GNUC__ >= 6
-#  define JSON_USE_INT64_DOUBLE_CONVERSION 1
-#endif
-
-namespace Json {
-typedef int Int;
-typedef unsigned int UInt;
-#if defined(JSON_NO_INT64)
-typedef int LargestInt;
-typedef unsigned int LargestUInt;
-#undef JSON_HAS_INT64
-#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 Int64;
-typedef unsigned __int64 UInt64;
-#else                 // if defined(_MSC_VER) // Other platforms, use long long
-typedef long long int Int64;
-typedef unsigned long long int UInt64;
-#endif // if defined(_MSC_VER)
-typedef Int64 LargestInt;
-typedef UInt64 LargestUInt;
-#define JSON_HAS_INT64
-#endif // if defined(JSON_NO_INT64)
-#define JSONCPP_STRING        std::string
-#define JSONCPP_OSTRINGSTREAM std::ostringstream
-#define JSONCPP_OSTREAM       std::ostream
-#define JSONCPP_ISTRINGSTREAM std::istringstream
-#define JSONCPP_ISTREAM       std::istream
-} // end namespace Json
-
-#endif // JSON_CONFIG_H_INCLUDED
-
-// //////////////////////////////////////////////////////////////////////
-// End of content of file: include/json/config.h
-// //////////////////////////////////////////////////////////////////////
-
-
-
-
-
-
-// //////////////////////////////////////////////////////////////////////
-// Beginning of content of file: include/json/forwards.h
-// //////////////////////////////////////////////////////////////////////
-
-// 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
-
-#if !defined(JSON_IS_AMALGAMATION)
-#include "config.h"
-#endif // if !defined(JSON_IS_AMALGAMATION)
-
-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;
-
-} // namespace Json
-
-#endif // JSON_FORWARDS_H_INCLUDED
-
-// //////////////////////////////////////////////////////////////////////
-// End of content of file: include/json/forwards.h
-// //////////////////////////////////////////////////////////////////////
-
-
-
-
-
-
-// //////////////////////////////////////////////////////////////////////
-// Beginning of content of file: include/json/features.h
-// //////////////////////////////////////////////////////////////////////
-
-// 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
-
-#if !defined(JSON_IS_AMALGAMATION)
-#include "forwards.h"
-#endif // if !defined(JSON_IS_AMALGAMATION)
-
-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_;
-
-   /// \c true if dropped null placeholders are allowed. Default: \c false.
-   bool allowDroppedNullPlaceholders_;
-
-   /// \c true if numeric object key are allowed. Default: \c false.
-   bool allowNumericKeys_;
-};
-
-} // namespace Json
-
-#endif // CPPTL_JSON_FEATURES_H_INCLUDED
-
-// //////////////////////////////////////////////////////////////////////
-// End of content of file: include/json/features.h
-// //////////////////////////////////////////////////////////////////////
-
-
-
-
-
-
-// //////////////////////////////////////////////////////////////////////
-// Beginning of content of file: include/json/value.h
-// //////////////////////////////////////////////////////////////////////
-
-// 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
-
-#if !defined(JSON_IS_AMALGAMATION)
-#include "forwards.h"
-#endif // if !defined(JSON_IS_AMALGAMATION)
-#include <string>
-#include <vector>
-#include <exception>
-
-#ifndef JSON_USE_CPPTL_SMALLMAP
-#include <map>
-#else
-#include <cpptl/smallmap.h>
-#endif
-#ifdef JSON_USE_CPPTL
-#include <cpptl/forwards.h>
-#endif
-
-// Disable warning C4251: <data member>: <type> needs to have dll-interface to
-// be used by...
-#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
-#pragma warning(push)
-#pragma warning(disable : 4251)
-#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
-
-/** \brief JSON (JavaScript Object Notation).
- */
-namespace Json {
-
-/** Base class for all exceptions we throw.
- *
- * We use nothing but these internally. Of course, STL can throw others.
- */
-class JSON_API Exception : public std::exception {
-public:
-   Exception(JSONCPP_STRING const& msg);
-   ~Exception() throw(); 
-   char const* what() const throw();
-protected:
-   JSONCPP_STRING msg_;
-};
-
-/** Exceptions which the user cannot easily avoid.
- *
- * E.g. out-of-memory (when we use malloc), stack-overflow, malicious input
- *
- * \remark derived from Json::Exception
- */
-class JSON_API RuntimeError : public Exception {
-public:
-   RuntimeError(JSONCPP_STRING const& msg);
-};
-
-/** Exceptions thrown by JSON_ASSERT/JSON_FAIL macros.
- *
- * These are precondition-violations (user bugs) and internal errors (our bugs).
- *
- * \remark derived from Json::Exception
- */
-class JSON_API LogicError : public Exception {
-public:
-   LogicError(JSONCPP_STRING const& msg);
-};
-
-/// used internally
-void throwRuntimeError(JSONCPP_STRING const& msg);
-/// used internally
-void throwLogicError(JSONCPP_STRING const& msg);
-
-/** \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) : c_str_(czstring) {}
-
-   operator const char*() const { return c_str_; }
-
-   const char* c_str() const { return c_str_; }
-
-private:
-   const char* c_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 resized and initialized
- * with #nullValue. resize() can be used to enlarge or truncate an #arrayValue.
- *
- * The get() methods can be used to obtain 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.
- *
- * \note #Value string-length fit in size_t, but keys must be < 2^30.
- * (The reason is an implementation detail.) A #CharReader will raise an
- * exception if a bound is exceeded to avoid security holes in your app,
- * but the Value API does *not* check bounds. That is the responsibility
- * of the caller.
- */
-class JSON_API Value {
-   friend class ValueIteratorBase;
-public:
-   typedef std::vector<JSONCPP_STRING> Members;
-   typedef ValueIterator iterator;
-   typedef ValueConstIterator const_iterator;
-   typedef Json::UInt UInt;
-   typedef Json::Int Int;
-#if defined(JSON_HAS_INT64)
-   typedef Json::UInt64 UInt64;
-   typedef Json::Int64 Int64;
-#endif // defined(JSON_HAS_INT64)
-   typedef Json::LargestInt LargestInt;
-   typedef Json::LargestUInt LargestUInt;
-   typedef Json::ArrayIndex ArrayIndex;
-
-   static const Value& null;  ///< We regret this reference to a global instance; prefer the simpler Value().
-   static const Value& nullRef;  ///< just a kludge for binary-compatibility; same as null
-   /// Minimum signed integer value that can be stored in a Json::Value.
-   static const LargestInt minLargestInt;
-   /// Maximum signed integer value that can be stored in a Json::Value.
-   static const LargestInt maxLargestInt;
-   /// Maximum unsigned integer value that can be stored in a Json::Value.
-   static const LargestUInt maxLargestUInt;
-
-   /// Minimum signed int value that can be stored in a Json::Value.
-   static const Int minInt;
-   /// Maximum signed int value that can be stored in a Json::Value.
-   static const Int maxInt;
-   /// Maximum unsigned int value that can be stored in a Json::Value.
-   static const UInt maxUInt;
-
-#if defined(JSON_HAS_INT64)
-   /// Minimum signed 64 bits int value that can be stored in a Json::Value.
-   static const Int64 minInt64;
-   /// Maximum signed 64 bits int value that can be stored in a Json::Value.
-   static const Int64 maxInt64;
-   /// Maximum unsigned 64 bits int value that can be stored in a Json::Value.
-   static const UInt64 maxUInt64;
-#endif // defined(JSON_HAS_INT64)
-
-private:
-#ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION
-   class CZString {
-   public:
-      enum DuplicationPolicy {
-         noDuplication = 0,
-         duplicate,
-         duplicateOnCopy
-      };
-      CZString(ArrayIndex index);
-      CZString(char const* str, unsigned length, DuplicationPolicy allocate);
-      CZString(CZString const& other);
-#if JSON_HAS_RVALUE_REFERENCES
-      CZString(CZString&& other);
-#endif
-      ~CZString();
-      CZString& operator=(CZString other);
-      bool operator<(CZString const& other) const;
-      bool operator==(CZString const& other) const;
-      ArrayIndex index() const;
-      //const char* c_str() const; ///< \deprecated
-      char const* data() const;
-      unsigned length() const;
-      bool isStaticString() const;
-
-   private:
-      void swap(CZString& other);
-
-      struct StringStorage {
-         unsigned policy_: 2;
-         unsigned length_: 30; // 1GB max
-      };
-
-      char const* cstr_;  // actually, a prefixed string, unless policy is noDup
-      union {
-         ArrayIndex index_;
-         StringStorage storage_;
-      };
-   };
-
-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 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);
-   Value(Int value);
-   Value(UInt value);
-#if defined(JSON_HAS_INT64)
-   Value(Int64 value);
-   Value(UInt64 value);
-#endif // if defined(JSON_HAS_INT64)
-   Value(double value);
-   Value(const char* value); ///< Copy til first 0. (NULL causes to seg-fault.)
-   Value(const char* begin, const char* end); ///< Copy all, incl zeroes.
-   /** \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.
-    * \note This works only for null-terminated strings. (We cannot change the
-    *   size of this class, so we have nowhere to store the length,
-    *   which might be computed later for various operations.)
-    *
-    * Example of usage:
-    * \code
-    * static StaticString foo("some text");
-    * Json::Value aValue(foo);
-    * \endcode
-    */
-   Value(const StaticString& value);
-   Value(const JSONCPP_STRING& value); ///< Copy data() til size(). Embedded zeroes too.
-#ifdef JSON_USE_CPPTL
-   Value(const CppTL::ConstString& value);
-#endif
-   Value(bool value);
-   /// Deep copy.
-   Value(const Value& other);
-#if JSON_HAS_RVALUE_REFERENCES
-   /// Move constructor
-   Value(Value&& other);
-#endif
-   ~Value();
-
-   /// Deep copy, then swap(other).
-   /// \note Over-write existing comments. To preserve comments, use #swapPayload().
-   Value& operator=(Value other);
-   /// Swap everything.
-   void swap(Value& other);
-   /// Swap values but leave comments and source offsets in place.
-   void swapPayload(Value& other);
-
-   ValueType type() const;
-
-   /// Compare payload only, not comments etc.
-   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;
-
-   const char* asCString() const; ///< Embedded zeroes could cause you trouble!
-   JSONCPP_STRING asString() const; ///< Embedded zeroes are possible.
-   /** Get raw char* of string-value.
-    *  \return false if !string. (Seg-fault if str or end are NULL.)
-    */
-   bool getString(char const** begin, char const** end) const;
-#ifdef JSON_USE_CPPTL
-   CppTL::ConstString asConstString() const;
-#endif
-   Int asInt() const;
-   UInt asUInt() const;
-#if defined(JSON_HAS_INT64)
-   Int64 asInt64() const;
-   UInt64 asUInt64() const;
-#endif // if defined(JSON_HAS_INT64)
-   LargestInt asLargestInt() const;
-   LargestUInt asLargestUInt() const;
-   float asFloat() const;
-   double asDouble() const;
-   bool asBool() const;
-
-   bool isNull() const;
-   bool isBool() const;
-   bool isInt() const;
-   bool isInt64() const;
-   bool isUInt() const;
-   bool isUInt64() 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 ).
-   /// 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[](int 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;
-
-   /// 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[](int 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.
-   /// \note Because of our implementation, keys are limited to 2^30 -1 chars.
-   ///  Exceeding that will cause an exception.
-   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.
-   /// \param key may contain embedded nulls.
-   Value& operator[](const JSONCPP_STRING& key);
-   /// Access an object value by name, returns null if there is no member with
-   /// that name.
-   /// \param key may contain embedded nulls.
-   const Value& operator[](const JSONCPP_STRING& key) const;
-   /** \brief Access an object value by name, create a null member if it does not
-   exist.
-
-    * If the object has 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.
-   /// \note deep copy
-   Value get(const char* key, const Value& defaultValue) const;
-   /// Return the member named key if it exist, defaultValue otherwise.
-   /// \note deep copy
-   /// \note key may contain embedded nulls.
-   Value get(const char* begin, const char* end, const Value& defaultValue) const;
-   /// Return the member named key if it exist, defaultValue otherwise.
-   /// \note deep copy
-   /// \param key may contain embedded nulls.
-   Value get(const JSONCPP_STRING& key, const Value& defaultValue) const;
-#ifdef JSON_USE_CPPTL
-   /// Return the member named key if it exist, defaultValue otherwise.
-   /// \note deep copy
-   Value get(const CppTL::ConstString& key, const Value& defaultValue) const;
-#endif
-   /// Most general and efficient version of isMember()const, get()const,
-   /// and operator[]const
-   /// \note As stated elsewhere, behavior is undefined if (end-begin) >= 2^30
-   Value const* find(char const* begin, char const* end) const;
-   /// Most general and efficient version of object-mutators.
-   /// \note As stated elsewhere, behavior is undefined if (end-begin) >= 2^30
-   /// \return non-zero, but JSON_ASSERT if this is neither object nor nullValue.
-   Value const* demand(char const* begin, char const* end);
-   /// \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
-   /// \deprecated
-   Value removeMember(const char* key);
-   /// Same as removeMember(const char*)
-   /// \param key may contain embedded nulls.
-   /// \deprecated
-   Value removeMember(const JSONCPP_STRING& key);
-   /// Same as removeMember(const char* begin, const char* end, Value* removed),
-   /// but 'key' is null-terminated.
-   bool removeMember(const char* key, Value* removed);
-   /** \brief Remove the named map member.
-
-      Update 'removed' iff removed.
-      \param key may contain embedded nulls.
-      \return true iff removed (no exceptions)
-    */
-   bool removeMember(JSONCPP_STRING const& key, Value* removed);
-   /// Same as removeMember(JSONCPP_STRING const& key, Value* removed)
-   bool removeMember(const char* begin, const char* end, Value* removed);
-   /** \brief Remove the indexed array element.
-
-      O(n) expensive operations.
-      Update 'removed' iff removed.
-      \return true iff removed (no exceptions)
-    */
-   bool removeIndex(ArrayIndex i, Value* removed);
-
-   /// Return true if the object has a member named key.
-   /// \note 'key' must be null-terminated.
-   bool isMember(const char* key) const;
-   /// Return true if the object has a member named key.
-   /// \param key may contain embedded nulls.
-   bool isMember(const JSONCPP_STRING& key) const;
-   /// Same as isMember(JSONCPP_STRING const& key)const
-   bool isMember(const char* begin, const char* end) 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
-
-   /// \deprecated Always pass len.
-   JSONCPP_DEPRECATED("Use setComment(JSONCPP_STRING const&) instead.")
-   void setComment(const char* comment, CommentPlacement placement);
-   /// Comments must be //... or /* ... */
-   void setComment(const char* comment, size_t len, CommentPlacement placement);
-   /// Comments must be //... or /* ... */
-   void setComment(const JSONCPP_STRING& comment, CommentPlacement placement);
-   bool hasComment(CommentPlacement placement) const;
-   /// Include delimiters and embedded newlines.
-   JSONCPP_STRING getComment(CommentPlacement placement) const;
-
-   JSONCPP_STRING toStyledString() const;
-
-   const_iterator begin() const;
-   const_iterator end() const;
-
-   iterator begin();
-   iterator end();
-
-   // Accessors for the [start, limit) range of bytes within the JSON text from
-   // which this value was parsed, if any.
-   void setOffsetStart(ptrdiff_t start);
-   void setOffsetLimit(ptrdiff_t limit);
-   ptrdiff_t getOffsetStart() const;
-   ptrdiff_t getOffsetLimit() const;
-
-private:
-   void initBasic(ValueType type, bool allocated = false);
-
-   Value& resolveReference(const char* key);
-   Value& resolveReference(const char* key, const char* end);
-
-   struct CommentInfo {
-      CommentInfo();
-      ~CommentInfo();
-
-      void setComment(const char* text, size_t len);
-
-      char* comment_;
-   };
-
-   // struct MemberNamesTransform
-   //{
-   //   typedef const char *result_type;
-   //   const char *operator()( const CZString &name ) const
-   //   {
-   //      return name.c_str();
-   //   }
-   //};
-
-   union ValueHolder {
-      LargestInt int_;
-      LargestUInt uint_;
-      double real_;
-      bool bool_;
-      char* string_;  // actually ptr to unsigned, followed by str, unless !allocated_
-      ObjectValues* map_;
-   } value_;
-   ValueType type_ : 8;
-   unsigned int allocated_ : 1; // Notes: if declared as bool, bitfield is useless.
-   // If not allocated_, string_ must be null-terminated.
-   CommentInfo* comments_;
-
-   // [start, limit) byte offsets in the source JSON text from which this Value
-   // was extracted.
-   ptrdiff_t start_;
-   ptrdiff_t limit_;
-};
-
-/** \brief Experimental and untested: represents an element of the "path" to
- * access a node.
- */
-class JSON_API PathArgument {
-public:
-   friend class Path;
-
-   PathArgument();
-   PathArgument(ArrayIndex index);
-   PathArgument(const char* key);
-   PathArgument(const JSONCPP_STRING& key);
-
-private:
-   enum Kind {
-      kindNone = 0,
-      kindIndex,
-      kindKey
-   };
-   JSONCPP_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 JSON_API Path {
-public:
-   Path(const JSONCPP_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 JSONCPP_STRING& path, const InArgs& in);
-   void addPathInArg(const JSONCPP_STRING& path,
-                     const InArgs& in,
-                     InArgs::const_iterator& itInArg,
-                     PathArgument::Kind kind);
-   void invalidPath(const JSONCPP_STRING& path, int location);
-
-   Args args_;
-};
-
-/** \brief base class for Value iterators.
- *
- */
-class JSON_API ValueIteratorBase {
-public:
-   typedef std::bidirectional_iterator_tag iterator_category;
-   typedef unsigned int size_t;
-   typedef int difference_type;
-   typedef ValueIteratorBase SelfType;
-
-   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 other.computeDistance(*this);
-   }
-
-   /// 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, or -1 if it is not an arrayValue.
-   UInt index() const;
-
-   /// Return the member name of the referenced Value, or "" if it is not an
-   /// objectValue.
-   /// \note Avoid `c_str()` on result, as embedded zeroes are possible.
-   JSONCPP_STRING name() const;
-
-   /// Return the member name of the referenced Value. "" if it is not an
-   /// objectValue.
-   /// \deprecated This cannot be used for UTF-8 strings, since there can be embedded nulls.
-   JSONCPP_DEPRECATED("Use `key = name();` instead.")
-   char const* memberName() const;
-   /// Return the member name of the referenced Value, or NULL if it is not an
-   /// objectValue.
-   /// \note Better version than memberName(). Allows embedded nulls.
-   char const* memberName(char const** end) 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:
-   Value::ObjectValues::iterator current_;
-   // Indicates that iterator is for a null value.
-   bool isNull_;
-
-public:
-   // For some reason, BORLAND needs these at the end, rather
-   // than earlier. No idea why.
-   ValueIteratorBase();
-   explicit ValueIteratorBase(const Value::ObjectValues::iterator& current);
-};
-
-/** \brief const iterator for object and array value.
- *
- */
-class JSON_API ValueConstIterator : public ValueIteratorBase {
-   friend class Value;
-
-public:
-   typedef const Value value_type;
-   //typedef unsigned int size_t;
-   //typedef int difference_type;
-   typedef const Value& reference;
-   typedef const Value* pointer;
-   typedef ValueConstIterator SelfType;
-
-   ValueConstIterator();
-   ValueConstIterator(ValueIterator const& other);
-
-private:
-   /*! \internal Use by Value to create an iterator.
-    */
-   explicit ValueConstIterator(const Value::ObjectValues::iterator& current);
-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(); }
-
-   pointer operator->() const { return &deref(); }
-};
-
-/** \brief Iterator for object and array value.
- */
-class JSON_API ValueIterator : public ValueIteratorBase {
-   friend class Value;
-
-public:
-   typedef Value value_type;
-   typedef unsigned int size_t;
-   typedef int difference_type;
-   typedef Value& reference;
-   typedef Value* pointer;
-   typedef ValueIterator SelfType;
-
-   ValueIterator();
-   explicit ValueIterator(const ValueConstIterator& other);
-   ValueIterator(const ValueIterator& other);
-
-private:
-   /*! \internal Use by Value to create an iterator.
-    */
-   explicit ValueIterator(const Value::ObjectValues::iterator& current);
-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(); }
-
-   pointer operator->() const { return &deref(); }
-};
-
-} // namespace Json
-
-
-namespace std {
-/// Specialize std::swap() for Json::Value.
-template<>
-inline void swap(Json::Value& a, Json::Value& b) { a.swap(b); }
-}
-
-
-#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
-#pragma warning(pop)
-#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
-
-#endif // CPPTL_JSON_H_INCLUDED
-
-// //////////////////////////////////////////////////////////////////////
-// End of content of file: include/json/value.h
-// //////////////////////////////////////////////////////////////////////
-
-
-
-
-
-
-// //////////////////////////////////////////////////////////////////////
-// Beginning of content of file: include/json/reader.h
-// //////////////////////////////////////////////////////////////////////
-
-// 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
-
-#if !defined(JSON_IS_AMALGAMATION)
-#include "features.h"
-#include "value.h"
-#endif // if !defined(JSON_IS_AMALGAMATION)
-#include <deque>
-#include <iosfwd>
-#include <stack>
-#include <string>
-#include <istream>
-
-// Disable warning C4251: <data member>: <type> needs to have dll-interface to
-// be used by...
-#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
-#pragma warning(push)
-#pragma warning(disable : 4251)
-#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
-
-namespace Json {
-
-/** \brief Unserialize a <a HREF="http://www.json.org">JSON</a> document into a
- *Value.
- *
- * \deprecated Use CharReader and CharReaderBuilder.
- */
-class JSON_API Reader {
-public:
-   typedef char Char;
-   typedef const Char* Location;
-
-   /** \brief An error tagged with where in the JSON text it was encountered.
-    *
-    * The offsets give the [start, limit) range of bytes within the text. Note
-    * that this is bytes, not codepoints.
-    *
-    */
-   struct StructuredError {
-      ptrdiff_t offset_start;
-      ptrdiff_t offset_limit;
-      std::string message;
-   };
-
-   /** \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 beginDoc Pointer on the beginning of the UTF-8 encoded string of the
-   document to read.
-    * \param endDoc Pointer on the end of the UTF-8 encoded string of the
-   document to read.
-    *               Must be >= beginDoc.
-    * \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(JSONCPP_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.
-    * \deprecated Use getFormattedErrorMessages() instead (typo fix).
-    */
-   JSONCPP_DEPRECATED("Use getFormattedErrorMessages() instead.")
-   std::string getFormatedErrorMessages() const;
-
-   /** \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 getFormattedErrorMessages() const;
-
-   /** \brief Returns a vector of structured erros encounted while parsing.
-    * \return A (possibly empty) vector of StructuredError objects. Currently
-    *         only one error can be returned, but the caller should tolerate
-    * multiple
-    *         errors.  This can occur if the parser recovers from a non-fatal
-    *         parse error and then encounters additional errors.
-    */
-   std::vector<StructuredError> getStructuredErrors() const;
-
-   /** \brief Add a semantic error message.
-    * \param value JSON Value location associated with the error
-    * \param message The error message.
-    * \return \c true if the error was successfully added, \c false if the
-    * Value offset exceeds the document size.
-    */
-   bool pushError(const Value& value, const std::string& message);
-
-   /** \brief Add a semantic error message with extra context.
-    * \param value JSON Value location associated with the error
-    * \param message The error message.
-    * \param extra Additional JSON Value location to contextualize the error
-    * \return \c true if the error was successfully added, \c false if either
-    * Value offset exceeds the document size.
-    */
-   bool pushError(const Value& value, const std::string& message, const Value& extra);
-
-   /** \brief Return whether there are any errors.
-    * \return \c true if there are no errors to report \c false if
-    * errors have occurred.
-    */
-   bool good() 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 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 decodeNumber(Token& token, Value& decoded);
-   bool decodeString(Token& token);
-   bool decodeString(Token& token, std::string& decoded);
-   bool decodeDouble(Token& token);
-   bool decodeDouble(Token& token, Value& decoded);
-   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_;
-};  // Reader
-
-/** Interface for reading JSON from a char array.
- */
-class JSON_API CharReader {
-public:
-   virtual ~CharReader() {}
-   /** \brief Read a Value from a <a HREF="http://www.json.org">JSON</a>
-   document.
-    * The document must be a UTF-8 encoded string containing the document to read.
-    *
-    * \param beginDoc Pointer on the beginning of the UTF-8 encoded string of the
-   document to read.
-    * \param endDoc Pointer on the end of the UTF-8 encoded string of the
-   document to read.
-    *        Must be >= beginDoc.
-    * \param root [out] Contains the root value of the document if it was
-    *             successfully parsed.
-    * \param errs [out] Formatted error messages (if not NULL)
-    *        a user friendly string that lists errors in the parsed
-    * document.
-    * \return \c true if the document was successfully parsed, \c false if an
-   error occurred.
-    */
-   virtual bool parse(
-         char const* beginDoc, char const* endDoc,
-         Value* root, std::string* errs) = 0;
-
-   class JSON_API Factory {
-   public:
-      virtual ~Factory() {}
-      /** \brief Allocate a CharReader via operator new().
-       * \throw std::exception if something goes wrong (e.g. invalid settings)
-       */
-      virtual CharReader* newCharReader() const = 0;
-   };  // Factory
-};  // CharReader
-
-/** \brief Build a CharReader implementation.
-
-Usage:
-\code
-  using namespace Json;
-  CharReaderBuilder builder;
-  builder["collectComments"] = false;
-  Value value;
-  std::string errs;
-  bool ok = parseFromStream(builder, std::cin, &value, &errs);
-\endcode
- */
-class JSON_API CharReaderBuilder : public CharReader::Factory {
-public:
-   // Note: We use a Json::Value so that we can add data-members to this class
-   // without a major version bump.
-   /** Configuration of this builder.
-    These are case-sensitive.
-    Available settings (case-sensitive):
-    - `"collectComments": false or true`
-      - true to collect comment and allow writing them
-        back during serialization, false to discard comments.
-        This parameter is ignored if allowComments is false.
-    - `"allowComments": false or true`
-      - true if comments are allowed.
-    - `"strictRoot": false or true`
-      - true if root must be either an array or an object value
-    - `"allowDroppedNullPlaceholders": false or true`
-      - true if dropped null placeholders are allowed. (See StreamWriterBuilder.)
-    - `"allowNumericKeys": false or true`
-      - true if numeric object keys are allowed.
-    - `"allowSingleQuotes": false or true`
-      - true if '' are allowed for strings (both keys and values)
-    - `"stackLimit": integer`
-      - Exceeding stackLimit (recursive depth of `readValue()`) will
-        cause an exception.
-      - This is a security issue (seg-faults caused by deeply nested JSON),
-        so the default is low.
-    - `"failIfExtra": false or true`
-      - If true, `parse()` returns false when extra non-whitespace trails
-        the JSON value in the input string.
-    - `"rejectDupKeys": false or true`
-      - If true, `parse()` returns false when a key is duplicated within an object.
-    - `"allowSpecialFloats": false or true`
-      - If true, special float values (NaNs and infinities) are allowed
-        and their values are lossfree restorable.
-
-    You can examine 'settings_` yourself
-    to see the defaults. You can also write and read them just like any
-    JSON Value.
-    \sa setDefaults()
-    */
-   Json::Value settings_;
-
-   CharReaderBuilder();
-   ~CharReaderBuilder();
-
-   CharReader* newCharReader() const;
-
-   /** \return true if 'settings' are legal and consistent;
-    *   otherwise, indicate bad settings via 'invalid'.
-    */
-   bool validate(Json::Value* invalid) const;
-
-   /** A simple way to update a specific setting.
-    */
-   Value& operator[](std::string key);
-
-   /** Called by ctor, but you can use this to reset settings_.
-    * \pre 'settings' != NULL (but Json::null is fine)
-    * \remark Defaults:
-    * \snippet src/lib_json/json_reader.cpp CharReaderBuilderDefaults
-    */
-   static void setDefaults(Json::Value* settings);
-   /** Same as old Features::strictMode().
-    * \pre 'settings' != NULL (but Json::null is fine)
-    * \remark Defaults:
-    * \snippet src/lib_json/json_reader.cpp CharReaderBuilderStrictMode
-    */
-   static void strictMode(Json::Value* settings);
-};
-
-/** Consume entire stream and use its begin/end.
- * Someday we might have a real StreamReader, but for now this
- * is convenient.
- */
-bool JSON_API parseFromStream(
-      CharReader::Factory const&,
-      JSONCPP_ISTREAM&,
-      Value* root, std::string* errs);
-
-/** \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<<()
- */
-JSON_API JSONCPP_ISTREAM& operator>>(JSONCPP_ISTREAM&, Value&);
-
-} // namespace Json
-
-#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
-#pragma warning(pop)
-#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
-
-#endif // CPPTL_JSON_READER_H_INCLUDED
-
-// //////////////////////////////////////////////////////////////////////
-// End of content of file: include/json/reader.h
-// //////////////////////////////////////////////////////////////////////
-
-
-
-
-
-
-// //////////////////////////////////////////////////////////////////////
-// Beginning of content of file: include/json/writer.h
-// //////////////////////////////////////////////////////////////////////
-
-// 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
-
-#if !defined(JSON_IS_AMALGAMATION)
-#include "value.h"
-#endif // if !defined(JSON_IS_AMALGAMATION)
-#include <vector>
-#include <string>
-#include <ostream>
-
-// Disable warning C4251: <data member>: <type> needs to have dll-interface to
-// be used by...
-#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
-#pragma warning(push)
-#pragma warning(disable : 4251)
-#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
-
-namespace Json {
-
-class Value;
-
-/**
-
-Usage:
-\code
-  using namespace Json;
-  void writeToStdout(StreamWriter::Factory const& factory, Value const& value) {
-    std::unique_ptr<StreamWriter> const writer(
-      factory.newStreamWriter());
-    writer->write(value, &std::cout);
-    std::cout << std::endl;  // add lf and flush
-  }
-\endcode
- */
-class JSON_API StreamWriter {
-protected:
-   JSONCPP_OSTREAM* sout_;  // not owned; will not delete
-public:
-   StreamWriter();
-   virtual ~StreamWriter();
-   /** Write Value into document as configured in sub-class.
-      Do not take ownership of sout, but maintain a reference during function.
-      \pre sout != NULL
-      \return zero on success (For now, we always return zero, so check the stream instead.)
-      \throw std::exception possibly, depending on configuration
-    */
-   virtual int write(Value const& root, JSONCPP_OSTREAM* sout) = 0;
-
-   /** \brief A simple abstract factory.
-    */
-   class JSON_API Factory {
-   public:
-      virtual ~Factory();
-      /** \brief Allocate a CharReader via operator new().
-       * \throw std::exception if something goes wrong (e.g. invalid settings)
-       */
-      virtual StreamWriter* newStreamWriter() const = 0;
-   };  // Factory
-};  // StreamWriter
-
-/** \brief Write into stringstream, then return string, for convenience.
- * A StreamWriter will be created from the factory, used, and then deleted.
- */
-std::string JSON_API writeString(StreamWriter::Factory const& factory, Value const& root);
-
-
-/** \brief Build a StreamWriter implementation.
-
-Usage:
-\code
-  using namespace Json;
-  Value value = ...;
-  StreamWriterBuilder builder;
-  builder["commentStyle"] = "None";
-  builder["indentation"] = "   ";  // or whatever you like
-  std::unique_ptr<Json::StreamWriter> writer(
-      builder.newStreamWriter());
-  writer->write(value, &std::cout);
-  std::cout << std::endl;  // add lf and flush
-\endcode
- */
-class JSON_API StreamWriterBuilder : public StreamWriter::Factory {
-public:
-   // Note: We use a Json::Value so that we can add data-members to this class
-   // without a major version bump.
-   /** Configuration of this builder.
-    Available settings (case-sensitive):
-    - "commentStyle": "None" or "All"
-    - "indentation":  "<anything>"
-    - "enableYAMLCompatibility": false or true
-      - slightly change the whitespace around colons
-    - "dropNullPlaceholders": false or true
-      - Drop the "null" string from the writer's output for nullValues.
-        Strictly speaking, this is not valid JSON. But when the output is being
-        fed to a browser's Javascript, it makes for smaller output and the
-        browser can handle the output just fine.
-    - "useSpecialFloats": false or true
-      - If true, outputs non-finite floating point values in the following way:
-        NaN values as "NaN", positive infinity as "Infinity", and negative infinity
-        as "-Infinity".
-
-    You can examine 'settings_` yourself
-    to see the defaults. You can also write and read them just like any
-    JSON Value.
-    \sa setDefaults()
-    */
-   Json::Value settings_;
-
-   StreamWriterBuilder();
-   ~StreamWriterBuilder();
-
-   /**
-    * \throw std::exception if something goes wrong (e.g. invalid settings)
-    */
-   StreamWriter* newStreamWriter() const;
-
-   /** \return true if 'settings' are legal and consistent;
-    *   otherwise, indicate bad settings via 'invalid'.
-    */
-   bool validate(Json::Value* invalid) const;
-   /** A simple way to update a specific setting.
-    */
-   Value& operator[](std::string key);
-
-   /** Called by ctor, but you can use this to reset settings_.
-    * \pre 'settings' != NULL (but Json::null is fine)
-    * \remark Defaults:
-    * \snippet src/lib_json/json_writer.cpp StreamWriterBuilderDefaults
-    */
-   static void setDefaults(Json::Value* settings);
-};
-
-/** \brief Abstract class for writers.
- * \deprecated Use StreamWriter. (And really, this is an implementation detail.)
- */
-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
- * \deprecated Use StreamWriterBuilder.
- */
-class JSON_API FastWriter : public Writer {
-
-public:
-   FastWriter();
-   ~FastWriter() {}
-
-   void enableYAMLCompatibility();
-
-   /** \brief Drop the "null" string from the writer's output for nullValues.
-    * Strictly speaking, this is not valid JSON. But when the output is being
-    * fed to a browser's Javascript, it makes for smaller output and the
-    * browser can handle the output just fine.
-    */
-   void dropNullPlaceholders();
-
-   void omitEndingLineFeed();
-
-public: // overridden from Writer
-   std::string write(const Value& root);
-
-private:
-   void writeValue(const Value& value);
-
-   std::string document_;
-   bool yamlCompatiblityEnabled_;
-   bool dropNullPlaceholders_;
-   bool omitEndingLineFeed_;
-};
-
-/** \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()
- * \deprecated Use StreamWriterBuilder.
- */
-class JSON_API StyledWriter : public Writer {
-public:
-   StyledWriter();
-   ~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.
-    */
-   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_;
-   unsigned int rightMargin_;
-   unsigned 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()
- * \deprecated Use StreamWriterBuilder.
- */
-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(JSONCPP_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_;
-   JSONCPP_OSTREAM* document_;
-   std::string indentString_;
-   unsigned int rightMargin_;
-   std::string indentation_;
-   bool addChildValues_ : 1;
-   bool indented_ : 1;
-};
-
-#if defined(JSON_HAS_INT64)
-std::string JSON_API valueToString(Int value);
-std::string JSON_API valueToString(UInt value);
-#endif // if defined(JSON_HAS_INT64)
-std::string JSON_API valueToString(LargestInt value);
-std::string JSON_API valueToString(LargestUInt 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>>()
-JSON_API JSONCPP_OSTREAM& operator<<(JSONCPP_OSTREAM&, const Value& root);
-
-} // namespace Json
-
-#if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
-#pragma warning(pop)
-#endif // if defined(JSONCPP_DISABLE_DLL_INTERFACE_WARNING)
-
-#endif // JSON_WRITER_H_INCLUDED
-
-// //////////////////////////////////////////////////////////////////////
-// End of content of file: include/json/writer.h
-// //////////////////////////////////////////////////////////////////////
-
-
-
-
-
-
-// //////////////////////////////////////////////////////////////////////
-// Beginning of content of file: include/json/assertions.h
-// //////////////////////////////////////////////////////////////////////
-
-// 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_ASSERTIONS_H_INCLUDED
-#define CPPTL_JSON_ASSERTIONS_H_INCLUDED
-
-#include <stdlib.h>
-#include <sstream>
-
-#if !defined(JSON_IS_AMALGAMATION)
-#include "config.h"
-#endif // if !defined(JSON_IS_AMALGAMATION)
-
-/** It should not be possible for a maliciously designed file to
- *  cause an abort() or seg-fault, so these macros are used only
- *  for pre-condition violations and internal logic errors.
- */
-#if JSON_USE_EXCEPTION
-
-// @todo <= add detail about condition in exception
-# define JSON_ASSERT(condition)                                                \
-      {if (!(condition)) {Json::throwLogicError( "assert json failed" );}}
-
-# define JSON_FAIL_MESSAGE(message)                                            \
-      {                                                                            \
-   JSONCPP_OSTRINGSTREAM oss; oss << message;                                    \
-   Json::throwLogicError(oss.str());                                          \
-   abort();                                                                   \
-      }
-
-#else // JSON_USE_EXCEPTION
-
-# define JSON_ASSERT(condition) assert(condition)
-
-// The call to assert() will show the failure message in debug builds. In
-// release builds we abort, for a core-dump or debugger.
-# define JSON_FAIL_MESSAGE(message)                                            \
-      {                                                                            \
-   JSONCPP_OSTRINGSTREAM oss; oss << message;                                    \
-   assert(false && oss.str().c_str());                                        \
-   abort();                                                                   \
-      }
-
-
-#endif
-
-#define JSON_ASSERT_MESSAGE(condition, message)                                \
-      if (!(condition)) {                                                          \
-         JSON_FAIL_MESSAGE(message);                                                \
-      }
-
-#endif // CPPTL_JSON_ASSERTIONS_H_INCLUDED
-
-// //////////////////////////////////////////////////////////////////////
-// End of content of file: include/json/assertions.h
-// //////////////////////////////////////////////////////////////////////
-
-
-
-
-
-#endif //ifndef JSON_AMALGATED_H_INCLUDED
diff --git a/include/ossim/base/ossim2dTo2dIdentityTransform.h b/include/ossim/base/ossim2dTo2dIdentityTransform.h
index fd4da43..d7d806e 100644
--- a/include/ossim/base/ossim2dTo2dIdentityTransform.h
+++ b/include/ossim/base/ossim2dTo2dIdentityTransform.h
@@ -1,6 +1,6 @@
 //*******************************************************************
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/base/ossim2dTo2dMatrixTransform.h b/include/ossim/base/ossim2dTo2dMatrixTransform.h
index 349deba..b5ecc65 100644
--- a/include/ossim/base/ossim2dTo2dMatrixTransform.h
+++ b/include/ossim/base/ossim2dTo2dMatrixTransform.h
@@ -1,6 +1,6 @@
 //----------------------------------------------------------------------------
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/base/ossim2dTo2dShiftTransform.h b/include/ossim/base/ossim2dTo2dShiftTransform.h
index 7c74694..c9fec5b 100644
--- a/include/ossim/base/ossim2dTo2dShiftTransform.h
+++ b/include/ossim/base/ossim2dTo2dShiftTransform.h
@@ -1,6 +1,6 @@
 //----------------------------------------------------------------------------
 //
-// License:  LGPL
+// License:  MIT
 //
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/base/ossim2dTo2dTransform.h b/include/ossim/base/ossim2dTo2dTransform.h
index 33e1ae9..23b177b 100644
--- a/include/ossim/base/ossim2dTo2dTransform.h
+++ b/include/ossim/base/ossim2dTo2dTransform.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc. 
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/base/ossim2dTo2dTransformFactory.h b/include/ossim/base/ossim2dTo2dTransformFactory.h
index 8694443..6b2e862 100644
--- a/include/ossim/base/ossim2dTo2dTransformFactory.h
+++ b/include/ossim/base/ossim2dTo2dTransformFactory.h
@@ -1,6 +1,6 @@
 //**************************************************************************************************
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/base/ossim2dTo2dTransformFactoryBase.h b/include/ossim/base/ossim2dTo2dTransformFactoryBase.h
index 24a8d51..553c5ce 100644
--- a/include/ossim/base/ossim2dTo2dTransformFactoryBase.h
+++ b/include/ossim/base/ossim2dTo2dTransformFactoryBase.h
@@ -3,7 +3,7 @@
 #include <ossim/base/ossimObjectFactory.h>
 //**************************************************************************************************
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/base/ossim2dTo2dTransformRegistry.h b/include/ossim/base/ossim2dTo2dTransformRegistry.h
index 9bf06de..6613b20 100644
--- a/include/ossim/base/ossim2dTo2dTransformRegistry.h
+++ b/include/ossim/base/ossim2dTo2dTransformRegistry.h
@@ -1,6 +1,6 @@
 //**************************************************************************************************
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/base/ossimBlockIStream.h b/include/ossim/base/ossimBlockIStream.h
index b6be7b0..fdcf595 100644
--- a/include/ossim/base/ossimBlockIStream.h
+++ b/include/ossim/base/ossimBlockIStream.h
@@ -1,5 +1,5 @@
-#ifndef ossimBlockReader_HEADER
-#define ossimBlockReader_HEADER 1
+#ifndef ossimBlockStream_HEADER
+#define ossimBlockStream_HEADER 1
 #include <ossim/base/ossimBlockStreamBuffer.h>
 
 namespace ossim {
diff --git a/include/ossim/base/ossimCallback1.h b/include/ossim/base/ossimCallback1.h
index 3375676..104a579 100644
--- a/include/ossim/base/ossimCallback1.h
+++ b/include/ossim/base/ossimCallback1.h
@@ -2,7 +2,7 @@
 //
 // File: ossimCallback1wRet.h
 // 
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/base/ossimCallback1wRet.h b/include/ossim/base/ossimCallback1wRet.h
index 4599662..f27eec9 100644
--- a/include/ossim/base/ossimCallback1wRet.h
+++ b/include/ossim/base/ossimCallback1wRet.h
@@ -2,7 +2,7 @@
 //
 // File: ossimCallback1wRet.h
 // 
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/base/ossimCallback2wRet.h b/include/ossim/base/ossimCallback2wRet.h
index cd03bab..f022f52 100644
--- a/include/ossim/base/ossimCallback2wRet.h
+++ b/include/ossim/base/ossimCallback2wRet.h
@@ -2,7 +2,7 @@
 //
 // File: ossimCallback2wRet.h
 // 
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/base/ossimCommon.h b/include/ossim/base/ossimCommon.h
index 01b2266..5d02fce 100644
--- a/include/ossim/base/ossimCommon.h
+++ b/include/ossim/base/ossimCommon.h
@@ -1,6 +1,6 @@
 //*******************************************************************
 //
-// License:  LGPL
+// License:  MIT
 //
 // See LICENSE.txt file in the top level directory for more details.
 //
@@ -627,11 +627,11 @@ namespace ossim
 	// REQUIRE(unbalancedQuotes != NULL);
 
    /**
-    * @brief Get the number threads to use from ossimPreferences or OpenThreads.
+    * @brief Get the number threads to use from ossimPreferences or ossim::Thread.
     *
     * Keyword searched for is:  "ossim_threads"
     *
-    * If keyword is not found OpenThreads::GetNumberOfProcessors() is used.
+    * If keyword is not found ossim::Thread::getNumberOfProcessors() is used.
     *
     * @return Number of threads. Default=1
     */
diff --git a/include/ossim/base/ossimConnectableDisplayListener.h b/include/ossim/base/ossimConnectableDisplayListener.h
index 07649b0..a921c28 100644
--- a/include/ossim/base/ossimConnectableDisplayListener.h
+++ b/include/ossim/base/ossimConnectableDisplayListener.h
@@ -1,7 +1,7 @@
 //----------------------------------------------------------------------------
 // Copyright (c) 2004, David Burken, all rights reserved.
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/base/ossimConnectionEvent.h b/include/ossim/base/ossimConnectionEvent.h
index d86471c..152238a 100644
--- a/include/ossim/base/ossimConnectionEvent.h
+++ b/include/ossim/base/ossimConnectionEvent.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc. 
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/base/ossimContainerEvent.h b/include/ossim/base/ossimContainerEvent.h
index d7485c3..c6e1b11 100644
--- a/include/ossim/base/ossimContainerEvent.h
+++ b/include/ossim/base/ossimContainerEvent.h
@@ -1,6 +1,6 @@
 //*******************************************************************
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/base/ossimDataObject.h b/include/ossim/base/ossimDataObject.h
index b2102d3..34bce76 100644
--- a/include/ossim/base/ossimDataObject.h
+++ b/include/ossim/base/ossimDataObject.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc. 
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/base/ossimDate.h b/include/ossim/base/ossimDate.h
index fe25729..62275d0 100644
--- a/include/ossim/base/ossimDate.h
+++ b/include/ossim/base/ossimDate.h
@@ -1,6 +1,6 @@
 //*******************************************************************
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
@@ -14,8 +14,7 @@
 #include <iosfwd>
 #include <ossim/base/ossimConstants.h>
 #include <ossim/base/ossimXmlNode.h>
-#include <OpenThreads/Mutex>
-#include <OpenThreads/ScopedLock>
+#include <mutex>
 
 class OSSIM_DLL ossimLocalTm : public std::tm
 {
@@ -233,7 +232,7 @@ protected:
    void pYear(std::ostream & os, int fmt) const;
    
    void setTimezoneOffsetFromGmt();
-   static OpenThreads::Mutex m_mutex;
+   static std::mutex m_mutex;
    double theFractionalSecond;
    mutable int m_timezoneOffset;
 };
diff --git a/include/ossim/base/ossimDateProperty.h b/include/ossim/base/ossimDateProperty.h
index 211563f..ed0ef54 100644
--- a/include/ossim/base/ossimDateProperty.h
+++ b/include/ossim/base/ossimDateProperty.h
@@ -1,6 +1,6 @@
 //*******************************************************************
 //
-// LICENSE: LGPL see top level license.txt
+// LICENSE: MIT see top level license.txt
 //
 // Author: Garrett Potts
 //
diff --git a/include/ossim/base/ossimDatumFactoryRegistry.h b/include/ossim/base/ossimDatumFactoryRegistry.h
index 27e16f9..f79c225 100644
--- a/include/ossim/base/ossimDatumFactoryRegistry.h
+++ b/include/ossim/base/ossimDatumFactoryRegistry.h
@@ -15,8 +15,7 @@
 #include <vector>
 #include <ossim/base/ossimConstants.h> /* for OSSIM_DLL macro */
 #include <ossim/base/ossimDatumFactoryInterface.h> 
-#include <OpenThreads/ReadWriteMutex>
-
+#include <mutex>
 // Forward class declarations.
 class ossimDatumFactoryInterface;
 class ossimString;
@@ -68,7 +67,7 @@ protected:
    /** Single static instance of this class. */
    //static ossimDatumFactoryRegistry* theInstance;
 
-	mutable OpenThreads::ReadWriteMutex theFactoryListMutex;
+	mutable std::mutex theFactoryListMutex;
    std::vector<ossimDatumFactoryInterface*> theFactoryList;
 };
 
diff --git a/include/ossim/base/ossimDirectory.h b/include/ossim/base/ossimDirectory.h
index 619dfdd..17a8e5f 100644
--- a/include/ossim/base/ossimDirectory.h
+++ b/include/ossim/base/ossimDirectory.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc. 
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 // 
diff --git a/include/ossim/base/ossimDisplayInterface.h b/include/ossim/base/ossimDisplayInterface.h
index 9953db9..2073af5 100644
--- a/include/ossim/base/ossimDisplayInterface.h
+++ b/include/ossim/base/ossimDisplayInterface.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc. 
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/base/ossimDpt3d.h b/include/ossim/base/ossimDpt3d.h
index 7964442..0d7a8fe 100644
--- a/include/ossim/base/ossimDpt3d.h
+++ b/include/ossim/base/ossimDpt3d.h
@@ -1,6 +1,6 @@
 //*******************************************************************
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/base/ossimDrect.h b/include/ossim/base/ossimDrect.h
index b67251c..47d7954 100644
--- a/include/ossim/base/ossimDrect.h
+++ b/include/ossim/base/ossimDrect.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc.
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/base/ossimDuration.h b/include/ossim/base/ossimDuration.h
index c61921b..dd9c217 100644
--- a/include/ossim/base/ossimDuration.h
+++ b/include/ossim/base/ossimDuration.h
@@ -1,6 +1,6 @@
 //*******************************************************************
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/base/ossimFactoryListInterface.h b/include/ossim/base/ossimFactoryListInterface.h
index f96001c..f82610a 100644
--- a/include/ossim/base/ossimFactoryListInterface.h
+++ b/include/ossim/base/ossimFactoryListInterface.h
@@ -1,6 +1,6 @@
 //**************************************************************************************************
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
@@ -10,16 +10,24 @@
 // $Id$
 #ifndef ossimFactoryListInterface_HEADER
 #define ossimFactoryListInterface_HEADER
-#include <OpenThreads/Mutex>
-#include <OpenThreads/ScopedLock>
 #include <vector>
 #include <ossim/base/ossimRefPtr.h>
 #include <ossim/base/ossimObject.h>
 #include <ossim/base/ossimString.h>
 #include <ossim/base/ossimKeywordlist.h>
+#include <mutex>
 
 /**
  * The is a factory list interface that allows registries to be accessed in a common way.  
+ *
+ * This is typically used by the Registries.  The registries derive from this
+ * interface so that it will have the ability to give access to others
+ * to add to it's registry:
+ *
+ * Pseudo Code:
+ * @code
+ * someRegistry::instance()->addFactory(someFactory::instance());
+ * @endcode
  */
 template <class T, class NativeType>
 class ossimFactoryListInterface
@@ -46,7 +54,7 @@ class ossimFactoryListInterface
       bool isFactoryRegistered(T* factory)const
       {
          if(!factory) return false;
-         OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_factoryListMutex);
+         std::lock_guard<std::mutex> lock(m_factoryListMutex);
          
          return findFactory(factory);
       }
@@ -58,7 +66,7 @@ class ossimFactoryListInterface
       void registerFactory(T* factory, bool pushToFrontFlag=false)
       {
          if(!factory) return;
-         OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_factoryListMutex);
+         std::lock_guard<std::mutex> lock(m_factoryListMutex);
          if(!findFactory(factory))
          {
             if (pushToFrontFlag)
@@ -76,7 +84,7 @@ class ossimFactoryListInterface
        */
       void unregisterFactory(T* factory)
       {
-         OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_factoryListMutex);
+         std::lock_guard<std::mutex> lock(m_factoryListMutex);
          ossim_uint32 idx = 0;
          for(idx = 0; idx < m_factoryList.size(); ++idx)
          {
@@ -89,11 +97,33 @@ class ossimFactoryListInterface
       }
       
       /**
+       * Will remove the factory from the registry by name.
+       * @param factoryTypeName  The class name of the factory, (e.g. "ossimCsmProjectionFactory")
+       */
+      void unregisterFactory(const ossimString& factoryTypeName)
+      {
+         std::lock_guard<std::mutex> lock(m_factoryListMutex);
+         ossim_uint32 idx = 0;
+         for(idx = 0; idx < m_factoryList.size(); ++idx)
+         {
+            if (m_factoryList[idx])
+            {
+               ossimString mangledName (typeid(*(m_factoryList[idx])).name());
+               if (mangledName.contains(factoryTypeName))
+               {
+                  m_factoryList.erase(m_factoryList.begin() + idx);
+                  return;
+               }
+            }
+         }
+      }
+
+      /**
        * Will remove all factories from the registry.
        */
       void unregisterAllFactories()
       {
-         OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_factoryListMutex);
+         std::lock_guard<std::mutex> lock(m_factoryListMutex);
          m_factoryList.clear();
       }
       
@@ -102,7 +132,7 @@ class ossimFactoryListInterface
        */
       void registerFactoryToFront(T* factory)
       {
-         OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_factoryListMutex);
+         std::lock_guard<std::mutex> lock(m_factoryListMutex);
          if(!findFactory(factory))
          {
             m_factoryList.insert(m_factoryList.begin(), factory);
@@ -115,7 +145,7 @@ class ossimFactoryListInterface
        */
       void registerFactoryBefore(T* factory, T* beforeThisFactory)
       {
-         OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_factoryListMutex);
+         std::lock_guard<std::mutex> lock(m_factoryListMutex);
          if(!findFactory(factory))
          {
             ossim_uint32 idx = 0;
@@ -186,14 +216,14 @@ class ossimFactoryListInterface
          
          return false;
       }
-      mutable OpenThreads::Mutex m_factoryListMutex;
+      mutable std::mutex m_factoryListMutex;
       FactoryListType m_factoryList;
    };
 
 template <class T, class NativeType>
 void ossimFactoryListInterface<T, NativeType>::getAllTypeNamesFromRegistry(std::vector<ossimString>& typeList)const
 {
-   //OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_factoryListMutex);
+   //std::lock_guard<std::mutex> lock(m_factoryListMutex);
    ossim_uint32 idx = 0;
    for(; idx<m_factoryList.size(); ++idx)
    {
@@ -203,7 +233,7 @@ void ossimFactoryListInterface<T, NativeType>::getAllTypeNamesFromRegistry(std::
 template <class T, class NativeType>
 ossimObject* ossimFactoryListInterface<T, NativeType>::createObjectFromRegistry(const ossimString& typeName)const
 {
-   //OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_factoryListMutex);
+   //std::lock_guard<std::mutex> lock(m_factoryListMutex);
    ossimObject* result = 0;
    ossim_uint32 idx = 0;
    for(;((idx<m_factoryList.size())&&!result); ++idx)
@@ -217,7 +247,7 @@ template <class T, class NativeType>
 ossimObject* ossimFactoryListInterface<T, NativeType>::createObjectFromRegistry(const ossimKeywordlist& kwl,
                                                                                 const char* prefix)const
 {
-   // OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_factoryListMutex);
+   // std::lock_guard<std::mutex> lock(m_factoryListMutex);
    ossimObject* result = 0;
    ossim_uint32 idx = 0;
    for(;((idx<m_factoryList.size())&&!result); ++idx)
diff --git a/include/ossim/base/ossimFileProcessorInterface.h b/include/ossim/base/ossimFileProcessorInterface.h
index 1611c4d..a5fc505 100644
--- a/include/ossim/base/ossimFileProcessorInterface.h
+++ b/include/ossim/base/ossimFileProcessorInterface.h
@@ -1,7 +1,7 @@
 //----------------------------------------------------------------------------
 // File: ossimFileProcessorInterface.h
 // 
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/base/ossimGeoTiffDatumLut.h b/include/ossim/base/ossimGeoTiffDatumLut.h
index 5d0ae0d..e14071d 100644
--- a/include/ossim/base/ossimGeoTiffDatumLut.h
+++ b/include/ossim/base/ossimGeoTiffDatumLut.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2001 ImageLinks Inc.
 //
-// License:  LGPL
+// License:  MIT
 //
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/base/ossimGeoidImage.h b/include/ossim/base/ossimGeoidImage.h
index fb4bb4a..230a334 100644
--- a/include/ossim/base/ossimGeoidImage.h
+++ b/include/ossim/base/ossimGeoidImage.h
@@ -1,6 +1,6 @@
 //----------------------------------------------------------------------------
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/base/ossimGrect.h b/include/ossim/base/ossimGrect.h
index 6b445ca..21d2b1b 100644
--- a/include/ossim/base/ossimGrect.h
+++ b/include/ossim/base/ossimGrect.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc. 
 //
-// License:  LGPL
+// License:  MIT
 //
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/base/ossimHistogramSource.h b/include/ossim/base/ossimHistogramSource.h
index f0d400b..43ba5e7 100644
--- a/include/ossim/base/ossimHistogramSource.h
+++ b/include/ossim/base/ossimHistogramSource.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc. 
 //
-// License:  LGPL
+// License:  MIT
 //
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/base/ossimKeywordNames.h b/include/ossim/base/ossimKeywordNames.h
index 6c26ce2..06dce8c 100644
--- a/include/ossim/base/ossimKeywordNames.h
+++ b/include/ossim/base/ossimKeywordNames.h
@@ -83,6 +83,7 @@ public:
    static const char* GEOM_FILE_KW;
    static const char* HEMISPHERE_KW;
    static const char* HORIZONTAL_SIZE_KW;
+   static const char* HAS_LUT_KW;
    static const char* ID_KW;
    static const char* IMAGE_CE90_KW;
    static const char* IMAGE_FILE_KW;
diff --git a/include/ossim/base/ossimKeywordlist.h b/include/ossim/base/ossimKeywordlist.h
index 464b7b7..4ebd618 100644
--- a/include/ossim/base/ossimKeywordlist.h
+++ b/include/ossim/base/ossimKeywordlist.h
@@ -394,6 +394,7 @@ public:
    OSSIMDLLEXPORT friend std::ostream& operator<<(std::ostream& os,
                                                   const ossimKeywordlist& kwl);
    bool operator ==(ossimKeywordlist& kwl)const;
+   bool operator !=(ossimKeywordlist& kwl)const;
 
     /*!
      * Clear all contents out of the ossimKeywordlist.
diff --git a/include/ossim/base/ossimListener.h b/include/ossim/base/ossimListener.h
index 041b284..d0e4698 100644
--- a/include/ossim/base/ossimListener.h
+++ b/include/ossim/base/ossimListener.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc. 
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/base/ossimLookUpTable.h b/include/ossim/base/ossimLookUpTable.h
index ff36fa0..e21d975 100644
--- a/include/ossim/base/ossimLookUpTable.h
+++ b/include/ossim/base/ossimLookUpTable.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc.
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/base/ossimMetadataInterface.h b/include/ossim/base/ossimMetadataInterface.h
index 3986941..062c74f 100644
--- a/include/ossim/base/ossimMetadataInterface.h
+++ b/include/ossim/base/ossimMetadataInterface.h
@@ -1,7 +1,7 @@
 //----------------------------------------------------------------------------
 // File: ossimFileProcessorInterface.h
 // 
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/base/ossimNBandLutDataObject.h b/include/ossim/base/ossimNBandLutDataObject.h
index be9aa66..0e18be4 100644
--- a/include/ossim/base/ossimNBandLutDataObject.h
+++ b/include/ossim/base/ossimNBandLutDataObject.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2005 Garrett Potts
 //
-// LICENSE: LGPL See top level license file.
+// LICENSE: MIT See top level license file.
 // 
 // Author: Garrett Potts
 //
diff --git a/include/ossim/base/ossimNormRgbVector.h b/include/ossim/base/ossimNormRgbVector.h
index b5f4b25..6e47167 100644
--- a/include/ossim/base/ossimNormRgbVector.h
+++ b/include/ossim/base/ossimNormRgbVector.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2005 Garrett Potts
 //
-// License: LGPL
+// License: MIT
 // Author: Garrett Potts 
 // Description:
 //
diff --git a/include/ossim/base/ossimPointHash.h b/include/ossim/base/ossimPointHash.h
index 9ac9859..f5a470e 100644
--- a/include/ossim/base/ossimPointHash.h
+++ b/include/ossim/base/ossimPointHash.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc.
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/base/ossimPolygon.h b/include/ossim/base/ossimPolygon.h
index 7ac6246..2dc885c 100644
--- a/include/ossim/base/ossimPolygon.h
+++ b/include/ossim/base/ossimPolygon.h
@@ -3,7 +3,7 @@
 //
 // Copyright (C) 2001 ImageLinks, Inc.
 //
-// License:  LGPL
+// License:  MIT
 //
 // See LICENSE.txt file in the top level directory for more details.
 //
@@ -140,6 +140,12 @@ public:
    bool isRectWithin(const ossimIrect &rect) const;
 
    /**
+   * METHOD: rectIntersects()
+   * Returns true if at least one corner points of the given rect is within.
+   */
+   bool rectIntersects(const ossimIrect &rect) const;
+
+   /**
    * METHOD: isPolyWithin()
    * Returns true if all the vertices of the given polygon fit within.
    */
diff --git a/include/ossim/base/ossimProcessListener.h b/include/ossim/base/ossimProcessListener.h
index c32504c..9f66bfe 100644
--- a/include/ossim/base/ossimProcessListener.h
+++ b/include/ossim/base/ossimProcessListener.h
@@ -1,7 +1,7 @@
 //----------------------------------------------------------------------------
 // Copyright (C) 2000 ImageLinks Inc. 
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/base/ossimProcessProgressEvent.h b/include/ossim/base/ossimProcessProgressEvent.h
index 4483f27..1b0ade2 100644
--- a/include/ossim/base/ossimProcessProgressEvent.h
+++ b/include/ossim/base/ossimProcessProgressEvent.h
@@ -1,7 +1,7 @@
 //----------------------------------------------------------------------------
 // Copyright (C) 2000 ImageLinks Inc.
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/base/ossimPropertyInterface.h b/include/ossim/base/ossimPropertyInterface.h
index 97b1234..675ce9e 100644
--- a/include/ossim/base/ossimPropertyInterface.h
+++ b/include/ossim/base/ossimPropertyInterface.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc. 
 //
-// LICENSE: LGPL see top level license.txt
+// LICENSE: MIT see top level license.txt
 //
 // Author: Garrett Potts (gpotts at imagelinks)
 //
diff --git a/include/ossim/base/ossimRectanglePartitioner.h b/include/ossim/base/ossimRectanglePartitioner.h
index 321befc..1c1b02f 100644
--- a/include/ossim/base/ossimRectanglePartitioner.h
+++ b/include/ossim/base/ossimRectanglePartitioner.h
@@ -1,7 +1,7 @@
 //----------------------------------------------------------------------------
 // Copyright (C) 2004 David Burken, all rights reserved.
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/base/ossimRectilinearDataObject.h b/include/ossim/base/ossimRectilinearDataObject.h
index ad4ff66..7c6c032 100644
--- a/include/ossim/base/ossimRectilinearDataObject.h
+++ b/include/ossim/base/ossimRectilinearDataObject.h
@@ -1,6 +1,6 @@
 //*******************************************************************
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/base/ossimRefPtr.h b/include/ossim/base/ossimRefPtr.h
index e7765d4..fef5824 100644
--- a/include/ossim/base/ossimRefPtr.h
+++ b/include/ossim/base/ossimRefPtr.h
@@ -1,12 +1,13 @@
 /* -*-c++-*- ossim - Copyright (C) since 2004 Garrett Potts 
  *
  * This was taken directly from OpenSceneGraph and will retain OSGGPL license.
- * This is basically an LGPL.
+ * This is basically an MIT.
  * 
 */
 #ifndef ossimRefPtr_HEADER
 #define ossimRefPtr_HEADER
 #include <ossim/base/ossimConstants.h>
+#include <stddef.h>
 
 template<class T> class ossimRefPtr
 {
@@ -51,8 +52,6 @@ template<class T> class ossimRefPtr
       }
    
    // comparison operators for ossimRefPtr.
-   inline bool operator == (const ossimRefPtr& rp) const { return (m_ptr==rp.m_ptr); }
-   inline bool operator != (const ossimRefPtr& rp) const { return (m_ptr!=rp.m_ptr); }
    inline bool operator < (const ossimRefPtr& rp) const { return (m_ptr<rp.m_ptr); }
    inline bool operator > (const ossimRefPtr& rp) const { return (m_ptr>rp.m_ptr); }
    
@@ -78,7 +77,7 @@ template<class T> class ossimRefPtr
     * Used in boolean expression. Example: "if (obj)" is same as "if (obj.valid())". This is
     * the same syntax as c++11 shared_ptr.
     */
-   inline operator bool() const { return m_ptr!=0L; }
+   explicit operator bool() const { return m_ptr == 0 ? false : true; }
 
    inline T* get() { return m_ptr; }
    
@@ -96,4 +95,26 @@ template<class T> class ossimRefPtr
    T* m_ptr;
 };
 
+// Copied from std::shared_ptr:
+template<typename _Tp1, typename _Tp2> inline bool
+  operator==(const ossimRefPtr<_Tp1>& __a, const ossimRefPtr<_Tp2>& __b) noexcept
+  { return __a.get() == __b.get(); }
+
+template<typename _Tp> inline bool operator==(const ossimRefPtr<_Tp>& __a, nullptr_t) noexcept
+  { return !__a; }
+
+template<typename _Tp> inline bool operator==(nullptr_t, const ossimRefPtr<_Tp>& __a) noexcept
+  { return !__a; }
+
+template<typename _Tp1, typename _Tp2>  inline bool
+  operator!=(const ossimRefPtr<_Tp1>& __a, const ossimRefPtr<_Tp2>& __b) noexcept
+  { return __a.get() != __b.get(); }
+
+template<typename _Tp> inline bool operator!=(const ossimRefPtr<_Tp>& __a, nullptr_t) noexcept
+  { return (bool)__a; }
+
+template<typename _Tp> inline bool operator!=(nullptr_t, const ossimRefPtr<_Tp>& __a) noexcept
+  { return (bool)__a; }
+
+
 #endif
diff --git a/include/ossim/base/ossimReferenced.h b/include/ossim/base/ossimReferenced.h
index db20a80..dc1f836 100644
--- a/include/ossim/base/ossimReferenced.h
+++ b/include/ossim/base/ossimReferenced.h
@@ -1,107 +1,98 @@
 /* -*-c++-*- libossim - Copyright (C) since 2004 Garrett Potts 
- * LICENSE: LGPL
+ * LICENSE: MIT
  * Author: Garrett Potts
 */
 #ifndef ossimReferenced_HEADER
 #define ossimReferenced_HEADER
 #include <ossim/base/ossimConstants.h>
-#include <OpenThreads/ScopedLock>
-#include <OpenThreads/Mutex>
 
+#include <atomic>
+#include <mutex>
+
+/**
+* ossimReferenced allows for shared object ref counting
+* if the reference count ever gets to 0 or less it will
+* delete 'this' object.
+*
+* Currently uses std::mutex to control the locking of the reference
+* count variable.
+*
+* Eventually we would like to replace all of ossimReferenced and ossimRefPtr
+* with C++11 std::shared_ptr
+*/
 class OSSIMDLLEXPORT ossimReferenced
 {
  public:
    ossimReferenced()
-   : theRefMutex(new OpenThreads::Mutex),
-     theRefCount(0)
+   : m_refCount(0)
       {}
    
    ossimReferenced(const ossimReferenced&)
-   : theRefMutex(new OpenThreads::Mutex),
-   theRefCount(0)
+   : m_refCount(0)
    {}
    inline ossimReferenced& operator = (const ossimReferenced&) { return *this; }
    
 
-   /*! increment the reference count by one, indicating that 
-       this object has another pointer which is referencing it.*/
+   /** 
+    * increment the reference count by one, indicating that 
+    * this object has another pointer which is referencing it.
+    */
    inline void ref() const;
    
-   /*! decrement the reference count by one, indicating that 
-       a pointer to this object is referencing it.  If the
-       reference count goes to zero, it is assumed that this object
-       is no longer referenced and is automatically deleted.*/
+   /**
+    * decrement the reference count by one, indicating that 
+    * a pointer to this object is referencing it.  If the
+    * reference count goes to zero, it is assumed that this object
+    * is no longer referenced and is automatically deleted.
+    */
    inline void unref() const;
    
-   /*! decrement the reference count by one, indicating that 
-       a pointer to this object is referencing it.  However, do
-       not delete it, even if ref count goes to 0.  Warning, unref_nodelete() 
-       should only be called if the user knows exactly who will
-       be resonsible for, one should prefer unref() over unref_nodelete() 
-       as the later can lead to memory leaks.*/
+   /**
+    * decrement the reference count by one, indicating that 
+    * a pointer to this object is referencing it.  However, do
+    * not delete it, even if ref count goes to 0.  Warning, unref_nodelete() 
+    * should only be called if the user knows exactly who will
+    * be resonsible for, one should prefer unref() over unref_nodelete() 
+    * as the later can lead to memory leaks.
+    */
    inline void unref_nodelete() const 
    { 
-      if (theRefMutex)
-      {
-         OpenThreads::ScopedLock<OpenThreads::Mutex> lock(*theRefMutex); 
-         --theRefCount;
-      }
-      else
-      {
-         --theRefCount;
-      }
+     // std::lock_guard<std::mutex> lock(theRefMutex); 
+     --m_refCount;
    }
    
-   /*! return the number pointers currently referencing this object. */
-   inline int referenceCount() const { return theRefCount; }
+   /**
+    * @return the number pointers currently referencing this object. 
+    */
+   inline int referenceCount() const { return m_refCount.load(); }
    
    
  protected:
    virtual ~ossimReferenced();
-   mutable OpenThreads::Mutex*     theRefMutex;
-   mutable int theRefCount;
+
+ private:
+    mutable std::atomic_int      m_refCount;
 };
 
 inline void ossimReferenced::ref() const
 {
-   if (theRefMutex)
-   {
-      OpenThreads::ScopedLock<OpenThreads::Mutex> lock(*theRefMutex); 
-      ++theRefCount;
-   }
-   else
-   {
-      ++theRefCount;
-   }
+  ++m_refCount;
 }
 
 inline void ossimReferenced::unref() const
 {
-   bool needDelete = false;
-   if (theRefMutex)
-   {
-      OpenThreads::ScopedLock<OpenThreads::Mutex> lock(*theRefMutex); 
-      --theRefCount;
-      needDelete = theRefCount<=0;
-   }
-   else
-   {
-      --theRefCount;
-      needDelete = theRefCount<=0;
-   }
-   
-   if (needDelete)
-   {
-      delete this;
-   }
-   
-#if 0
-    --theRefCount;
-    if (theRefCount==0)
-    {
-        delete this;
-    }
-#endif
+  bool needDelete = false;
+  {
+    // fetch_sub should return the value before subtraction.
+    // so if 1 was before the subtraction that means it should
+    // be zero after the subtraction so we will test <=1
+    needDelete = m_refCount.fetch_sub(1) <= 1;
+  }
+
+  if (needDelete)
+  {
+    delete this;
+  }
 }
 
 #endif
diff --git a/include/ossim/base/ossimStdOutProgress.h b/include/ossim/base/ossimStdOutProgress.h
index 950350c..4c51737 100644
--- a/include/ossim/base/ossimStdOutProgress.h
+++ b/include/ossim/base/ossimStdOutProgress.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc. 
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/base/ossimStreamFactoryRegistry.h b/include/ossim/base/ossimStreamFactoryRegistry.h
index bd61026..ef4d772 100644
--- a/include/ossim/base/ossimStreamFactoryRegistry.h
+++ b/include/ossim/base/ossimStreamFactoryRegistry.h
@@ -20,7 +20,8 @@
 
 #include <memory>
 #include <vector>
-
+#include <mutex>
+#include <atomic>
 namespace ossim
 {
   /**
@@ -171,6 +172,12 @@ namespace ossim
       virtual bool exists(const std::string& connectionString,
                           bool& continueFlag) const;
    
+      /**
+      * This will load the buffer information from the 
+      * preferences.
+      */
+      void loadPreferences();
+
    protected:
       StreamFactoryRegistry();
       
@@ -197,12 +204,6 @@ namespace ossim
       StreamFactoryRegistry(const StreamFactoryRegistry&);
 
       /**
-      * This will load the buffer information from the 
-      * preferences.
-      */
-      void loadPreferences();
-
-      /**
       * @param bufferInfo Holds the result of the first buffer info 
       *        matching the connection string
       * @param connecitonString The connection string
@@ -214,6 +215,7 @@ namespace ossim
       std::vector<BufferInfo>  m_bufferInfoList;
       static StreamFactoryRegistry*   m_instance;
       mutable ossimRegExp m_patternMatcher;
+      mutable std::mutex m_mutex;
    };
    
 } // End: namespace ossim
diff --git a/include/ossim/base/ossimString.h b/include/ossim/base/ossimString.h
index e29fbbc..095502f 100644
--- a/include/ossim/base/ossimString.h
+++ b/include/ossim/base/ossimString.h
@@ -1,6 +1,6 @@
 //*******************************************************************
 //
-// License:  LGPL
+// License:  MIT
 //
 // See LICENSE.txt file in the top level directory for more details.
 //
@@ -94,6 +94,8 @@ public:
    /** @brief Reads a single line from the input stream is. */
    friend OSSIM_DLL std::istream& getline( std::istream& is, ossimString& str );
 
+   explicit operator bool() const { return m_str.empty() ? false : true; }
+
    const ossimString& operator=(const std::string& s)
    {
       m_str = s;
@@ -229,7 +231,7 @@ public:
     */
    bool operator==(const ossimString& rhs) const
    {
-      return (m_str.compare( rhs.m_str ) == 0);
+      return (m_str == rhs.m_str);
    }
 
    /**
@@ -274,6 +276,23 @@ public:
       return result;
    }
 
+   bool operator<(const ossimString& rhs) const
+   {
+      return m_str < rhs.m_str;
+   }
+   bool operator<=(const ossimString& rhs) const
+   {
+      return m_str <= rhs.m_str;
+   }
+   bool operator>(const ossimString& rhs) const
+   {
+      return m_str > rhs.m_str;
+   }
+   bool operator>=(const ossimString& rhs) const
+   {
+      return m_str >= rhs.m_str;
+   }
+
    char& operator[](std::string::size_type i)
    {
       return m_str[i];
diff --git a/include/ossim/base/ossimStringProperty.h b/include/ossim/base/ossimStringProperty.h
index cb3cd61..ba4ff5f 100644
--- a/include/ossim/base/ossimStringProperty.h
+++ b/include/ossim/base/ossimStringProperty.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc. 
 //
-// LICENSE: LGPL see top level license.txt
+// LICENSE: MIT see top level license.txt
 //
 // Author: Garrett Potts (gpotts at imagelinks.com)
 //
diff --git a/include/ossim/base/ossimTempFilename.h b/include/ossim/base/ossimTempFilename.h
index 270281b..bcf07cd 100644
--- a/include/ossim/base/ossimTempFilename.h
+++ b/include/ossim/base/ossimTempFilename.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc. 
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/base/ossimTerm.h b/include/ossim/base/ossimTerm.h
index 2c3bf04..dc93cd8 100644
--- a/include/ossim/base/ossimTerm.h
+++ b/include/ossim/base/ossimTerm.h
@@ -6,8 +6,8 @@
  * 
  *        See top level LICENSE.txt file.
  */
-#ifndef OSSIM_FUNCTION_H
-#define OSSIM_FUNCTION_H
+#ifndef OSSIM_TERM_H
+#define OSSIM_TERM_H 1
 
 #include <ossim/base/ossimConstants.h>
 
@@ -32,74 +32,75 @@ enum termType : ossim_uint32 {
 /**
  * An abstract class to containing a multivariable function.
  */
-class OSSIMDLLEXPORT ossimTerm{
+class OSSIMDLLEXPORT ossimTerm
+{
 public:
 
 
-	/**
-	 * @brief      Virtual destructor for destroying tree from the top node.
-	 */
-	virtual ~ossimTerm() {}
-
-
-	/**
-	 * @brief      Evaluates a term at a given point PURE VIRTUAL
-	 *
-	 * @param[in]  point  The point to be evaluated
-	 *
-	 * @return     the value at a point
-	 */
-	virtual ossim_float64	evaluate(std::vector<ossim_float64> point) const = 0;
-	/**
-	 * @brief      Calculates the derivative of the term
-	 *
-	 * @param[in]  variable  The variable in which the derivative is with respect too
-	 *
-	 * @return     A pointer containing the derivative of the term.
-	 */
-	virtual ossimTerm*		derivative(const ossim_uint32& variable) const = 0;
-
-
-	/**
-	 * @brief      Gets the type
-	 *
-	 * @return     The type
-	 */
-	virtual ossim_uint32	getType() const = 0;
-	/**
-	 * @brief      Returns a pointer to a copy of the term
-	 *
-	 * @return     A pointer to a copy of the term
-	 */
-	virtual ossimTerm*		copy() const = 0;
-
-
-	/**
-	 * @brief      Evaluates the function for a point
-	 *
-	 * @param      point   The point at which the function is being evaluated
-	 *
-	 * @return     The value at a point
-	 */
-	inline ossim_float64	operator()(std::vector<ossim_float64> point) const{ return this->evaluate(point); }
-
-
-	/**
-	 * @brief      Returns a copy of the two terms in a polynomial
-	 *
-	 * @param      rhs   The right hand term of the polynomial
-	 *
-	 * @return     A polynomial with !COPIES! of the two terms
-	 */
-	inline ossimTerm*	operator+(ossimTerm* rhs) const;
-	/**
-	 * @brief      Returns a copy of the two terms in a product
-	 *
-	 * @param      rhs   The right hand term of the product
-	 *
-	 * @return     A product with !COPIES! of the two terms
-	 */
-	inline ossimTerm*	operator*(ossimTerm* rhs) const;
+   /**
+    * @brief      Virtual destructor for destroying tree from the top node.
+    */
+   virtual ~ossimTerm() {}
+
+
+   /**
+    * @brief      Evaluates a term at a given point PURE VIRTUAL
+    *
+    * @param[in]  point  The point to be evaluated
+    *
+    * @return     the value at a point
+    */
+   virtual ossim_float64	evaluate(std::vector<ossim_float64> /* point */ ) const = 0;
+   /**
+    * @brief      Calculates the derivative of the term
+    *
+    * @param[in]  variable  The variable in which the derivative is with respect too
+    *
+    * @return     A pointer containing the derivative of the term.
+    */
+   virtual ossimTerm*		derivative(const ossim_uint32& variable) const = 0;
+
+
+   /**
+    * @brief      Gets the type
+    *
+    * @return     The type
+    */
+   virtual ossim_uint32	getType() const = 0;
+   /**
+    * @brief      Returns a pointer to a copy of the term
+    *
+    * @return     A pointer to a copy of the term
+    */
+   virtual ossimTerm*		copy() const = 0;
+
+
+   /**
+    * @brief      Evaluates the function for a point
+    *
+    * @param      point   The point at which the function is being evaluated
+    *
+    * @return     The value at a point
+    */
+   inline ossim_float64	operator()(std::vector<ossim_float64> point) const{ return this->evaluate(point); }
+
+
+   /**
+    * @brief      Returns a copy of the two terms in a polynomial
+    *
+    * @param      rhs   The right hand term of the polynomial
+    *
+    * @return     A polynomial with !COPIES! of the two terms
+    */
+   inline ossimTerm*	operator+(ossimTerm* rhs) const;
+   /**
+    * @brief      Returns a copy of the two terms in a product
+    *
+    * @param      rhs   The right hand term of the product
+    *
+    * @return     A product with !COPIES! of the two terms
+    */
+   inline ossimTerm*	operator*(ossimTerm* rhs) const;
 
 };
 
@@ -368,64 +369,63 @@ private:
 /**
  * A constant class to hold a constant as a term.
  */
-class OSSIMDLLEXPORT ossimConst : public ossimTerm{
+class OSSIMDLLEXPORT ossimConst : public ossimTerm
+{
 public:
 
 
-	/**
-	 * @brief      Public Constructor
-	 *
-	 * @param[in]  value  The value of the constant
-	 */
-	ossimConst(const ossim_float64& value) : val(value) {}
-	/**
-	 * @brief      Public Copy Constructor
-	 *
-	 * @param[in]  src   The source to be copied
-	 */
-	ossimConst(const ossimConst& src) : val(src.val) {}
-	/**
-	 * @brief      Destroys the constant
-	 */
-	~ossimConst() {}
-
-
-	/**
-	 * @brief      Evaluates a constant for a point
-	 *
-	 * @param[in]  point  The point to be evaluated
-	 *
-	 * @return     The value at a point.
-	 */
-	ossim_float64	evaluate(std::vector<ossim_float64> point) const{ return val; }
-	/**
-	 * @brief      Calculates the derivative for a constant
-	 *
-	 * @param[in]  variable  The variable in which the derivative is with respect too.
-	 *
-	 * @return     A pointer to that contains the derivative of the term.
-	 */
-	ossimTerm*		derivative(const ossim_uint32& variable) const;
-
-
-	/**
-	 * @brief      Gets the type of a constant
-	 *
-	 * @return     The type of a constant
-	 */
-	ossim_uint32	getType() const { return termType::constant; }
-	/**
-	 * @brief      Creates a copy of the constant
-	 *
-	 * @return     A pointer to a copy of the constant
-	 */
-	ossimTerm*		copy() const;
+   /**
+    * @brief      Public Constructor
+    *
+    * @param[in]  value  The value of the constant
+    */
+ossimConst(const ossim_float64& value) : val(value) {}
+   /**
+    * @brief      Public Copy Constructor
+    *
+    * @param[in]  src   The source to be copied
+    */
+ossimConst(const ossimConst& src) : val(src.val) {}
+   /**
+    * @brief      Destroys the constant
+    */
+   ~ossimConst() {}
+
+
+   /**
+    * @brief      Evaluates a constant for a point
+    *
+    * @param[in]  point  The point to be evaluated
+    *
+    * @return     The value at a point.
+    */
+   ossim_float64	evaluate(std::vector<ossim_float64> /* point */ ) const{ return val; }
+   /**
+    * @brief      Calculates the derivative for a constant
+    *
+    * @param[in]  variable  The variable in which the derivative is with respect too.
+    *
+    * @return     A pointer to that contains the derivative of the term.
+    */
+   ossimTerm*		derivative(const ossim_uint32& variable) const;
+
+
+   /**
+    * @brief      Gets the type of a constant
+    *
+    * @return     The type of a constant
+    */
+   ossim_uint32	getType() const { return termType::constant; }
+   /**
+    * @brief      Creates a copy of the constant
+    *
+    * @return     A pointer to a copy of the constant
+    */
+   ossimTerm*		copy() const;
 
 private:
-	ossim_float64 val;	// The value of the constant
+   ossim_float64 val;	// The value of the constant
 
 };
 
-
-
-#endif // OSSIM_FUNCTION_H
\ No newline at end of file
+#endif // OSSIM_TERM_H
diff --git a/include/ossim/base/ossimTieMeasurementGeneratorInterface.h b/include/ossim/base/ossimTieMeasurementGeneratorInterface.h
index a1f28e8..cef945b 100644
--- a/include/ossim/base/ossimTieMeasurementGeneratorInterface.h
+++ b/include/ossim/base/ossimTieMeasurementGeneratorInterface.h
@@ -2,7 +2,7 @@
 //
 // File: ossimTieMeasurementGeneratorInterface.h
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/base/ossimTileHash.h b/include/ossim/base/ossimTileHash.h
index faf0b36..d1fc0a2 100644
--- a/include/ossim/base/ossimTileHash.h
+++ b/include/ossim/base/ossimTileHash.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc.
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/base/ossimTiledImageHash.h b/include/ossim/base/ossimTiledImageHash.h
index 6531c45..26c8451 100644
--- a/include/ossim/base/ossimTiledImageHash.h
+++ b/include/ossim/base/ossimTiledImageHash.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc.
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/base/ossimTraceManager.h b/include/ossim/base/ossimTraceManager.h
index d01829f..e10b870 100644
--- a/include/ossim/base/ossimTraceManager.h
+++ b/include/ossim/base/ossimTraceManager.h
@@ -1,7 +1,7 @@
 //*****************************************************************************
 // Copyright (C) 2005 Garrett Potts, all rights reserved.
 //
-// License:  LGPL
+// License:  MIT
 //
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/base/ossimUnitConversionTool.h b/include/ossim/base/ossimUnitConversionTool.h
index 274e7e4..524f103 100644
--- a/include/ossim/base/ossimUnitConversionTool.h
+++ b/include/ossim/base/ossimUnitConversionTool.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc. 
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/base/ossimVrect.h b/include/ossim/base/ossimVrect.h
index 3948e41..8e24ddd 100644
--- a/include/ossim/base/ossimVrect.h
+++ b/include/ossim/base/ossimVrect.h
@@ -2,7 +2,7 @@
 //
 // Copyright (C) 2000 ImageLinks Inc.
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/elevation/ossimDtedElevationDatabase.h b/include/ossim/elevation/ossimDtedElevationDatabase.h
index 1697485..a48e3c6 100644
--- a/include/ossim/elevation/ossimDtedElevationDatabase.h
+++ b/include/ossim/elevation/ossimDtedElevationDatabase.h
@@ -4,8 +4,21 @@
 #include <ossim/elevation/ossimElevationCellDatabase.h>
 #include <ossim/base/ossimFilename.h>
 #include <ossim/elevation/ossimDtedHandler.h>
-#include <OpenThreads/Mutex>
+#include <mutex>
 
+/**
+* The DTED elevation data base is also an elevation source but allows
+* one to point to an file based elevation tree.  The general format of
+* a DTED elevation tree:
+* 
+* <root dir>/e|w<longitude value>/n|s<latitiude value>.<extension>
+* Exmaple 1 kilometer:
+* <root dir>/w023/n15.dt0
+*
+* Note for 1 kilimeter the extension is dt0 and for 90 meter post spacing
+* it is .dt1 and for 30 meter spacing it is .dt2
+*
+*/  
 class OSSIM_DLL ossimDtedElevationDatabase : public ossimElevationCellDatabase
 {
 public:
@@ -79,7 +92,7 @@ protected:
    bool m_upcase;
 
    ossimRefPtr<ossimElevCellHandler> m_lastHandler;
-   mutable OpenThreads::Mutex m_mutex;
+   mutable std::mutex m_mutex;
     
 
 TYPE_DATA
diff --git a/include/ossim/elevation/ossimDtedFactory.h b/include/ossim/elevation/ossimDtedFactory.h
index 62e47c9..93e5994 100644
--- a/include/ossim/elevation/ossimDtedFactory.h
+++ b/include/ossim/elevation/ossimDtedFactory.h
@@ -1,7 +1,7 @@
 //*****************************************************************************
 // FILE: ossimDtedFactory.cc
 //
-// License:  LGPL
+// License:  MIT
 //
 // See LICENSE.txt file in the top level directory for more details.
 // 
diff --git a/include/ossim/elevation/ossimDtedHandler.h b/include/ossim/elevation/ossimDtedHandler.h
index 5a10142..f3ded9b 100644
--- a/include/ossim/elevation/ossimDtedHandler.h
+++ b/include/ossim/elevation/ossimDtedHandler.h
@@ -26,7 +26,6 @@
 #include <ossim/base/ossimConstants.h>
 #include <ossim/base/ossimString.h>
 #include <ossim/elevation/ossimElevCellHandler.h>
-#include <OpenThreads/Mutex>
 #include <ossim/support_data/ossimDtedVol.h>
 #include <ossim/support_data/ossimDtedHdr.h>
 #include <ossim/support_data/ossimDtedUhl.h>
@@ -34,20 +33,52 @@
 #include <ossim/support_data/ossimDtedAcc.h>
 #include <ossim/support_data/ossimDtedRecord.h>
 
+#include <mutex>
+/**
+* the DTED handler is an elevation source that allows for handling of a
+* single cell of data.  DTED is typically a 1x1 degree cell.
+*
+* This can open from an ossim::istream or from a filename.  It allows
+* one to query the cell by overriding the getHeightAboveMSL.
+*
+* For reference @see ossimGpt
+* Example:
+* @code
+* ossimRefPtr<ossimDtedHandler> h = new ossimDtedHandler();
+* if(h->open(someFile))
+* {
+*    h->getHeightAboveMSL(ossimGpt(28, -110));  
+* }
+* @endcode
+* 
+* When a height is calculated it will use a weighted average of 4 neighboring
+* posts.
+*/
 class OSSIM_DLL ossimDtedHandler : public ossimElevCellHandler
 {
 public:
 
-   /// number of Dted posts per point.
+   // number of Dted posts per point.
    static const int TOTAL_POSTS = 4;
-   /// number of Dted posts per block
+   // number of Dted posts per block
    static const int NUM_POSTS_PER_BLOCK= 2;
 
-   /// ossimDtedHandler
+   /**
+   * Constructor
+   */
    ossimDtedHandler()
    {
    }
 
+   /**
+   * Constructor
+   *
+   * @param dted_file is a file path to the dted cell we wish to
+   *        open
+   * @param memoryMapFlag If this is set we will pull the entire cell
+   *        into memory and treat that memory location as an 
+   *        inputstream.
+   */
    ossimDtedHandler(const ossimFilename& dted_file, bool memoryMapFlag=false);
 
    enum
@@ -58,15 +89,37 @@ public:
       NULL_POST                  = -32767 // Fixed by DTED specification.
    };
 
+   /**
+   * opens a cell
+   *
+   * @param file is a file path to the dted cell we wish to
+   *        open
+   * @param memoryMapFlag If this is set we will pull the entire cell
+   *        into memory and treat that memory location as an 
+   *        inputstream.
+   */
    virtual bool open(const ossimFilename& file, bool memoryMapFlag=false);
+
+   /**
+   * opens a cell given a stream
+   *
+   * @param fileStr is a stream that was opened and has access
+   *        to a cell.
+   * @param connectionString is the connection string used to open the
+   *        input stream.
+   * @param memoryMapFlag If this is set we will pull the entire cell
+   *        into memory and treat that memory location as an 
+   *        inputstream.
+   */
    virtual bool open(std::shared_ptr<ossim::istream>& fileStr, const std::string& connectionString, bool memoryMapFlag=false);
    virtual void close();
    
-   /*!
-    * METHOD: getHeightAboveMSL
-    * Height access methods.
+   /**
+    * @param gpt is a ground point <lat, lon> that is used to 
+    *        lookup the elevation pos value.
+    * @return height above Mean Sea Level (MSL). 
     */
-   virtual double getHeightAboveMSL(const ossimGpt&);
+   virtual double getHeightAboveMSL(const ossimGpt& gpt);
 
    /*!
     *  METHOD:  getSizeOfElevCell
@@ -180,7 +233,7 @@ protected:
    */
    void readPostsFromFile(DtedHeight &postData, int offset);
 
-   mutable OpenThreads::Mutex m_fileStrMutex;
+   mutable std::mutex m_fileStrMutex;
   // mutable std::ifstream m_fileStr;
    mutable std::shared_ptr<ossim::istream> m_fileStr;
    mutable std::string m_connectionString;
@@ -199,7 +252,7 @@ protected:
    // Indicates whether byte swapping is needed.
    bool m_swapBytesFlag;
 
-   mutable OpenThreads::Mutex m_memoryMapMutex;
+   mutable std::mutex m_memoryMapMutex;
    mutable std::vector<ossim_uint8> m_memoryMap;
    
    std::shared_ptr<ossimDtedVol> m_vol;
@@ -232,8 +285,7 @@ inline bool ossimDtedHandler::isOpen()const
 {
 
   if(!m_memoryMap.empty()) return true;
-  OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_fileStrMutex);
-
+  std::lock_guard<std::mutex> lock(m_fileStrMutex);
 
   return (m_fileStr != 0);
 }
diff --git a/include/ossim/elevation/ossimElevManager.h b/include/ossim/elevation/ossimElevManager.h
index add6721..8007705 100644
--- a/include/ossim/elevation/ossimElevManager.h
+++ b/include/ossim/elevation/ossimElevManager.h
@@ -25,7 +25,7 @@
 #include <ossim/base/ossimVisitor.h>
 #include <ossim/elevation/ossimElevSource.h>
 #include <ossim/elevation/ossimElevationDatabase.h>
-#include <OpenThreads/ReadWriteMutex>
+#include <mutex>
 
 class OSSIM_DLL ossimElevManager : public ossimElevSource
 {
@@ -190,7 +190,7 @@ protected:
     * and it seems to be much more stable across all platforms.  More testing needs to occur for the ReadWriteMutex.
     * For now we will use Mutex.
     */
-   mutable OpenThreads::Mutex m_mutex;
+   mutable std::mutex m_mutex;
 };
 
 #endif
diff --git a/include/ossim/elevation/ossimElevSourceFactory.h b/include/ossim/elevation/ossimElevSourceFactory.h
index 28c87ec..bd6b9d9 100644
--- a/include/ossim/elevation/ossimElevSourceFactory.h
+++ b/include/ossim/elevation/ossimElevSourceFactory.h
@@ -3,7 +3,7 @@
 //
 // Copyright (C) 2002 ImageLinks, Inc.
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/elevation/ossimElevationCellDatabase.h b/include/ossim/elevation/ossimElevationCellDatabase.h
index 799ae1a..ab92606 100644
--- a/include/ossim/elevation/ossimElevationCellDatabase.h
+++ b/include/ossim/elevation/ossimElevationCellDatabase.h
@@ -1,6 +1,7 @@
 #ifndef ossimElevationCellDatabase_HEADER
 #define ossimElevationCellDatabase_HEADER 1
 #include <ossim/elevation/ossimElevationDatabase.h>
+#include <mutex>
 
 class OSSIM_DLL ossimElevationCellDatabase : public ossimElevationDatabase
 {
@@ -160,7 +161,7 @@ protected:
    
    ossim_uint32               m_minOpenCells;
    ossim_uint32               m_maxOpenCells;
-   mutable OpenThreads::Mutex m_cacheMapMutex;
+   mutable std::mutex         m_cacheMapMutex;
    CellMap                    m_cacheMap;
    ossim_uint32               m_memoryMapCellsFlag;
    
diff --git a/include/ossim/elevation/ossimElevationDatabaseFactory.h b/include/ossim/elevation/ossimElevationDatabaseFactory.h
index e7bda54..a270ce6 100644
--- a/include/ossim/elevation/ossimElevationDatabaseFactory.h
+++ b/include/ossim/elevation/ossimElevationDatabaseFactory.h
@@ -2,6 +2,58 @@
 #define ossimElevationDatabaseFactory_HEADER
 #include "ossimElevationDatabaseFactoryBase.h"
 
+/**
+* This is our default elevation factory in the ossim core.  It supports
+* general_raster, general imagery, DTED and SRTM directory layouts.
+*
+* Example DTED Keywordlist:
+* @code
+* elevation_manager.elevation_source1.type: dted_directory
+* elevation_manager.elevation_source1.connection_string: /data/elevation/dted/level0
+* elevation_manager.elevation_source1.min_open_cells: 5
+* elevation_manager.elevation_source1.max_open_cells: 25
+* elevation_manager.elevation_source1.enabled: true
+* elevation_manager.elevation_source1.memory_map_cells: true
+* @endcode
+* Note:  only use memory_map_cells to true if they are small files.  DTED0 is 
+* small so we set it to true.
+* Where the dted file tree has the form: <rootdir>/w056/n49.dt0
+*
+* Example General Raster directory:
+* @code
+* elevation_manager.elevation_source2.type: general_raster_directory
+* elevation_manager.elevation_source2.connection_string: /data/tutorial/data/elevation/general_raster_pk_90m
+* elevation_manager.elevation_source2.min_open_cells: 25
+* elevation_manager.elevation_source2.max_open_cells: 50 
+* elevation_manager.elevation_source2.enabled: false 
+* elevation_manager.elevation_source2.memory_map_cells: false
+* @endcode
+* where the directory is a flat directory with general raster files
+*
+* Example SRTM directory:
+* @code
+* elevation_manager.elevation_source10.type: srtm_directory
+* elevation_manager.elevation_source10.connection_string: /Volumes/DataDrive/data/elevation/srtm1/
+* elevation_manager.elevation_source10.min_open_cells: 25
+* elevation_manager.elevation_source10.max_open_cells: 50 
+* elevation_manager.elevation_source10.memory_map_cells: false
+* elevation_manager.elevation_source10.enabled: true
+* @endcode
+* where the directory has files of the form N39W112.hgt and are 1x1 degree
+* cells
+*
+* Example image directory format:
+* @code
+* elevation_manager.elevation_source20.type: image_directory
+* elevation_manager.elevation_source20.connection_string: /data/elevation/image
+* elevation_manager.elevation_source20.min_open_cells: 25
+* elevation_manager.elevation_source20.max_open_cells: 50 
+* elevation_manager.elevation_source20.memory_map_cells: false
+* elevation_manager.elevation_source20.enabled: false 
+* @endcode
+* 
+* where the directory can have any image the ossim supports and is a flat directory
+*/
 class OSSIM_DLL ossimElevationDatabaseFactory : public ossimElevationDatabaseFactoryBase
 {
 public:
@@ -9,13 +61,40 @@ public:
    {
       m_instance = this;
    }
+
+   /**
+   * @return a singleton instance of this factory
+   */
    static ossimElevationDatabaseFactory* instance();
    
+   /**
+   * @param typeName is the type name of the database you wish to
+   *        create.
+   * @return the elevation database or null otherwise
+   */
    ossimElevationDatabase* createDatabase(const ossimString& typeName)const;
+
+   /**
+   * @param kwl kewyord list that has state information about how to
+   *        create a database
+   * @param prefix prefix key to use when loading the state information.
+   * @return the elevation database or null otherwise
+   */
    ossimElevationDatabase* createDatabase(const ossimKeywordlist& kwl,
                                           const char* prefix=0)const;
+   /**
+   * @param connectionString used to determine which database can support
+   *        that connection.
+   * @return the elevation database or null otherwise
+   */
    virtual ossimElevationDatabase* open(const ossimString& connectionString)const;
+
+   /**
+   * @param typeList appends to the typeList all the type names this factory
+   * supports
+   */
    virtual void getTypeNameList(std::vector<ossimString>& typeList)const;
+
 protected:
    static ossimElevationDatabaseFactory* m_instance;
 };
diff --git a/include/ossim/elevation/ossimElevationDatabaseRegistry.h b/include/ossim/elevation/ossimElevationDatabaseRegistry.h
index 00f679c..ccd00d4 100644
--- a/include/ossim/elevation/ossimElevationDatabaseRegistry.h
+++ b/include/ossim/elevation/ossimElevationDatabaseRegistry.h
@@ -3,6 +3,14 @@
 #include <ossim/elevation/ossimElevationDatabaseFactoryBase.h>
 #include <ossim/elevation/ossimElevationDatabase.h>
 #include <ossim/base/ossimFactoryListInterface.h>
+
+/**
+*
+* This is the elevation database registry.  
+* @see ossimElevationDatabaseFactory for more details on the factories
+* supported within the ossim core.
+*
+*/
 class OSSIM_DLL ossimElevationDatabaseRegistry : public ossimFactoryListInterface<ossimElevationDatabaseFactoryBase, ossimElevationDatabase>
 
 {
@@ -16,9 +24,27 @@ public:
    {
       getAllTypeNamesFromRegistry(typeList);
    }
+   /**
+   * @param typeName is the type name of the database you wish to
+   *        create
+   * @return the elevation database or null otherwise
+   */
    ossimElevationDatabase* createDatabase(const ossimString& typeName)const;
+   
+   /**
+   * @param kwl kewyord list that has state information about how to
+   *        create a database
+   * @param prefix prefix key to use when loading the state information.
+   * @return the elevation database or null otherwise
+   */
    ossimElevationDatabase* createDatabase(const ossimKeywordlist& kwl,
                                           const char* prefix=0)const;
+
+   /**
+   * @param connectionString used to determine which database can support
+   *        that connection.
+   * @return the elevation database or null otherwise
+   */
    ossimElevationDatabase* open(const ossimString& connectionString);
 
 protected:
diff --git a/include/ossim/elevation/ossimGeneralRasterElevHandler.h b/include/ossim/elevation/ossimGeneralRasterElevHandler.h
index 2424db2..082d392 100644
--- a/include/ossim/elevation/ossimGeneralRasterElevHandler.h
+++ b/include/ossim/elevation/ossimGeneralRasterElevHandler.h
@@ -29,8 +29,7 @@
 #include <ossim/base/ossimKeywordlist.h>
 #include <ossim/base/ossimDpt.h>
 #include <ossim/base/ossimGpt.h>
-#include <OpenThreads/Mutex>
-#include <OpenThreads/ScopedLock>
+#include <mutex>
 class ossimProjection;
 /**
  * @class ossimGeneralRasterElevHandler Elevation source for an srtm file.
@@ -157,7 +156,7 @@ private:
    virtual bool setFilename(const ossimFilename& file);
    
    ossimGeneralRasterElevHandler::GeneralRasterInfo theGeneralRasterInfo;
-   mutable OpenThreads::Mutex m_inputStreamMutex;
+   mutable std::mutex m_inputStreamMutex;
    std::ifstream m_inputStream;
 
    /** @brief true if stream is open. */
diff --git a/include/ossim/elevation/ossimGeneralRasterElevationDatabase.h b/include/ossim/elevation/ossimGeneralRasterElevationDatabase.h
index d448394..f9d79df 100644
--- a/include/ossim/elevation/ossimGeneralRasterElevationDatabase.h
+++ b/include/ossim/elevation/ossimGeneralRasterElevationDatabase.h
@@ -4,7 +4,7 @@
 #include <ossim/elevation/ossimElevationCellDatabase.h>
 #include <ossim/base/ossimFilename.h>
 #include <ossim/elevation/ossimGeneralRasterElevHandler.h>
-#include <OpenThreads/Mutex>
+#include <mutex>
 
 class OSSIM_DLL ossimGeneralRasterElevationDatabase : public ossimElevationCellDatabase
 {
diff --git a/include/ossim/elevation/ossimImageElevationDatabase.h b/include/ossim/elevation/ossimImageElevationDatabase.h
index 99a333d..7aa12a6 100644
--- a/include/ossim/elevation/ossimImageElevationDatabase.h
+++ b/include/ossim/elevation/ossimImageElevationDatabase.h
@@ -2,7 +2,7 @@
 //
 // File: ossimImageElevationDatabase.h
 // 
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/elevation/ossimImageElevationHandler.h b/include/ossim/elevation/ossimImageElevationHandler.h
index 963130f..748c414 100644
--- a/include/ossim/elevation/ossimImageElevationHandler.h
+++ b/include/ossim/elevation/ossimImageElevationHandler.h
@@ -2,7 +2,7 @@
 //
 // File: ossimImageElevationHandler.h
 // 
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
@@ -22,7 +22,7 @@
 #include <ossim/imaging/ossimImageGeometry.h>
 #include <ossim/imaging/ossimImageHandler.h>
 #include <ossim/imaging/ossimTileCache.h>
-#include <OpenThreads/ReadWriteMutex>
+#include <mutex>
 
 /**
  * @class ossimImageElevationHandler
@@ -124,7 +124,7 @@ private:
    ossimIpt                            m_tileSize;
    ossim_uint32                        m_numTilesPerRow;
 
-   mutable OpenThreads::ReadWriteMutex  m_mutex;
+   mutable std::mutex  m_mutex;
 
    TYPE_DATA
 };
diff --git a/include/ossim/elevation/ossimSrtmElevationDatabase.h b/include/ossim/elevation/ossimSrtmElevationDatabase.h
index ac472c5..95135ec 100644
--- a/include/ossim/elevation/ossimSrtmElevationDatabase.h
+++ b/include/ossim/elevation/ossimSrtmElevationDatabase.h
@@ -11,7 +11,7 @@
 #include <ossim/elevation/ossimElevationCellDatabase.h>
 #include <ossim/base/ossimFilename.h>
 #include <ossim/elevation/ossimSrtmHandler.h>
-#include <OpenThreads/Mutex>
+#include <mutex>
 
 class OSSIM_DLL ossimSrtmElevationDatabase : public ossimElevationCellDatabase
 {
diff --git a/include/ossim/elevation/ossimSrtmFactory.h b/include/ossim/elevation/ossimSrtmFactory.h
index 026bc95..ec3c92f 100644
--- a/include/ossim/elevation/ossimSrtmFactory.h
+++ b/include/ossim/elevation/ossimSrtmFactory.h
@@ -1,7 +1,7 @@
 //----------------------------------------------------------------------------
 // Copyright (c) 2005, David Burken, all rights reserved.
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/elevation/ossimSrtmHandler.h b/include/ossim/elevation/ossimSrtmHandler.h
index 7cc4c9c..b2c5758 100644
--- a/include/ossim/elevation/ossimSrtmHandler.h
+++ b/include/ossim/elevation/ossimSrtmHandler.h
@@ -19,6 +19,7 @@
 #include <ossim/base/ossimString.h>
 #include <ossim/elevation/ossimElevCellHandler.h>
 #include <ossim/support_data/ossimSrtmSupportData.h>
+#include <mutex>
 
 class ossimEndian;
 
@@ -84,7 +85,7 @@ protected:
    /** destructor */
    virtual ~ossimSrtmHandler();
    ossimSrtmSupportData m_supportData;
-   mutable OpenThreads::Mutex m_fileStrMutex;
+   mutable std::mutex m_fileStrMutex;
    std::ifstream m_fileStr;
 
    /** @brief true if stream is open. */
diff --git a/include/ossim/elevation/ossimTiledElevationDatabase.h b/include/ossim/elevation/ossimTiledElevationDatabase.h
index 0506d5d..18240bf 100644
--- a/include/ossim/elevation/ossimTiledElevationDatabase.h
+++ b/include/ossim/elevation/ossimTiledElevationDatabase.h
@@ -2,7 +2,7 @@
 //
 // File: ossimTiledElevationDatabase.h
 // 
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/font/ossimFontFactoryBase.h b/include/ossim/font/ossimFontFactoryBase.h
index 014a6f1..74d2bc4 100644
--- a/include/ossim/font/ossimFontFactoryBase.h
+++ b/include/ossim/font/ossimFontFactoryBase.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc. 
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/hdf5/ossimHdf5GridModel.h b/include/ossim/hdf5/ossimHdf5GridModel.h
index 6d54580..9561e8a 100644
--- a/include/ossim/hdf5/ossimHdf5GridModel.h
+++ b/include/ossim/hdf5/ossimHdf5GridModel.h
@@ -1,7 +1,7 @@
 //*****************************************************************************
 // FILE: ossimHdf5GridModel.h
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/hdf5/ossimHdf5ImageDataset.h b/include/ossim/hdf5/ossimHdf5ImageDataset.h
index 1189b37..9ba7c9b 100644
--- a/include/ossim/hdf5/ossimHdf5ImageDataset.h
+++ b/include/ossim/hdf5/ossimHdf5ImageDataset.h
@@ -1,6 +1,6 @@
 //----------------------------------------------------------------------------
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/hdf5/ossimHdf5ImageHandler.h b/include/ossim/hdf5/ossimHdf5ImageHandler.h
index 0d7f19c..c539f06 100644
--- a/include/ossim/hdf5/ossimHdf5ImageHandler.h
+++ b/include/ossim/hdf5/ossimHdf5ImageHandler.h
@@ -15,10 +15,9 @@
 #include <ossim/imaging/ossimImageHandler.h>
 #include <ossim/hdf5/ossimHdf5.h>
 #include <ossim/hdf5/ossimHdf5ImageDataset.h>
-#include <OpenThreads/Mutex>
 #include <vector>
 #include <string>
-
+#include <mutex>
 /**
  * This is the base class for all imagery using HDF5 as the file format. HDF5 is unique in that it
  * represents a variety of subformats for raster and projection information. The derived classes
@@ -221,7 +220,7 @@ protected:
    std::vector<ossimRefPtr<ossimHdf5ImageDataset> > m_entries;
    ossim_uint32                     m_currentEntry;
    ossimRefPtr<ossimImageData>      m_tile;
-   OpenThreads::Mutex               m_mutex;
+   std::mutex                       m_mutex;
 
    TYPE_DATA
 };
diff --git a/include/ossim/hdf5/ossimHdf5Info.h b/include/ossim/hdf5/ossimHdf5Info.h
index 1974988..864fb6c 100644
--- a/include/ossim/hdf5/ossimHdf5Info.h
+++ b/include/ossim/hdf5/ossimHdf5Info.h
@@ -1,6 +1,6 @@
 //----------------------------------------------------------------------------
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/hdf5/ossimHdf5ProjectionFactory.h b/include/ossim/hdf5/ossimHdf5ProjectionFactory.h
index a29ed03..5551b92 100644
--- a/include/ossim/hdf5/ossimHdf5ProjectionFactory.h
+++ b/include/ossim/hdf5/ossimHdf5ProjectionFactory.h
@@ -1,5 +1,5 @@
 //----------------------------------------------------------------------------
-// License:  LGPL
+// License:  MIT
 //
 // See LICENSE.txt file in the top level directory for more details.
 //----------------------------------------------------------------------------
diff --git a/include/ossim/imaging/ossim3x3ConvolutionFilter.h b/include/ossim/imaging/ossim3x3ConvolutionFilter.h
index 63637ba..ae5f046 100644
--- a/include/ossim/imaging/ossim3x3ConvolutionFilter.h
+++ b/include/ossim/imaging/ossim3x3ConvolutionFilter.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc. 
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimAOD.h b/include/ossim/imaging/ossimAOD.h
index 074c555..926d6e5 100644
--- a/include/ossim/imaging/ossimAOD.h
+++ b/include/ossim/imaging/ossimAOD.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2002 ImageLinks Inc. 
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimAdrgTileSource.h b/include/ossim/imaging/ossimAdrgTileSource.h
index 0f157bb..d140c16 100644
--- a/include/ossim/imaging/ossimAdrgTileSource.h
+++ b/include/ossim/imaging/ossimAdrgTileSource.h
@@ -1,6 +1,6 @@
 //*******************************************************************
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 // 
diff --git a/include/ossim/imaging/ossimAppFixedTileCache.h b/include/ossim/imaging/ossimAppFixedTileCache.h
index 9470b4b..dcf6207 100644
--- a/include/ossim/imaging/ossimAppFixedTileCache.h
+++ b/include/ossim/imaging/ossimAppFixedTileCache.h
@@ -1,6 +1,6 @@
 //******************************************************************
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
@@ -18,7 +18,7 @@
 #include <ossim/base/ossimConstants.h>
 #include <ossim/base/ossimRefPtr.h>
 #include <ossim/base/ossimIrect.h>
-#include <OpenThreads/ReadWriteMutex>
+#include <mutex>
 
 class ossimFixedTileCache;
 class ossimImageData;
@@ -111,7 +111,7 @@ protected:
 
    std::map<ossimAppFixedCacheId, ossimFixedTileCache*> theAppCacheMap;
 
-   OpenThreads::Mutex theMutex;
+   std::mutex theMutex;
 };
 
 #endif
diff --git a/include/ossim/imaging/ossimAppTileCache.h b/include/ossim/imaging/ossimAppTileCache.h
index 382ffe0..627af1b 100644
--- a/include/ossim/imaging/ossimAppTileCache.h
+++ b/include/ossim/imaging/ossimAppTileCache.h
@@ -1,7 +1,7 @@
 //******************************************************************
 // Copyright (C) 2000 ImageLinks Inc.
 //
-// License:  LGPL
+// License:  MIT
 //
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimAtCorrRemapper.h b/include/ossim/imaging/ossimAtCorrRemapper.h
index be043a0..c634a41 100644
--- a/include/ossim/imaging/ossimAtCorrRemapper.h
+++ b/include/ossim/imaging/ossimAtCorrRemapper.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2002 ImageLinks Inc. 
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimBandAverageFilter.h b/include/ossim/imaging/ossimBandAverageFilter.h
index c20ecd0..e2748a7 100644
--- a/include/ossim/imaging/ossimBandAverageFilter.h
+++ b/include/ossim/imaging/ossimBandAverageFilter.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc. 
 //
-// License:  LGPL
+// License:  MIT
 //
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimBandClipFilter.h b/include/ossim/imaging/ossimBandClipFilter.h
index f925082..91a44ad 100644
--- a/include/ossim/imaging/ossimBandClipFilter.h
+++ b/include/ossim/imaging/ossimBandClipFilter.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc. 
 //
-// License:  LGPL
+// License:  MIT
 //
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimBandLutFilter.h b/include/ossim/imaging/ossimBandLutFilter.h
index 8565a21..4924070 100644
--- a/include/ossim/imaging/ossimBandLutFilter.h
+++ b/include/ossim/imaging/ossimBandLutFilter.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc. 
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimBandMergeSource.h b/include/ossim/imaging/ossimBandMergeSource.h
index b7b0e16..d696afc 100644
--- a/include/ossim/imaging/ossimBandMergeSource.h
+++ b/include/ossim/imaging/ossimBandMergeSource.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc. 
 //
-// License:  LGPL
+// License:  MIT
 //
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimBandSeparateHandler.h b/include/ossim/imaging/ossimBandSeparateHandler.h
index 4beaac3..24a1acc 100644
--- a/include/ossim/imaging/ossimBandSeparateHandler.h
+++ b/include/ossim/imaging/ossimBandSeparateHandler.h
@@ -1,6 +1,6 @@
 //**************************************************************************************************
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimBitMaskTileSource.h b/include/ossim/imaging/ossimBitMaskTileSource.h
index 3799de3..091978f 100644
--- a/include/ossim/imaging/ossimBitMaskTileSource.h
+++ b/include/ossim/imaging/ossimBitMaskTileSource.h
@@ -1,6 +1,6 @@
 //*******************************************************************
 //
-// License:  LGPL
+// License:  MIT
 //
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimBitMaskWriter.h b/include/ossim/imaging/ossimBitMaskWriter.h
index 794669f..29e3299 100644
--- a/include/ossim/imaging/ossimBitMaskWriter.h
+++ b/include/ossim/imaging/ossimBitMaskWriter.h
@@ -1,6 +1,6 @@
 //*************************************************************************************************
 //
-// License:  LGPL
+// License:  MIT
 //
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimBlendMosaic.h b/include/ossim/imaging/ossimBlendMosaic.h
index 1e16922..010e3a1 100644
--- a/include/ossim/imaging/ossimBlendMosaic.h
+++ b/include/ossim/imaging/ossimBlendMosaic.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc. 
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimBrightnessMatch.h b/include/ossim/imaging/ossimBrightnessMatch.h
index 3708f84..c5b2d9f 100644
--- a/include/ossim/imaging/ossimBrightnessMatch.h
+++ b/include/ossim/imaging/ossimBrightnessMatch.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc. 
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimBumpShadeTileSource.h b/include/ossim/imaging/ossimBumpShadeTileSource.h
index d6646b7..5c8a8df 100644
--- a/include/ossim/imaging/ossimBumpShadeTileSource.h
+++ b/include/ossim/imaging/ossimBumpShadeTileSource.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc. 
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimCacheTileSource.h b/include/ossim/imaging/ossimCacheTileSource.h
index 7d5829d..4c73f6d 100644
--- a/include/ossim/imaging/ossimCacheTileSource.h
+++ b/include/ossim/imaging/ossimCacheTileSource.h
@@ -13,7 +13,7 @@
 #include <ossim/imaging/ossimImageSourceFilter.h>
 #include <ossim/imaging/ossimAppFixedTileCache.h>
 #include <ossim/base/ossimProcessProgressEvent.h>
-#include <OpenThreads/Mutex>
+#include <mutex>
 
 /** Cache Tile Source */
 class OSSIMDLLEXPORT ossimCacheTileSource : public ossimImageSourceFilter
diff --git a/include/ossim/imaging/ossimCastTileSourceFilter.h b/include/ossim/imaging/ossimCastTileSourceFilter.h
index 1981010..5d51e6d 100644
--- a/include/ossim/imaging/ossimCastTileSourceFilter.h
+++ b/include/ossim/imaging/ossimCastTileSourceFilter.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc. 
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimCcfTileSource.h b/include/ossim/imaging/ossimCcfTileSource.h
index 70e4cd0..3a78f40 100644
--- a/include/ossim/imaging/ossimCcfTileSource.h
+++ b/include/ossim/imaging/ossimCcfTileSource.h
@@ -1,6 +1,6 @@
 //*******************************************************************
 //
-// License:  LGPL
+// License:  MIT
 //
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimClosestToCenterCombiner.h b/include/ossim/imaging/ossimClosestToCenterCombiner.h
index 03e0b68..f78e31c 100644
--- a/include/ossim/imaging/ossimClosestToCenterCombiner.h
+++ b/include/ossim/imaging/ossimClosestToCenterCombiner.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2005 Garrett Potts. 
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimCodecBase.h b/include/ossim/imaging/ossimCodecBase.h
index 6e5620c..7b9e6f2 100644
--- a/include/ossim/imaging/ossimCodecBase.h
+++ b/include/ossim/imaging/ossimCodecBase.h
@@ -59,8 +59,7 @@ public:
    virtual bool decode( const std::vector<ossim_uint8>& in,
                         ossimRefPtr<ossimImageData>& out ) const=0;
 
-TYPE_DATA;
-
+   virtual const std::string& getExtension() const=0;
 };
 
 #endif
diff --git a/include/ossim/imaging/ossimCodecFactory.h b/include/ossim/imaging/ossimCodecFactory.h
index f7b491f..967048f 100644
--- a/include/ossim/imaging/ossimCodecFactory.h
+++ b/include/ossim/imaging/ossimCodecFactory.h
@@ -1,6 +1,6 @@
 //----------------------------------------------------------------------------
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimCodecFactoryInterface.h b/include/ossim/imaging/ossimCodecFactoryInterface.h
index ee5b19b..9e6ebaf 100644
--- a/include/ossim/imaging/ossimCodecFactoryInterface.h
+++ b/include/ossim/imaging/ossimCodecFactoryInterface.h
@@ -1,6 +1,6 @@
 //----------------------------------------------------------------------------
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimColorNormalizedFusion.h b/include/ossim/imaging/ossimColorNormalizedFusion.h
index d9f52a1..785e404 100644
--- a/include/ossim/imaging/ossimColorNormalizedFusion.h
+++ b/include/ossim/imaging/ossimColorNormalizedFusion.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc. 
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimConvolutionFilter1D.h b/include/ossim/imaging/ossimConvolutionFilter1D.h
index 3a7f741..ba65075 100644
--- a/include/ossim/imaging/ossimConvolutionFilter1D.h
+++ b/include/ossim/imaging/ossimConvolutionFilter1D.h
@@ -1,5 +1,5 @@
 //*******************************************************************
-// License:  LGPL
+// License:  MIT
 //
 // See LICENSE.txt file in the top level directory for more details.
 // class ossimImageGaussianFilter : tile source
diff --git a/include/ossim/imaging/ossimConvolutionSource.h b/include/ossim/imaging/ossimConvolutionSource.h
index 597389a..7eccb5a 100644
--- a/include/ossim/imaging/ossimConvolutionSource.h
+++ b/include/ossim/imaging/ossimConvolutionSource.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc.
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimDespeckleFilter.h b/include/ossim/imaging/ossimDespeckleFilter.h
index 0385850..09c4d32 100644
--- a/include/ossim/imaging/ossimDespeckleFilter.h
+++ b/include/ossim/imaging/ossimDespeckleFilter.h
@@ -1,6 +1,6 @@
 //*******************************************************************
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimDilationFilter.h b/include/ossim/imaging/ossimDilationFilter.h
index fb06be8..4d59535 100644
--- a/include/ossim/imaging/ossimDilationFilter.h
+++ b/include/ossim/imaging/ossimDilationFilter.h
@@ -2,7 +2,7 @@
 //
 //                                            OSSIM
 //
-//       License: LGPL. See LICENSE.txt file in the top level directory for more details.
+//       License: MIT. See LICENSE.txt file in the top level directory for more details.
 //
 //**************************************************************************************************
 //  $Id$
diff --git a/include/ossim/imaging/ossimDoqqTileSource.h b/include/ossim/imaging/ossimDoqqTileSource.h
index 568fdb2..be9d053 100644
--- a/include/ossim/imaging/ossimDoqqTileSource.h
+++ b/include/ossim/imaging/ossimDoqqTileSource.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc.
 //
-// License:  LGPL
+// License:  MIT
 //
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimDtedTileSource.h b/include/ossim/imaging/ossimDtedTileSource.h
index a120e62..92648d6 100644
--- a/include/ossim/imaging/ossimDtedTileSource.h
+++ b/include/ossim/imaging/ossimDtedTileSource.h
@@ -1,6 +1,6 @@
 //*******************************************************************
 //
-// License:  LGPL
+// License:  MIT
 //
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimERSTileSource.h b/include/ossim/imaging/ossimERSTileSource.h
index c63ec77..6c7de03 100644
--- a/include/ossim/imaging/ossimERSTileSource.h
+++ b/include/ossim/imaging/ossimERSTileSource.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc.
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimEdgeFilter.h b/include/ossim/imaging/ossimEdgeFilter.h
index dbc4427..351417a 100644
--- a/include/ossim/imaging/ossimEdgeFilter.h
+++ b/include/ossim/imaging/ossimEdgeFilter.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc.
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimElevImageSource.h b/include/ossim/imaging/ossimElevImageSource.h
index 92cdb4f..5407e89 100644
--- a/include/ossim/imaging/ossimElevImageSource.h
+++ b/include/ossim/imaging/ossimElevImageSource.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2002 ImageLinks Inc. 
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimElevationMosaic.h b/include/ossim/imaging/ossimElevationMosaic.h
index f617f49..119be6f 100644
--- a/include/ossim/imaging/ossimElevationMosaic.h
+++ b/include/ossim/imaging/ossimElevationMosaic.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc. 
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimEnviHeaderFileWriter.h b/include/ossim/imaging/ossimEnviHeaderFileWriter.h
index b5c599c..ecd0a23 100644
--- a/include/ossim/imaging/ossimEnviHeaderFileWriter.h
+++ b/include/ossim/imaging/ossimEnviHeaderFileWriter.h
@@ -1,7 +1,7 @@
 //----------------------------------------------------------------------------
 // Copyright (c) 2005, David Burken, all rights reserved.
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimEnviTileSource.h b/include/ossim/imaging/ossimEnviTileSource.h
index fdd0d11..bbae0ce 100644
--- a/include/ossim/imaging/ossimEnviTileSource.h
+++ b/include/ossim/imaging/ossimEnviTileSource.h
@@ -1,6 +1,6 @@
 //----------------------------------------------------------------------------
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimEquationCombiner.h b/include/ossim/imaging/ossimEquationCombiner.h
index 03421d1..1bf48d5 100644
--- a/include/ossim/imaging/ossimEquationCombiner.h
+++ b/include/ossim/imaging/ossimEquationCombiner.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc. 
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimFeatherMosaic.h b/include/ossim/imaging/ossimFeatherMosaic.h
index b0fff9a..f169007 100644
--- a/include/ossim/imaging/ossimFeatherMosaic.h
+++ b/include/ossim/imaging/ossimFeatherMosaic.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc. 
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 // 
diff --git a/include/ossim/imaging/ossimFftFilter.h b/include/ossim/imaging/ossimFftFilter.h
index ba744a6..c728e5b 100644
--- a/include/ossim/imaging/ossimFftFilter.h
+++ b/include/ossim/imaging/ossimFftFilter.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc.
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimFgdcFileWriter.h b/include/ossim/imaging/ossimFgdcFileWriter.h
index 5df2704..71afb54 100644
--- a/include/ossim/imaging/ossimFgdcFileWriter.h
+++ b/include/ossim/imaging/ossimFgdcFileWriter.h
@@ -1,7 +1,7 @@
 //----------------------------------------------------------------------------
 // Copyright (c) 2005, David Burken, all rights reserved.
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimFilterResampler.h b/include/ossim/imaging/ossimFilterResampler.h
index 96a84fb..b14f0ec 100644
--- a/include/ossim/imaging/ossimFilterResampler.h
+++ b/include/ossim/imaging/ossimFilterResampler.h
@@ -1,5 +1,5 @@
 //*******************************************************************
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimFilterTable.h b/include/ossim/imaging/ossimFilterTable.h
index ecdad50..9832722 100644
--- a/include/ossim/imaging/ossimFilterTable.h
+++ b/include/ossim/imaging/ossimFilterTable.h
@@ -1,6 +1,6 @@
 //----------------------------------------------------------------------------
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimFixedTileCache.h b/include/ossim/imaging/ossimFixedTileCache.h
index 2560719..7768c16 100644
--- a/include/ossim/imaging/ossimFixedTileCache.h
+++ b/include/ossim/imaging/ossimFixedTileCache.h
@@ -1,7 +1,7 @@
 //******************************************************************
 // Copyright (C) 2000 ImageLinks Inc.
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
@@ -19,7 +19,7 @@
 #include <ossim/base/ossimReferenced.h>
 #include <ossim/base/ossimRefPtr.h>
 #include <ossim/imaging/ossimImageData.h>
-#include <OpenThreads/Mutex>
+#include <mutex>
 
 class  ossimFixedTileCacheInfo
 {
@@ -128,7 +128,7 @@ public:
    virtual void setTileSize(const ossimIpt& tileSize);
 protected:
    virtual ~ossimFixedTileCache();
-   OpenThreads::Mutex theMutex;
+   std::mutex theMutex;
    ossimIrect   theTileBoundaryRect;
    ossimIpt     theTileSize;
    ossimIpt     theBoundaryWidthHeight;
diff --git a/include/ossim/imaging/ossimFusionCombiner.h b/include/ossim/imaging/ossimFusionCombiner.h
index d08aff4..9da8193 100644
--- a/include/ossim/imaging/ossimFusionCombiner.h
+++ b/include/ossim/imaging/ossimFusionCombiner.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc. 
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimGammaRemapper.h b/include/ossim/imaging/ossimGammaRemapper.h
index 95b6a96..fe0458d 100644
--- a/include/ossim/imaging/ossimGammaRemapper.h
+++ b/include/ossim/imaging/ossimGammaRemapper.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2002 ImageLinks Inc. 
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimGeneralRasterInfo.h b/include/ossim/imaging/ossimGeneralRasterInfo.h
index 6bec188..767d4f3 100644
--- a/include/ossim/imaging/ossimGeneralRasterInfo.h
+++ b/include/ossim/imaging/ossimGeneralRasterInfo.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc.
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
@@ -23,7 +23,7 @@
 #include <ossim/base/ossimErrorContext.h>
 #include <ossim/base/ossimFilename.h>
 #include <ossim/base/ossimIrect.h>
-#include <ossim/imaging/ossimImageMetaData.h>
+#include <ossim/support_data/ossimImageMetaData.h>
 #include <vector>
 
 //---
diff --git a/include/ossim/imaging/ossimGeoAnnotationBitmap.h b/include/ossim/imaging/ossimGeoAnnotationBitmap.h
index f32820e..ce321c5 100644
--- a/include/ossim/imaging/ossimGeoAnnotationBitmap.h
+++ b/include/ossim/imaging/ossimGeoAnnotationBitmap.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc. 
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimGeomFileWriter.h b/include/ossim/imaging/ossimGeomFileWriter.h
index 3b273e5..59077ca 100644
--- a/include/ossim/imaging/ossimGeomFileWriter.h
+++ b/include/ossim/imaging/ossimGeomFileWriter.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2003 Storage Area Networks, Inc.
 //
-// License:  LGPL
+// License:  MIT
 //
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimGridRemapEngine.h b/include/ossim/imaging/ossimGridRemapEngine.h
index a2d26c7..5765bb8 100644
--- a/include/ossim/imaging/ossimGridRemapEngine.h
+++ b/include/ossim/imaging/ossimGridRemapEngine.h
@@ -3,7 +3,7 @@
 //
 // Copyright (C) 2001 ImageLinks, Inc.
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimGridRemapSource.h b/include/ossim/imaging/ossimGridRemapSource.h
index b3eb061..613731c 100644
--- a/include/ossim/imaging/ossimGridRemapSource.h
+++ b/include/ossim/imaging/ossimGridRemapSource.h
@@ -3,7 +3,7 @@
 //
 // Copyright (C) 2001 ImageLinks, Inc.
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimHistoMatchRemapper.h b/include/ossim/imaging/ossimHistoMatchRemapper.h
index 90fbb52..e928c1f 100644
--- a/include/ossim/imaging/ossimHistoMatchRemapper.h
+++ b/include/ossim/imaging/ossimHistoMatchRemapper.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc.
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimHistogramEqualization.h b/include/ossim/imaging/ossimHistogramEqualization.h
index cee88f8..8933c36 100644
--- a/include/ossim/imaging/ossimHistogramEqualization.h
+++ b/include/ossim/imaging/ossimHistogramEqualization.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc. 
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 // 
diff --git a/include/ossim/imaging/ossimHistogramThreshholdFilter.h b/include/ossim/imaging/ossimHistogramThreshholdFilter.h
index 9d8121e..049d215 100644
--- a/include/ossim/imaging/ossimHistogramThreshholdFilter.h
+++ b/include/ossim/imaging/ossimHistogramThreshholdFilter.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc. 
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimHsiRemapper.h b/include/ossim/imaging/ossimHsiRemapper.h
index 172fcfd..5837bc0 100644
--- a/include/ossim/imaging/ossimHsiRemapper.h
+++ b/include/ossim/imaging/ossimHsiRemapper.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2002 ImageLinks Inc. 
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimHsiToRgbSource.h b/include/ossim/imaging/ossimHsiToRgbSource.h
index 4cdc91e..4bbf9b0 100644
--- a/include/ossim/imaging/ossimHsiToRgbSource.h
+++ b/include/ossim/imaging/ossimHsiToRgbSource.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc. 
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimHsvGridRemapEngine.h b/include/ossim/imaging/ossimHsvGridRemapEngine.h
index 1d5d605..9ec4b47 100644
--- a/include/ossim/imaging/ossimHsvGridRemapEngine.h
+++ b/include/ossim/imaging/ossimHsvGridRemapEngine.h
@@ -3,7 +3,7 @@
 //
 // Copyright (C) 2001 ImageLinks, Inc.
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 // 
diff --git a/include/ossim/imaging/ossimHsvToRgbSource.h b/include/ossim/imaging/ossimHsvToRgbSource.h
index aa34e07..2d341cc 100644
--- a/include/ossim/imaging/ossimHsvToRgbSource.h
+++ b/include/ossim/imaging/ossimHsvToRgbSource.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc. 
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimImageChain.h b/include/ossim/imaging/ossimImageChain.h
index 6cbb06a..5c6cc8b 100644
--- a/include/ossim/imaging/ossimImageChain.h
+++ b/include/ossim/imaging/ossimImageChain.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc. 
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimImageData.h b/include/ossim/imaging/ossimImageData.h
index fb6263a..1122005 100644
--- a/include/ossim/imaging/ossimImageData.h
+++ b/include/ossim/imaging/ossimImageData.h
@@ -920,6 +920,10 @@ public:
     * Undefined until validate() is called.
     */
    ossim_float64 percentFull() const { return m_percentFull; }
+
+
+   virtual bool isEqualTo(const ossimDataObject& rhs,
+                          bool deepTest=false)const;
    
    virtual bool saveState(ossimKeywordlist& kwl, const char* prefix=0)const;
    virtual bool loadState(const ossimKeywordlist& kwl, const char* prefix=0);
@@ -1193,8 +1197,6 @@ protected:
     */
    virtual void initializeNullDefault();
 
-   virtual bool isEqualTo(const ossimDataObject& rhs,
-                          bool deepTest=false)const;
    
    bool hasSameDimensionsAs(ossimImageData* data)const
    {
diff --git a/include/ossim/imaging/ossimImageDataFactory.h b/include/ossim/imaging/ossimImageDataFactory.h
index d04110c..e305a27 100644
--- a/include/ossim/imaging/ossimImageDataFactory.h
+++ b/include/ossim/imaging/ossimImageDataFactory.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc. 
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
@@ -16,7 +16,7 @@
 
 #include <ossim/imaging/ossimImageData.h>
 #include <ossim/base/ossimRefPtr.h>
-#include <OpenThreads/Mutex>
+#include <mutex>
 class ossimSource;
 class ossimImageSource;
 
@@ -57,7 +57,7 @@ protected:
    void operator = (ossimImageDataFactory&){}// hide
    
    static ossimImageDataFactory* theInstance;
-   static OpenThreads::Mutex theInstanceMutex;
+   static std::mutex theInstanceMutex;
 };
 
 #endif
diff --git a/include/ossim/imaging/ossimImageGaussianFilter.h b/include/ossim/imaging/ossimImageGaussianFilter.h
index cd55cfb..228071a 100644
--- a/include/ossim/imaging/ossimImageGaussianFilter.h
+++ b/include/ossim/imaging/ossimImageGaussianFilter.h
@@ -1,5 +1,5 @@
 //*******************************************************************
-// License:  LGPL
+// License:  MIT
 //
 // See LICENSE.txt file in the top level directory for more details.
 // class ossimImageGaussianFilter : tile source
diff --git a/include/ossim/imaging/ossimImageGeometry.h b/include/ossim/imaging/ossimImageGeometry.h
index ea803ce..823000a 100644
--- a/include/ossim/imaging/ossimImageGeometry.h
+++ b/include/ossim/imaging/ossimImageGeometry.h
@@ -1,6 +1,6 @@
 //***********************************************************************************************
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimImageGeometryFactory.h b/include/ossim/imaging/ossimImageGeometryFactory.h
index 4c20353..7bf84ec 100644
--- a/include/ossim/imaging/ossimImageGeometryFactory.h
+++ b/include/ossim/imaging/ossimImageGeometryFactory.h
@@ -1,6 +1,6 @@
 //*****************************************************************************
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimImageGeometryFactoryBase.h b/include/ossim/imaging/ossimImageGeometryFactoryBase.h
index 1f732de..be0980c 100644
--- a/include/ossim/imaging/ossimImageGeometryFactoryBase.h
+++ b/include/ossim/imaging/ossimImageGeometryFactoryBase.h
@@ -1,6 +1,6 @@
 //**************************************************************************************************
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimImageGeometryRegistry.h b/include/ossim/imaging/ossimImageGeometryRegistry.h
index 5ae90ca..6c0c6c6 100644
--- a/include/ossim/imaging/ossimImageGeometryRegistry.h
+++ b/include/ossim/imaging/ossimImageGeometryRegistry.h
@@ -1,6 +1,6 @@
 //**************************************************************************************************
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimImageHandler.h b/include/ossim/imaging/ossimImageHandler.h
index 9c6d05b..50bf532 100644
--- a/include/ossim/imaging/ossimImageHandler.h
+++ b/include/ossim/imaging/ossimImageHandler.h
@@ -1,6 +1,6 @@
 //*******************************************************************
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
@@ -23,7 +23,8 @@
 #include <ossim/base/ossimNBandLutDataObject.h>
 #include <ossim/base/ossimRefPtr.h>
 #include <ossim/imaging/ossimFilterResampler.h>
-#include <ossim/imaging/ossimImageMetaData.h>
+#include <ossim/support_data/ossimImageMetaData.h>
+#include <ossim/support_data/ImageHandlerState.h>
 
 class ossimMultiResLevelHistogram;
 
@@ -176,6 +177,7 @@ public:
 
    virtual bool open(const ossimFilename& imageFile);
 
+   virtual bool open(std::shared_ptr<ossim::ImageHandlerState> state);
    /**
     *  Deletes the overview and clears the valid image vertices.  Derived
     *  classes should implement.
@@ -730,6 +732,14 @@ public:
     */
    virtual bool getRgbBandList(std::vector<ossim_uint32>& bandList) const;
 
+
+   template <class T>
+   std::shared_ptr<T> getStateAs(){return dynamic_pointer_cast<T> (m_state);}
+   template <class T>
+   std::shared_ptr<const T> getStateAs()const{return dynamic_pointer_cast<const T> (m_state);}
+   std::shared_ptr<ossim::ImageHandlerState> getState(){return m_state;}
+   std::shared_ptr<const ossim::ImageHandlerState> getState()const{return m_state;}
+   void setState(std::shared_ptr<ossim::ImageHandlerState> state){m_state = state;}
 protected:
    
    /**
@@ -842,7 +852,8 @@ protected:
     */
    bool theOpenOverviewFlag;
    mutable ossimPixelType thePixelType; // pixel-is-point or pixel-is-area
-   
+
+  std::shared_ptr<ossim::ImageHandlerState> m_state;   
 TYPE_DATA
 };
 
diff --git a/include/ossim/imaging/ossimImageHandlerFactory.h b/include/ossim/imaging/ossimImageHandlerFactory.h
index df94754..8341501 100644
--- a/include/ossim/imaging/ossimImageHandlerFactory.h
+++ b/include/ossim/imaging/ossimImageHandlerFactory.h
@@ -38,6 +38,7 @@ public:
    virtual ossimImageHandler* open(const ossimKeywordlist& kwl,
                                    const char* prefix=0)const;
    
+   virtual ossimRefPtr<ossimImageHandler> open(std::shared_ptr<ossim::ImageHandlerState> state)const;
    /**
     * @brief Open method that takes a stream.
     * @param str Open stream to image.
diff --git a/include/ossim/imaging/ossimImageHandlerFactoryBase.h b/include/ossim/imaging/ossimImageHandlerFactoryBase.h
index cb81cec..5c1a3a3 100644
--- a/include/ossim/imaging/ossimImageHandlerFactoryBase.h
+++ b/include/ossim/imaging/ossimImageHandlerFactoryBase.h
@@ -13,6 +13,7 @@
 #include <ossim/base/ossimString.h>
 #include <ossim/base/ossimRefPtr.h>
 #include <ossim/imaging/ossimImageHandler.h>
+#include <ossim/support_data/ImageHandlerState.h>
 #include <ossim/base/ossimObjectFactory.h>
 #include <ossim/base/ossimIosFwd.h>
 #include <algorithm>
@@ -101,6 +102,10 @@ public:
       const std::string& connectionString,
       bool openOverview=true ) const;
 
+
+   virtual ossimRefPtr<ossimImageHandler> open(std::shared_ptr<ossim::ImageHandlerState> state)const;
+
+
    /**
     * @brief Open overview that takes a file name.
     *
diff --git a/include/ossim/imaging/ossimImageHandlerRegistry.h b/include/ossim/imaging/ossimImageHandlerRegistry.h
index b0e5674..822640a 100644
--- a/include/ossim/imaging/ossimImageHandlerRegistry.h
+++ b/include/ossim/imaging/ossimImageHandlerRegistry.h
@@ -20,11 +20,24 @@
 #include <iosfwd>
 #include <vector>
 #include <memory>
+#include <ossim/base/ItemCache.h>
+#include <ossim/support_data/ImageHandlerState.h>
 
 class ossimImageHandler;
 class ossimFilename;
 class ossimKeywordlist;
 
+/**
+* ossimImageHandlerRegistry supports the new state cache. During initialization the properties are
+* read from the global preferences.  The keywords are:
+*
+* ossim.imaging.handler.registry.state_cache.enabled: true or false
+* ossim.imaging.handler.registry.state_cache.min_size: min number of items
+* ossim.imaging.handler.registry.state_cache.max_size: max number of items
+*
+* On open if the state cache is enabled it will determine if a state exists when a file is passed 
+* in to be open and if a state exists it will try to open the handler based on the state.
+*/
 class OSSIMDLLEXPORT ossimImageHandlerRegistry : public ossimObjectFactory,
                                                 public ossimFactoryListInterface<ossimImageHandlerFactoryBase, ossimImageHandler>
 {
@@ -33,6 +46,10 @@ public:
    
    static ossimImageHandlerRegistry* instance();
 
+
+   std::shared_ptr<ossim::ImageHandlerState> getState(const ossimString& connectionString, ossim_uint32 entry)const;
+   std::shared_ptr<ossim::ImageHandlerState> getState(const ossimString& id)const;
+
    ossimRefPtr<ossimImageHandler> openConnection(
       const ossimString& connectionString, bool openOverview=true  )const;
    
@@ -56,6 +73,7 @@ public:
    virtual ossimImageHandler* open(const ossimKeywordlist& kwl,
                                    const char* prefix=0)const;
    
+   virtual ossimRefPtr<ossimImageHandler> open(std::shared_ptr<ossim::ImageHandlerState> state)const;
    /**
     * @brief Open method that takes a stream.
     * @param str Open stream to image.
@@ -161,7 +179,13 @@ protected:
    ossimImageHandlerRegistry(const ossimImageHandlerRegistry& rhs);
    const ossimImageHandlerRegistry&
       operator=(const ossimImageHandlerRegistry& rhs);
-   
+
+   void initializeStateCache()const;
+
+   void addToStateCache(ossimImageHandler* handler)const;
+
+   mutable std::shared_ptr<ossim::ItemCache<ossim::ImageHandlerState> > m_stateCache;
+
    //static ossimImageHandlerRegistry*            theInstance;
    
 TYPE_DATA
diff --git a/include/ossim/imaging/ossimImageMetaDataWriterFactory.h b/include/ossim/imaging/ossimImageMetaDataWriterFactory.h
index e9493e8..01795af 100644
--- a/include/ossim/imaging/ossimImageMetaDataWriterFactory.h
+++ b/include/ossim/imaging/ossimImageMetaDataWriterFactory.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2003 Storage Area Networks, Inc.
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimImageMetaDataWriterFactoryBase.h b/include/ossim/imaging/ossimImageMetaDataWriterFactoryBase.h
index cb1013d..0a46625 100644
--- a/include/ossim/imaging/ossimImageMetaDataWriterFactoryBase.h
+++ b/include/ossim/imaging/ossimImageMetaDataWriterFactoryBase.h
@@ -1,5 +1,5 @@
 //----------------------------------------------------------------------------
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //----------------------------------------------------------------------------
diff --git a/include/ossim/imaging/ossimImageMetaDataWriterRegistry.h b/include/ossim/imaging/ossimImageMetaDataWriterRegistry.h
index ea62f65..c46630e 100644
--- a/include/ossim/imaging/ossimImageMetaDataWriterRegistry.h
+++ b/include/ossim/imaging/ossimImageMetaDataWriterRegistry.h
@@ -1,5 +1,5 @@
 //----------------------------------------------------------------------------
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //----------------------------------------------------------------------------
diff --git a/include/ossim/imaging/ossimImageModel.h b/include/ossim/imaging/ossimImageModel.h
index 3ab9c98..4b0dd5a 100644
--- a/include/ossim/imaging/ossimImageModel.h
+++ b/include/ossim/imaging/ossimImageModel.h
@@ -1,6 +1,6 @@
 //-----------------------------------------------------------------------------
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimImageMosaic.h b/include/ossim/imaging/ossimImageMosaic.h
index e5afb34..43e5bd2 100644
--- a/include/ossim/imaging/ossimImageMosaic.h
+++ b/include/ossim/imaging/ossimImageMosaic.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc. 
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimImageRenderer.h b/include/ossim/imaging/ossimImageRenderer.h
index 28742ab..736b2f9 100644
--- a/include/ossim/imaging/ossimImageRenderer.h
+++ b/include/ossim/imaging/ossimImageRenderer.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2001 ImageLinks Inc. 
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimImageSharpenFilter.h b/include/ossim/imaging/ossimImageSharpenFilter.h
index efbce71..b2d07eb 100644
--- a/include/ossim/imaging/ossimImageSharpenFilter.h
+++ b/include/ossim/imaging/ossimImageSharpenFilter.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc. 
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimImageSource.h b/include/ossim/imaging/ossimImageSource.h
index 6ce3b1a..1461b62 100644
--- a/include/ossim/imaging/ossimImageSource.h
+++ b/include/ossim/imaging/ossimImageSource.h
@@ -1,6 +1,6 @@
 //*******************************************************************
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimImageSourceFilter.h b/include/ossim/imaging/ossimImageSourceFilter.h
index 41809ae..f0df530 100644
--- a/include/ossim/imaging/ossimImageSourceFilter.h
+++ b/include/ossim/imaging/ossimImageSourceFilter.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc.
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimImageSourceSequencer.h b/include/ossim/imaging/ossimImageSourceSequencer.h
index a2162f6..07f8c91 100644
--- a/include/ossim/imaging/ossimImageSourceSequencer.h
+++ b/include/ossim/imaging/ossimImageSourceSequencer.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc.
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimImageToPlaneNormalFilter.h b/include/ossim/imaging/ossimImageToPlaneNormalFilter.h
index 4de7145..03899f7 100644
--- a/include/ossim/imaging/ossimImageToPlaneNormalFilter.h
+++ b/include/ossim/imaging/ossimImageToPlaneNormalFilter.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc. 
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimImageWriterFactory.h b/include/ossim/imaging/ossimImageWriterFactory.h
index 3d50792..26fe9eb 100644
--- a/include/ossim/imaging/ossimImageWriterFactory.h
+++ b/include/ossim/imaging/ossimImageWriterFactory.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc.
 //
-// License:  LGPL
+// License:  MIT
 //
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimImageWriterFactoryRegistry.h b/include/ossim/imaging/ossimImageWriterFactoryRegistry.h
index e30db31..a05b49e 100644
--- a/include/ossim/imaging/ossimImageWriterFactoryRegistry.h
+++ b/include/ossim/imaging/ossimImageWriterFactoryRegistry.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc.
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimIndexToRgbLutFilter.h b/include/ossim/imaging/ossimIndexToRgbLutFilter.h
index 77142ca..4698172 100644
--- a/include/ossim/imaging/ossimIndexToRgbLutFilter.h
+++ b/include/ossim/imaging/ossimIndexToRgbLutFilter.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc. 
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimIntensityAdjustmentFilter.h b/include/ossim/imaging/ossimIntensityAdjustmentFilter.h
index 6b83809..1a64d17 100644
--- a/include/ossim/imaging/ossimIntensityAdjustmentFilter.h
+++ b/include/ossim/imaging/ossimIntensityAdjustmentFilter.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc.
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimJpegCodec.h b/include/ossim/imaging/ossimJpegCodec.h
index 55e3853..d51d11f 100644
--- a/include/ossim/imaging/ossimJpegCodec.h
+++ b/include/ossim/imaging/ossimJpegCodec.h
@@ -1,13 +1,12 @@
-//----------------------------------------------------------------------------
+//---
 //
-// License:  LGPL
-// 
-// See LICENSE.txt file in the top level directory for more details.
+// License: MIT
 //
 // Description: class declaration for base codec(encoder/decoder).
 // 
-//----------------------------------------------------------------------------
+//---
 // $Id$
+
 #ifndef ossimJpegCodec_HEADER
 #define ossimJpegCodec_HEADER 1
 #include <ossim/imaging/ossimCodecBase.h>
@@ -58,6 +57,8 @@ public:
    virtual bool decode( const std::vector<ossim_uint8>& in,
                         ossimRefPtr<ossimImageData>& out ) const;
 
+   virtual const std::string& getExtension() const;
+
    /**
     * Ineterface to allow for specific properties to be set.
     *
@@ -127,7 +128,7 @@ protected:
    ossim_int32 getColorSpace( const std::vector<ossim_uint8>& in ) const;
    
    ossim_uint32 m_quality;
-   TYPE_DATA;
+   std::string m_ext;
 };
 
 #endif
diff --git a/include/ossim/imaging/ossimJpegDefaultTable.h b/include/ossim/imaging/ossimJpegDefaultTable.h
index a49fe6f..3b4486e 100644
--- a/include/ossim/imaging/ossimJpegDefaultTable.h
+++ b/include/ossim/imaging/ossimJpegDefaultTable.h
@@ -1,6 +1,6 @@
 //*******************************************************************
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 // 
diff --git a/include/ossim/imaging/ossimJpegTileSource.h b/include/ossim/imaging/ossimJpegTileSource.h
index a12fa7d..5ecc9b0 100644
--- a/include/ossim/imaging/ossimJpegTileSource.h
+++ b/include/ossim/imaging/ossimJpegTileSource.h
@@ -1,6 +1,6 @@
 //*******************************************************************
 //
-// License:  LGPL
+// License:  MIT
 //
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimJpegYCbCrToRgbSource.h b/include/ossim/imaging/ossimJpegYCbCrToRgbSource.h
index 6436edd..233eb76 100644
--- a/include/ossim/imaging/ossimJpegYCbCrToRgbSource.h
+++ b/include/ossim/imaging/ossimJpegYCbCrToRgbSource.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc. 
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimLasReader.h b/include/ossim/imaging/ossimLasReader.h
index eebae11..6fcee7b 100644
--- a/include/ossim/imaging/ossimLasReader.h
+++ b/include/ossim/imaging/ossimLasReader.h
@@ -20,6 +20,7 @@
 #include <ossim/imaging/ossimImageData.h>
 #include <ossim/imaging/ossimImageGeometry.h>
 #include <ossim/projection/ossimProjection.h>
+#include <mutex>
 
 class ossimLasHdr;
 class ossimLasPointRecordInterface;
@@ -306,7 +307,7 @@ private:
    ossimDpt                     m_gsd;
    ossimRefPtr<ossimImageData>  m_tile;
    ossim_uint8                  m_entry;
-   OpenThreads::Mutex           m_mutex;
+   std::mutex                   m_mutex;
    bool                         m_scan;  // Scan for bounds at open.
    ossimUnitType                m_units;
    ossimUnitConversionTool*     m_unitConverter;
diff --git a/include/ossim/imaging/ossimLinearStretchRemapper.h b/include/ossim/imaging/ossimLinearStretchRemapper.h
index f8174f0..4194267 100644
--- a/include/ossim/imaging/ossimLinearStretchRemapper.h
+++ b/include/ossim/imaging/ossimLinearStretchRemapper.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc. 
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimMapCompositionSource.h b/include/ossim/imaging/ossimMapCompositionSource.h
index eae1552..6a68278 100644
--- a/include/ossim/imaging/ossimMapCompositionSource.h
+++ b/include/ossim/imaging/ossimMapCompositionSource.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc. 
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimMaskFilter.h b/include/ossim/imaging/ossimMaskFilter.h
index d0a90aa..429a9da 100644
--- a/include/ossim/imaging/ossimMaskFilter.h
+++ b/include/ossim/imaging/ossimMaskFilter.h
@@ -1,7 +1,7 @@
 //*******************************************************************
   // Copyright (C) 2000 ImageLinks Inc. 
   //
-  // License:  LGPL
+  // License:  MIT
   // 
   // See LICENSE.txt file in the top level directory for more details.
   //
diff --git a/include/ossim/imaging/ossimMaxMosaic.h b/include/ossim/imaging/ossimMaxMosaic.h
index af13fd1..f09dd2c 100644
--- a/include/ossim/imaging/ossimMaxMosaic.h
+++ b/include/ossim/imaging/ossimMaxMosaic.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2005 SANZ Inc. 
 //
-// License:  LGPL
+// License:  MIT
 //
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimMeanMedianFilter.h b/include/ossim/imaging/ossimMeanMedianFilter.h
index ec4bab1..627ec0e 100644
--- a/include/ossim/imaging/ossimMeanMedianFilter.h
+++ b/include/ossim/imaging/ossimMeanMedianFilter.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc.
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimMetadataFileWriter.h b/include/ossim/imaging/ossimMetadataFileWriter.h
index 04d44ec..ca0a932 100644
--- a/include/ossim/imaging/ossimMetadataFileWriter.h
+++ b/include/ossim/imaging/ossimMetadataFileWriter.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2003 Storage Area Networks, Inc.
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimMonoGridRemapEngine.h b/include/ossim/imaging/ossimMonoGridRemapEngine.h
index 78385da..1b0312d 100644
--- a/include/ossim/imaging/ossimMonoGridRemapEngine.h
+++ b/include/ossim/imaging/ossimMonoGridRemapEngine.h
@@ -3,7 +3,7 @@
 //
 // Copyright (C) 2001 ImageLinks, Inc.
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimNBandToIndexFilter.h b/include/ossim/imaging/ossimNBandToIndexFilter.h
index 0ec580d..fa5c9a9 100644
--- a/include/ossim/imaging/ossimNBandToIndexFilter.h
+++ b/include/ossim/imaging/ossimNBandToIndexFilter.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2005 Garrett Potts
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimNitf20Writer.h b/include/ossim/imaging/ossimNitf20Writer.h
index c26ba01..c689a81 100644
--- a/include/ossim/imaging/ossimNitf20Writer.h
+++ b/include/ossim/imaging/ossimNitf20Writer.h
@@ -1,6 +1,6 @@
 //*******************************************************************
 //
-// License:  LGPL
+// License:  MIT
 //
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimNitfWriterBase.h b/include/ossim/imaging/ossimNitfWriterBase.h
index ea17167..a00d7e6 100644
--- a/include/ossim/imaging/ossimNitfWriterBase.h
+++ b/include/ossim/imaging/ossimNitfWriterBase.h
@@ -1,6 +1,6 @@
 //----------------------------------------------------------------------------
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimNormalizedRemapTable.h b/include/ossim/imaging/ossimNormalizedRemapTable.h
index 88b6e6d..adc9665 100644
--- a/include/ossim/imaging/ossimNormalizedRemapTable.h
+++ b/include/ossim/imaging/ossimNormalizedRemapTable.h
@@ -1,6 +1,6 @@
 //*******************************************************************
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 // 
diff --git a/include/ossim/imaging/ossimNormalizedS16RemapTable.h b/include/ossim/imaging/ossimNormalizedS16RemapTable.h
index ce87f86..9c21321 100644
--- a/include/ossim/imaging/ossimNormalizedS16RemapTable.h
+++ b/include/ossim/imaging/ossimNormalizedS16RemapTable.h
@@ -1,6 +1,6 @@
 //*******************************************************************
 //
-// License:  LGPL
+// License:  MIT
 //
 // See LICENSE.txt file in the top level directory for more details.
 // 
diff --git a/include/ossim/imaging/ossimNormalizedU11RemapTable.h b/include/ossim/imaging/ossimNormalizedU11RemapTable.h
index e5a6ded..38ba03a 100644
--- a/include/ossim/imaging/ossimNormalizedU11RemapTable.h
+++ b/include/ossim/imaging/ossimNormalizedU11RemapTable.h
@@ -1,6 +1,6 @@
 //*******************************************************************
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 // 
diff --git a/include/ossim/imaging/ossimNormalizedU12RemapTable.h b/include/ossim/imaging/ossimNormalizedU12RemapTable.h
index 09946d0..e8cd4fd 100644
--- a/include/ossim/imaging/ossimNormalizedU12RemapTable.h
+++ b/include/ossim/imaging/ossimNormalizedU12RemapTable.h
@@ -1,6 +1,6 @@
 //*******************************************************************
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 // 
diff --git a/include/ossim/imaging/ossimNormalizedU13RemapTable.h b/include/ossim/imaging/ossimNormalizedU13RemapTable.h
index b220762..a06d0ca 100644
--- a/include/ossim/imaging/ossimNormalizedU13RemapTable.h
+++ b/include/ossim/imaging/ossimNormalizedU13RemapTable.h
@@ -1,6 +1,6 @@
 //*******************************************************************
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 // 
diff --git a/include/ossim/imaging/ossimNormalizedU14RemapTable.h b/include/ossim/imaging/ossimNormalizedU14RemapTable.h
index b2b4e12..12e4ad5 100644
--- a/include/ossim/imaging/ossimNormalizedU14RemapTable.h
+++ b/include/ossim/imaging/ossimNormalizedU14RemapTable.h
@@ -1,6 +1,6 @@
 //*******************************************************************
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 // 
diff --git a/include/ossim/imaging/ossimNormalizedU15RemapTable.h b/include/ossim/imaging/ossimNormalizedU15RemapTable.h
index 0952495..37b35c4 100644
--- a/include/ossim/imaging/ossimNormalizedU15RemapTable.h
+++ b/include/ossim/imaging/ossimNormalizedU15RemapTable.h
@@ -1,6 +1,6 @@
 //*******************************************************************
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 // 
diff --git a/include/ossim/imaging/ossimNormalizedU16RemapTable.h b/include/ossim/imaging/ossimNormalizedU16RemapTable.h
index 5435a66..70cae4a 100644
--- a/include/ossim/imaging/ossimNormalizedU16RemapTable.h
+++ b/include/ossim/imaging/ossimNormalizedU16RemapTable.h
@@ -1,6 +1,6 @@
 //*******************************************************************
 //
-// License:  LGPL
+// License:  MIT
 //
 // See LICENSE.txt file in the top level directory for more details.
 // 
diff --git a/include/ossim/imaging/ossimNormalizedU8RemapTable.h b/include/ossim/imaging/ossimNormalizedU8RemapTable.h
index 050b1cf..0faac38 100644
--- a/include/ossim/imaging/ossimNormalizedU8RemapTable.h
+++ b/include/ossim/imaging/ossimNormalizedU8RemapTable.h
@@ -1,6 +1,6 @@
 //*******************************************************************
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 // 
diff --git a/include/ossim/imaging/ossimNullPixelFlip.h b/include/ossim/imaging/ossimNullPixelFlip.h
index 15904de..ed7cc51 100644
--- a/include/ossim/imaging/ossimNullPixelFlip.h
+++ b/include/ossim/imaging/ossimNullPixelFlip.h
@@ -27,7 +27,8 @@ public:
       ReplacementType_MAXPIX = 1
    };
    
-   ossimNullPixelFlip();
+   ossimNullPixelFlip(ClipMode clipMode = ClipMode_BOUNDING_RECT, 
+                      ReplacementType replacementType=ReplacementType_MINPIX);
    virtual void initialize();
    virtual ossimRefPtr<ossimImageData> getTile(const ossimIrect& tile_rect,
                                                ossim_uint32 resLevel=0);
diff --git a/include/ossim/imaging/ossimOrthoImageMosaic.h b/include/ossim/imaging/ossimOrthoImageMosaic.h
index be01411..7af6503 100644
--- a/include/ossim/imaging/ossimOrthoImageMosaic.h
+++ b/include/ossim/imaging/ossimOrthoImageMosaic.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc.
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimOverviewBuilderBase.h b/include/ossim/imaging/ossimOverviewBuilderBase.h
index 8731981..ce9a3c2 100644
--- a/include/ossim/imaging/ossimOverviewBuilderBase.h
+++ b/include/ossim/imaging/ossimOverviewBuilderBase.h
@@ -1,6 +1,6 @@
 //----------------------------------------------------------------------------
 //
-// License:  LGPL
+// License:  MIT
 //
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimPdfWriter.h b/include/ossim/imaging/ossimPdfWriter.h
index 0f38a80..4b495cc 100644
--- a/include/ossim/imaging/ossimPdfWriter.h
+++ b/include/ossim/imaging/ossimPdfWriter.h
@@ -19,8 +19,8 @@
 #include <ossim/base/ossimRtti.h>
 #include <ossim/base/ossimKeywordlist.h>
 #include <ossim/imaging/ossimImageSource.h>
-#include <OpenThreads/Mutex>
 #include <iosfwd>
+#include <mutex>
 
 // Forward class declarations:
 class ossimImageData;
@@ -546,7 +546,7 @@ private:
    /** Holds all options in key, value pair map. */
    ossimRefPtr<ossimKeywordlist> m_kwl;
 
-   OpenThreads::Mutex m_mutex;
+   std::mutex m_mutex;
 
 TYPE_DATA
 };
diff --git a/include/ossim/imaging/ossimPixelFlipper.h b/include/ossim/imaging/ossimPixelFlipper.h
index 5659834..1f35f16 100644
--- a/include/ossim/imaging/ossimPixelFlipper.h
+++ b/include/ossim/imaging/ossimPixelFlipper.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2002 ImageLinks Inc. 
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
@@ -19,7 +19,7 @@
 
 #include <ossim/imaging/ossimImageSourceFilter.h>
 #include <ossim/base/ossimPolygon.h>
-#include <OpenThreads/ReentrantMutex>
+#include <mutex>
 
 /**
  *  Class to scan pixels and flip target dn value to a replacement dn
@@ -258,7 +258,7 @@ protected:
    ClipMode        theClipMode;
    
    /** For lock and unlock. */
-   mutable OpenThreads::ReentrantMutex      theMutex;
+   mutable std::recursive_mutex      theMutex;
 
    mutable std::vector<ossimPolygon> theValidVertices;
    mutable std::vector<ossimIrect>   theBoundingRects;
diff --git a/include/ossim/imaging/ossimPolyCutter.h b/include/ossim/imaging/ossimPolyCutter.h
index a0afc16..abdd56c 100644
--- a/include/ossim/imaging/ossimPolyCutter.h
+++ b/include/ossim/imaging/ossimPolyCutter.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc. 
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimQbTileFilesHandler.h b/include/ossim/imaging/ossimQbTileFilesHandler.h
index 5fa1484..c1268ce 100644
--- a/include/ossim/imaging/ossimQbTileFilesHandler.h
+++ b/include/ossim/imaging/ossimQbTileFilesHandler.h
@@ -1,6 +1,6 @@
 //**************************************************************************************************
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimQuickbirdNitfTileSource.h b/include/ossim/imaging/ossimQuickbirdNitfTileSource.h
index fa2b883..eb317ad 100644
--- a/include/ossim/imaging/ossimQuickbirdNitfTileSource.h
+++ b/include/ossim/imaging/ossimQuickbirdNitfTileSource.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc.
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimQuickbirdTiffTileSource.h b/include/ossim/imaging/ossimQuickbirdTiffTileSource.h
index 6e9bd90..74ae032 100644
--- a/include/ossim/imaging/ossimQuickbirdTiffTileSource.h
+++ b/include/ossim/imaging/ossimQuickbirdTiffTileSource.h
@@ -1,7 +1,7 @@
 //----------------------------------------------------------------------------
 // Copyright (c) 2005, David Burken, all rights reserved.
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimRLevelFilter.h b/include/ossim/imaging/ossimRLevelFilter.h
index 9a3319f..409f844 100644
--- a/include/ossim/imaging/ossimRLevelFilter.h
+++ b/include/ossim/imaging/ossimRLevelFilter.h
@@ -1,6 +1,6 @@
 //*******************************************************************
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimRangeDomeTileSource.h b/include/ossim/imaging/ossimRangeDomeTileSource.h
index 1ae0e63..77ee738 100755
--- a/include/ossim/imaging/ossimRangeDomeTileSource.h
+++ b/include/ossim/imaging/ossimRangeDomeTileSource.h
@@ -2,7 +2,7 @@
 //
 // OSSIM (http://trac.osgeo.org/ossim/)
 //
-// License:  LGPL -- See LICENSE.txt file in the top level directory for more details.
+// License:  MIT -- See LICENSE.txt file in the top level directory for more details.
 //
 //**************************************************************************************************
 // $Id: ossimRangeDomeTileSource.h 23464 2015-08-07 18:39:47Z okramer $
diff --git a/include/ossim/imaging/ossimReadmeFileWriter.h b/include/ossim/imaging/ossimReadmeFileWriter.h
index a02a1ba..49610cf 100644
--- a/include/ossim/imaging/ossimReadmeFileWriter.h
+++ b/include/ossim/imaging/ossimReadmeFileWriter.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2003 Storage Area Networks, Inc.
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimRectangleCutFilter.h b/include/ossim/imaging/ossimRectangleCutFilter.h
index a831cb2..be53098 100644
--- a/include/ossim/imaging/ossimRectangleCutFilter.h
+++ b/include/ossim/imaging/ossimRectangleCutFilter.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc. 
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimRgbGridRemapEngine.h b/include/ossim/imaging/ossimRgbGridRemapEngine.h
index e0a1d04..acdf50f 100644
--- a/include/ossim/imaging/ossimRgbGridRemapEngine.h
+++ b/include/ossim/imaging/ossimRgbGridRemapEngine.h
@@ -3,7 +3,7 @@
 //
 // Copyright (C) 2001 ImageLinks, Inc.
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimRgbToGreyFilter.h b/include/ossim/imaging/ossimRgbToGreyFilter.h
index a274034..422da9c 100644
--- a/include/ossim/imaging/ossimRgbToGreyFilter.h
+++ b/include/ossim/imaging/ossimRgbToGreyFilter.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc. 
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimRgbToHsiSource.h b/include/ossim/imaging/ossimRgbToHsiSource.h
index 5105111..060c134 100644
--- a/include/ossim/imaging/ossimRgbToHsiSource.h
+++ b/include/ossim/imaging/ossimRgbToHsiSource.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc. 
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimRgbToHsvSource.h b/include/ossim/imaging/ossimRgbToHsvSource.h
index 6b8f542..b37c200 100644
--- a/include/ossim/imaging/ossimRgbToHsvSource.h
+++ b/include/ossim/imaging/ossimRgbToHsvSource.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc. 
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimRgbToIndexFilter.h b/include/ossim/imaging/ossimRgbToIndexFilter.h
index d66c192..8c6fd81 100644
--- a/include/ossim/imaging/ossimRgbToIndexFilter.h
+++ b/include/ossim/imaging/ossimRgbToIndexFilter.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc. 
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimRgbToJpegYCbCrSource.h b/include/ossim/imaging/ossimRgbToJpegYCbCrSource.h
index 2422b80..16a3ff2 100644
--- a/include/ossim/imaging/ossimRgbToJpegYCbCrSource.h
+++ b/include/ossim/imaging/ossimRgbToJpegYCbCrSource.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc. 
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimS16ImageData.h b/include/ossim/imaging/ossimS16ImageData.h
index 2df4e18..91edf96 100644
--- a/include/ossim/imaging/ossimS16ImageData.h
+++ b/include/ossim/imaging/ossimS16ImageData.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2001 ImageLinks Inc. 
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimSFIMFusion.h b/include/ossim/imaging/ossimSFIMFusion.h
index eef34a9..8e73084 100644
--- a/include/ossim/imaging/ossimSFIMFusion.h
+++ b/include/ossim/imaging/ossimSFIMFusion.h
@@ -26,7 +26,7 @@
  *
  *
  * Auther: Garrett Potts
- * LICENSE: LGPL
+ * LICENSE: MIT
  */
 class OSSIM_DLL ossimSFIMFusion : public ossimFusionCombiner,
                                   public ossimAdjustableParameterInterface
diff --git a/include/ossim/imaging/ossimScaleFilter.h b/include/ossim/imaging/ossimScaleFilter.h
index 1a7a3bb..9435776 100644
--- a/include/ossim/imaging/ossimScaleFilter.h
+++ b/include/ossim/imaging/ossimScaleFilter.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc. 
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimShiftFilter.h b/include/ossim/imaging/ossimShiftFilter.h
index bf5e6d5..c95e399 100644
--- a/include/ossim/imaging/ossimShiftFilter.h
+++ b/include/ossim/imaging/ossimShiftFilter.h
@@ -1,5 +1,5 @@
 //----------------------------------------------------------------------------
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimSingleImageChain.h b/include/ossim/imaging/ossimSingleImageChain.h
index e797492..e61f7f3 100644
--- a/include/ossim/imaging/ossimSingleImageChain.h
+++ b/include/ossim/imaging/ossimSingleImageChain.h
@@ -21,6 +21,7 @@
 #include <ossim/imaging/ossimImageHandler.h>
 #include <ossim/imaging/ossimImageRenderer.h>
 #include <ossim/imaging/ossimImageSharpenFilter.h>
+#include <ossim/imaging/ossimNullPixelFlip.h>
 #include <ossim/imaging/ossimScalarRemapper.h>
 #include <vector>
 
@@ -62,7 +63,8 @@ public:
    ossimSingleImageChain();
 
    /** Constructor that takes flags.*/
-   ossimSingleImageChain(bool addHistogramFlag,
+   ossimSingleImageChain(bool addNullPixelFlipFlag,
+                         bool addHistogramFlag,
                          bool addResamplerCacheFlag,
                          bool addChainCacheFlag,
                          bool remapToEightBitFlag,
@@ -240,6 +242,11 @@ public:
 
 
    /**
+   * Adds the null pixel flip just after the band selection
+   */
+   void addNullPixelFlip();
+   void addNullPixelFlip(const ossimSrcRecord& src);
+   /**
    *
    * @brief Adds a geo polycutter to allow for cropping imagery or nulling out
    * regions.  This has no affect on modification of the bounds
@@ -269,6 +276,11 @@ public:
    ossimRefPtr<const ossimBandSelector> getBandSelector() const;
 
    /**
+   *  @return the null pixel flip
+   */
+   ossimRefPtr<const ossimNullPixelFlip> getNullPixelFlip() const;
+
+   /**
     * @return ossimRefPtr containing  the band selector.
     * @note Can contain a null pointer so callers should validate.
     */
@@ -360,6 +372,20 @@ public:
    ossimRefPtr<ossimCacheTileSource> getChainCache();
 
    /**
+    * @brief If flag is true a null pixel flip will be added to the chain at create time.
+    * @param flag
+    */
+   void setAddNullPixelFlipFlag(bool flag);
+
+   /**
+    * @brief Gets the add histogram flag.
+    * @return true or false.
+    */
+   bool getNullPixelFlipFlag() const;
+
+ 
+
+   /**
     * @brief If flag is true a histogram will be added to the chain at create time.
     * @param flag
     */
@@ -537,6 +563,7 @@ private:
    /**  Pointers to links in chain. */
    ossimRefPtr<ossimImageHandler>             m_handler;
    ossimRefPtr<ossimBandSelector>             m_bandSelector;
+   ossimRefPtr<ossimNullPixelFlip>            m_nullPixelFlip;
    ossimRefPtr<ossimHistogramRemapper>        m_histogramRemapper;
    ossimRefPtr<ossimBrightnessContrastSource> m_brightnessContrast;
    ossimRefPtr<ossimImageSharpenFilter>       m_sharpen;   
@@ -545,8 +572,8 @@ private:
    ossimRefPtr<ossimImageRenderer>            m_resampler;
    ossimRefPtr<ossimGeoPolyCutter>            m_geoPolyCutter;
    ossimRefPtr<ossimCacheTileSource>          m_chainCache;
-
    /** control flags */
+   bool m_addNullPixelFlipFlag;
    bool m_addHistogramFlag;
    bool m_addResamplerCacheFlag;
    bool m_addChainCacheFlag;
diff --git a/include/ossim/imaging/ossimSrtmTileSource.h b/include/ossim/imaging/ossimSrtmTileSource.h
index 7ddde03..8e78407 100644
--- a/include/ossim/imaging/ossimSrtmTileSource.h
+++ b/include/ossim/imaging/ossimSrtmTileSource.h
@@ -1,7 +1,7 @@
 //----------------------------------------------------------------------------
 // Copyright (c) 2005, David Burken, all rights reserved.
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimSubImageTileSource.h b/include/ossim/imaging/ossimSubImageTileSource.h
index 152a06a..9fac598 100644
--- a/include/ossim/imaging/ossimSubImageTileSource.h
+++ b/include/ossim/imaging/ossimSubImageTileSource.h
@@ -3,7 +3,7 @@
 //
 // Copyright (C) 2001 ImageLinks, Inc.
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimTiffOverviewBuilder.h b/include/ossim/imaging/ossimTiffOverviewBuilder.h
index 4c3179d..1a14c95 100644
--- a/include/ossim/imaging/ossimTiffOverviewBuilder.h
+++ b/include/ossim/imaging/ossimTiffOverviewBuilder.h
@@ -1,6 +1,6 @@
 //*******************************************************************
 //
-// License:  LGPL
+// License:  MIT
 //
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimTiffTileSource.h b/include/ossim/imaging/ossimTiffTileSource.h
index 3fc96e7..930edf9 100644
--- a/include/ossim/imaging/ossimTiffTileSource.h
+++ b/include/ossim/imaging/ossimTiffTileSource.h
@@ -22,7 +22,7 @@
 #include <ossim/base/ossimIrect.h>
 #include <vector>
 #include <ossim/base/ossimStreamFactoryRegistry.h>
-
+#include <ossim/support_data/TiffStreamAdaptor.h>
 /*
  * TIFF is defined as an incomplete type to hide the tiff library's internal
  * data structures from clients.
@@ -56,7 +56,7 @@ public:
     *  Returns true if the image_file can be opened and is a valid tiff file.
     */
    virtual bool open(const ossimFilename& image_file);
-
+   
    /**
     *  @brief This open takes a stream and stores/captures the shared pointer
     *  on success.
@@ -375,7 +375,8 @@ private:
    ossim_uint32              theCurrentTiffRlevel;
    ossim_int32               theCompressionType;
    std::vector<ossim_uint32> theOutputBandList;
-   shared_ptr<TiffStreamAdaptor> m_streamAdaptor;
+   std::shared_ptr<ossim::TiffIStreamAdaptor> m_streamAdaptor;
+
 TYPE_DATA
 };
 
diff --git a/include/ossim/imaging/ossimTileCache.h b/include/ossim/imaging/ossimTileCache.h
index e6f1c64..43b1227 100644
--- a/include/ossim/imaging/ossimTileCache.h
+++ b/include/ossim/imaging/ossimTileCache.h
@@ -1,6 +1,6 @@
 //*******************************************************************
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 // License:  See top level LICENSE.txt file.
diff --git a/include/ossim/imaging/ossimTilePatch.h b/include/ossim/imaging/ossimTilePatch.h
index 4f6203e..205aa2a 100644
--- a/include/ossim/imaging/ossimTilePatch.h
+++ b/include/ossim/imaging/ossimTilePatch.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc.
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimTiledImageHandler.h b/include/ossim/imaging/ossimTiledImageHandler.h
index f86d5a2..0a4ab2f 100644
--- a/include/ossim/imaging/ossimTiledImageHandler.h
+++ b/include/ossim/imaging/ossimTiledImageHandler.h
@@ -1,6 +1,6 @@
 //**************************************************************************************************
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimTiling.h b/include/ossim/imaging/ossimTiling.h
index 21acd77..f6551f0 100644
--- a/include/ossim/imaging/ossimTiling.h
+++ b/include/ossim/imaging/ossimTiling.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2004 Garrett Potts
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimTilingPoly.h b/include/ossim/imaging/ossimTilingPoly.h
index 295ca53..227f6de 100644
--- a/include/ossim/imaging/ossimTilingPoly.h
+++ b/include/ossim/imaging/ossimTilingPoly.h
@@ -1,6 +1,6 @@
 //*******************************************************************
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimTilingRect.h b/include/ossim/imaging/ossimTilingRect.h
index 9e451c9..d3d618a 100644
--- a/include/ossim/imaging/ossimTilingRect.h
+++ b/include/ossim/imaging/ossimTilingRect.h
@@ -1,6 +1,6 @@
 //*******************************************************************
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimTopographicCorrectionFilter.h b/include/ossim/imaging/ossimTopographicCorrectionFilter.h
index f137139..546ae39 100644
--- a/include/ossim/imaging/ossimTopographicCorrectionFilter.h
+++ b/include/ossim/imaging/ossimTopographicCorrectionFilter.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc. 
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimTrimFilter.h b/include/ossim/imaging/ossimTrimFilter.h
index 2cf239f..2db6c77 100644
--- a/include/ossim/imaging/ossimTrimFilter.h
+++ b/include/ossim/imaging/ossimTrimFilter.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc. 
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimTwoColorView.h b/include/ossim/imaging/ossimTwoColorView.h
index 5049369..182bff3 100644
--- a/include/ossim/imaging/ossimTwoColorView.h
+++ b/include/ossim/imaging/ossimTwoColorView.h
@@ -1,5 +1,5 @@
 //-------------------------------------------------------------------
-// License:  LGPL.  See top level LICENSE.txt file.
+// License:  MIT.  See top level LICENSE.txt file.
 //
 // Author:  Garrett Potts
 //
diff --git a/include/ossim/imaging/ossimU11ImageData.h b/include/ossim/imaging/ossimU11ImageData.h
index 0e1035d..fd50297 100644
--- a/include/ossim/imaging/ossimU11ImageData.h
+++ b/include/ossim/imaging/ossimU11ImageData.h
@@ -1,6 +1,6 @@
 //*******************************************************************
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimU12ImageData.h b/include/ossim/imaging/ossimU12ImageData.h
index 8d0e877..895cab2 100644
--- a/include/ossim/imaging/ossimU12ImageData.h
+++ b/include/ossim/imaging/ossimU12ImageData.h
@@ -1,6 +1,6 @@
 //*******************************************************************
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimU13ImageData.h b/include/ossim/imaging/ossimU13ImageData.h
index f7594bc..e91fdea 100644
--- a/include/ossim/imaging/ossimU13ImageData.h
+++ b/include/ossim/imaging/ossimU13ImageData.h
@@ -1,6 +1,6 @@
 //*******************************************************************
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimU14ImageData.h b/include/ossim/imaging/ossimU14ImageData.h
index f551104..b76f703 100644
--- a/include/ossim/imaging/ossimU14ImageData.h
+++ b/include/ossim/imaging/ossimU14ImageData.h
@@ -1,6 +1,6 @@
 //*******************************************************************
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimU15ImageData.h b/include/ossim/imaging/ossimU15ImageData.h
index 5bddbb1..c87d8a8 100644
--- a/include/ossim/imaging/ossimU15ImageData.h
+++ b/include/ossim/imaging/ossimU15ImageData.h
@@ -1,6 +1,6 @@
 //*******************************************************************
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimU16ImageData.h b/include/ossim/imaging/ossimU16ImageData.h
index e1926df..c70aefd 100644
--- a/include/ossim/imaging/ossimU16ImageData.h
+++ b/include/ossim/imaging/ossimU16ImageData.h
@@ -1,6 +1,6 @@
 //*******************************************************************
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimU8ImageData.h b/include/ossim/imaging/ossimU8ImageData.h
index 70487be..7d3f761 100644
--- a/include/ossim/imaging/ossimU8ImageData.h
+++ b/include/ossim/imaging/ossimU8ImageData.h
@@ -1,6 +1,6 @@
 //*******************************************************************
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimUsgsDemTileSource.h b/include/ossim/imaging/ossimUsgsDemTileSource.h
index 7b19497..672335e 100644
--- a/include/ossim/imaging/ossimUsgsDemTileSource.h
+++ b/include/ossim/imaging/ossimUsgsDemTileSource.h
@@ -1,6 +1,6 @@
 //*******************************************************************
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimValueAssignImageSourceFilter.h b/include/ossim/imaging/ossimValueAssignImageSourceFilter.h
index 40dda54..e6bae84 100644
--- a/include/ossim/imaging/ossimValueAssignImageSourceFilter.h
+++ b/include/ossim/imaging/ossimValueAssignImageSourceFilter.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc. 
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimVpfAnnotationCoverageInfo.h b/include/ossim/imaging/ossimVpfAnnotationCoverageInfo.h
index 074f01d..60643cf 100644
--- a/include/ossim/imaging/ossimVpfAnnotationCoverageInfo.h
+++ b/include/ossim/imaging/ossimVpfAnnotationCoverageInfo.h
@@ -1,7 +1,7 @@
 //*************************************************************************
 // Copyright (C) 2004 Intelligence Data Systems, Inc.  All rights reserved.
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimVpfAnnotationFeatureInfo.h b/include/ossim/imaging/ossimVpfAnnotationFeatureInfo.h
index 6833c32..5b1f0ec 100644
--- a/include/ossim/imaging/ossimVpfAnnotationFeatureInfo.h
+++ b/include/ossim/imaging/ossimVpfAnnotationFeatureInfo.h
@@ -1,6 +1,6 @@
 //*******************************************************************
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimVpfTileSource.h b/include/ossim/imaging/ossimVpfTileSource.h
index 23988dd..8f7057c 100644
--- a/include/ossim/imaging/ossimVpfTileSource.h
+++ b/include/ossim/imaging/ossimVpfTileSource.h
@@ -1,7 +1,7 @@
 //----------------------------------------------------------------------------
 // Copyright (C) 2004 Garrett Potts, all rights reserved.
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/imaging/ossimWatermarkFilter.h b/include/ossim/imaging/ossimWatermarkFilter.h
index 8f7bdf4..ed86050 100644
--- a/include/ossim/imaging/ossimWatermarkFilter.h
+++ b/include/ossim/imaging/ossimWatermarkFilter.h
@@ -1,7 +1,7 @@
 //----------------------------------------------------------------------------
 // Copyright (c) 2005, David Burken, all rights reserved.
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/parallel/ossimIgen.h b/include/ossim/parallel/ossimIgen.h
index b25cc19..47bc0c7 100644
--- a/include/ossim/parallel/ossimIgen.h
+++ b/include/ossim/parallel/ossimIgen.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc. 
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/parallel/ossimImageChainMtAdaptor.h b/include/ossim/parallel/ossimImageChainMtAdaptor.h
index df78dea..5ff6f57 100644
--- a/include/ossim/parallel/ossimImageChainMtAdaptor.h
+++ b/include/ossim/parallel/ossimImageChainMtAdaptor.h
@@ -1,7 +1,7 @@
 //*************************************************************************************************
 //                                            OSSIM
 //
-// License:  LGPL -- See LICENSE.txt file in the top level directory for more details.
+// License:  MIT -- See LICENSE.txt file in the top level directory for more details.
 //
 // Author: Oscar Kramer
 //
diff --git a/include/ossim/parallel/ossimImageHandlerMtAdaptor.h b/include/ossim/parallel/ossimImageHandlerMtAdaptor.h
index bbab136..6589dcd 100644
--- a/include/ossim/parallel/ossimImageHandlerMtAdaptor.h
+++ b/include/ossim/parallel/ossimImageHandlerMtAdaptor.h
@@ -12,8 +12,7 @@
 
 #include <ossim/imaging/ossimImageHandler.h>
 #include <ossim/imaging/ossimCacheTileSource.h>
-#include <OpenThreads/Thread>
-
+#include <mutex>
 //**************************************************************************************************
 //! Intended mainly to provide a mechanism for mutex-locking access to a shared resource during
 //! a getTile operation on an ossimImageHandler. This is needed for multi-threaded implementation.
@@ -83,7 +82,7 @@ protected:
 
    ossimRefPtr<ossimImageHandler>    m_adaptedHandler;
    ossimRefPtr<ossimCacheTileSource> m_cache;
-   mutable OpenThreads::Mutex        m_mutex;   
+   mutable std::mutex                m_mutex;   
 
    bool                        d_useCache;
    bool                        d_useFauxTile;
diff --git a/include/ossim/parallel/ossimImageMpiMWriterSequenceConnection.h b/include/ossim/parallel/ossimImageMpiMWriterSequenceConnection.h
index 52bcc21..5fdd5fc 100644
--- a/include/ossim/parallel/ossimImageMpiMWriterSequenceConnection.h
+++ b/include/ossim/parallel/ossimImageMpiMWriterSequenceConnection.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc.
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/parallel/ossimImageMpiSWriterSequenceConnection.h b/include/ossim/parallel/ossimImageMpiSWriterSequenceConnection.h
index f15f84d..d353d05 100644
--- a/include/ossim/parallel/ossimImageMpiSWriterSequenceConnection.h
+++ b/include/ossim/parallel/ossimImageMpiSWriterSequenceConnection.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc.
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/parallel/ossimJob.h b/include/ossim/parallel/ossimJob.h
index 370fc33..e5e99d2 100644
--- a/include/ossim/parallel/ossimJob.h
+++ b/include/ossim/parallel/ossimJob.h
@@ -8,54 +8,148 @@
 #ifndef ossimJob_HEADER
 #define ossimJob_HEADER
 #include <ossim/base/ossimObject.h>
-#include <OpenThreads/Mutex>
-#include <OpenThreads/ScopedLock>
-#include <ossim/base/ossimRefPtr.h>
 #include <ossim/base/ossimString.h>
 #include <list>
-
+#include <mutex>
+#include <memory>
 class ossimJob;
 
-//*************************************************************************************************
-//! Generic callback class needed by ossimJob
-//*************************************************************************************************
-class OSSIM_DLL ossimJobCallback : public ossimReferenced
+/**
+* This is the job callback interface
+* It allows one to attach and listen for different states of the job
+* and if properties have changed
+*
+* @code
+* #include <ossim/base/Thread.h>
+* #include <ossim/parallel/ossimJob.h>
+* // Put your includes here:
+* 
+* // System includes:
+* #include <memory>
+* #include <iostream>
+* 
+* class TestJob : public ossimJob
+* {
+* public:
+*    TestJob(){}
+* protected:
+*    virtual void run()
+*    {
+*       std:cout << "Running Job\n";
+*       ossim::Thread::sleepInSeconds(2);
+*       std::cout << "Finished Running Job\n";
+*    }
+* };
+* class MyCallback : public ossimJobCallback
+* {
+* public:
+*    MyCallback(){}
+*    virtual void started(std::shared_ptr<ossimJob> job)  
+*    {
+*       std::cout << "Started job\n";
+*       ossimJobCallback::started(job);
+*    }
+*    virtual void finished(std::shared_ptr<ossimJob> job) 
+*    {
+*       std::cout << "Finished job\n";
+*       ossimJobCallback::finished(job);
+*    }
+* };
+* int main(int argc, char *argv[])
+* {
+*    std::shared_ptr<TestJob> job = std::make_shared<TestJob>();
+*    job->setCallback(std::make_shared<MyCallback>());
+*    job->start();
+*
+*    return 0;
+* }
+* @endcode
+*/
+class OSSIM_DLL ossimJobCallback
 {
 public:
-   ossimJobCallback(ossimJobCallback* nextCallback=0):m_nextCallback(nextCallback){}
+   ossimJobCallback(std::shared_ptr<ossimJobCallback> nextCallback=0):m_nextCallback(nextCallback){}
 
-   virtual void ready(ossimJob* job)    {if(m_nextCallback.valid()) m_nextCallback->ready(job);   }
-   virtual void started(ossimJob* job)  {if(m_nextCallback.valid()) m_nextCallback->started(job); }
-   virtual void finished(ossimJob* job) {if(m_nextCallback.valid()) m_nextCallback->finished(job);}
-   virtual void canceled(ossimJob* job) {if(m_nextCallback.valid()) m_nextCallback->canceled(job);}
+   virtual void ready(std::shared_ptr<ossimJob> job)    {if(m_nextCallback) m_nextCallback->ready(job);   }
+   virtual void started(std::shared_ptr<ossimJob> job)  {if(m_nextCallback) m_nextCallback->started(job); }
+   virtual void finished(std::shared_ptr<ossimJob> job) {if(m_nextCallback) m_nextCallback->finished(job);}
+   virtual void canceled(std::shared_ptr<ossimJob> job) {if(m_nextCallback) m_nextCallback->canceled(job);}
 
-   virtual void nameChanged(const ossimString& name, ossimJob* job)
-   {if(m_nextCallback.valid()) m_nextCallback->nameChanged(name, job);}
+   virtual void nameChanged(const ossimString& name, std::shared_ptr<ossimJob> job)
+   {if(m_nextCallback) m_nextCallback->nameChanged(name, job);}
    
-   virtual void descriptionChanged(const ossimString& description, ossimJob* job)
-   {if(m_nextCallback.valid()) m_nextCallback->descriptionChanged(description, job);}
+   virtual void descriptionChanged(const ossimString& description, std::shared_ptr<ossimJob> job)
+   {if(m_nextCallback) m_nextCallback->descriptionChanged(description, job);}
 
-   virtual void idChanged(const ossimString& id, ossimJob* job)
-   {if(m_nextCallback.valid()) m_nextCallback->idChanged(id, job);}
+   virtual void idChanged(const ossimString& id, std::shared_ptr<ossimJob> job)
+   {if(m_nextCallback) m_nextCallback->idChanged(id, job);}
 
-   virtual void percentCompleteChanged(double percentValue, ossimJob* job)
-   {if(m_nextCallback.valid()) m_nextCallback->percentCompleteChanged(percentValue, job);}
+   virtual void percentCompleteChanged(double percentValue, std::shared_ptr<ossimJob> job)
+   {if(m_nextCallback) m_nextCallback->percentCompleteChanged(percentValue, job);}
 
-   void setCallback(ossimJobCallback* c){m_nextCallback = c;}
-   ossimJobCallback* callback(){return m_nextCallback.get();}
+   void setCallback(std::shared_ptr<ossimJobCallback> c){m_nextCallback = c;}
+   std::shared_ptr<ossimJobCallback> callback(){return m_nextCallback;}
 
 protected:
-   ossimRefPtr<ossimJobCallback> m_nextCallback;
+   std::shared_ptr<ossimJobCallback> m_nextCallback;
 };
 
 
-//*************************************************************************************************
-//! Pure virtual base class for all job types
-//*************************************************************************************************
-class OSSIM_DLL ossimJob : public ossimObject
+/**
+* This is the job callback interface
+* It allows one to attach and listen for different states of the job
+* and if properties have changed
+*
+* @code
+* #include <ossim/base/Thread.h>
+* #include <ossim/parallel/ossimJob.h>
+* // Put your includes here:
+* 
+* // System includes:
+* #include <memory>
+* #include <iostream>
+* 
+* class TestJob : public ossimJob
+* {
+* public:
+*    TestJob(){}
+* protected:
+*    virtual void run()
+*    {
+*       std:cout << "Running Job\n";
+*       ossim::Thread::sleepInSeconds(2);
+*       std::cout << "Finished Running Job\n";
+*    }
+* };
+* class MyCallback : public ossimJobCallback
+* {
+* public:
+*    MyCallback(){}
+*    virtual void started(std::shared_ptr<ossimJob> job)  
+*    {
+*       std::cout << "Started job\n";
+*       ossimJobCallback::started(job);
+*    }
+*    virtual void finished(std::shared_ptr<ossimJob> job) 
+*    {
+*       std::cout << "Finished job\n";
+*       ossimJobCallback::finished(job);
+*    }
+* };
+* int main(int argc, char *argv[])
+* {
+*    std::shared_ptr<TestJob> job = std::make_shared<TestJob>();
+*    job->setCallback(std::make_shared<MyCallback>());
+*    job->start();
+*
+*    return 0;
+* }
+* @endcode
+*/
+class OSSIM_DLL ossimJob : public std::enable_shared_from_this<ossimJob>
 {
 public:
-   typedef std::list<ossimRefPtr<ossimJob> > List;
+   typedef std::list<std::shared_ptr<ossimJob> > List;
 
    /** 
    * This is a Bit vector.  The only value that can be assigned as both active is FINISHED and CANCEL.
@@ -73,36 +167,89 @@ public:
    
    ossimJob() : m_state(ossimJob_READY),  m_priority(0.0) {}
 
-   virtual void start()=0;
-   
+   /**
+   * Main entry point to the job.  It will set the state as running and then
+   * call the pure virtual method run. Once completed the job is marked finished
+   * only if the job was not canceled.
+   *
+   * Classes must override the run method.  @see run.
+   */
+   virtual void start();
+
+   /**
+   * This is a convenience method to get the shared representation 
+   * of this pointer
+   *
+   * @return the shared pointer
+   */
+   std::shared_ptr<ossimJob> getSharedFromThis(){
+      return shared_from_this();
+   }
+
+   /**
+   * This is a convenience method to get the shared representation 
+   * of this pointer
+   *
+   * @return the shared pointer
+   */
+   std::shared_ptr<const ossimJob> getSharedFromThis()const{
+      return shared_from_this();
+   }
+
+   /**
+   * When the pernet complete is set for the job it will call any callbacks 
+   * and nofity percentCompleteChanged.
+   *
+   * @value percent complete
+   */   
    void setPercentComplete(double value)
    {
-      OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_jobMutex);
-      if(m_callback.valid())
+      std::lock_guard<std::mutex> lock(m_jobMutex);
+      if(m_callback)
       {
-         m_callback->percentCompleteChanged(value, this);
+         m_callback->percentCompleteChanged(value, getSharedFromThis());
       }
    }
 
+   /**
+   * sets the priority of the job
+   *
+   * @param value priority value
+   */
    void setPriority(double value)
    {
-      OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_jobMutex);
+      std::lock_guard<std::mutex> lock(m_jobMutex);
       m_priority = value;
    }
 
+   /*
+   * @return the priotiy of the job
+   */
    double priority()const
    {
       return m_priority;
    }
 
+   /**
+   * If derived interfaces implement a block this will allow one to release.
+   * Derived classes must override.
+   */
    virtual void release(){}
 
+   /**
+   * @return the state of the object
+   */
    State state()const
    {
-      OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_jobMutex);
+      std::lock_guard<std::mutex> lock(m_jobMutex);
       return m_state;
    }
 
+   /**
+   * Will clear out the state and the call setState
+   *
+   * @param value is the state you wish to reset to
+   */
    virtual void resetState(int value)
    {
       m_jobMutex.lock();
@@ -119,36 +266,59 @@ public:
 
    }
 
+   /**
+   * Will allow you to set the state of the job
+   *
+   * @param value is the state you wish to set to
+   * @param on will turn the value on if on is true
+   *        and turn it off otherwise.
+   */
    virtual void setState(int value, bool on=true);
 
+   /**
+   * @return true if the job is in a cancel state and false
+   *         otherwise
+   */
    bool isCanceled()const
    {
-      OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_jobMutex);
+      std::lock_guard<std::mutex> lock(m_jobMutex);
       return (m_state & ossimJob_CANCEL);
    }
 
+   /**
+   * Sets the state if the object as cancelled
+   */
    virtual void cancel()
    {
       // append the cancel flag to current state
       setState(ossimJob_CANCEL);
    }
 
+   /**
+   * Sets the state if the object as ready
+   */
    virtual void ready()
    {
       resetState(ossimJob_READY);
    }
 
+   /**
+   * Sets the state if the object as running
+   */
    virtual void running()
    {
       resetState(ossimJob_RUNNING);
    }
 
+   /**
+   * Sets the state if the object as finished
+   */
    virtual void finished()
    {
       int newState = 0;
       {
          // maintain the cancel flag so we can indicate the job has now finished
-         OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_jobMutex);
+         std::lock_guard<std::mutex> lock(m_jobMutex);
          newState = ((m_state & ossimJob_CANCEL) | 
             (ossimJob_FINISHED));
       }
@@ -156,111 +326,158 @@ public:
       resetState(newState);
    }
 
+   /**
+   * @return true if the state of the object is in a ready state.
+   */
    bool isReady()const
    {
-      OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_jobMutex);
+      std::lock_guard<std::mutex> lock(m_jobMutex);
       return m_state & ossimJob_READY;
    }
 
+   /**
+   * @return true if the state of the object is in some kind of stopped state.
+   */
    bool isStopped()const
    {
-      OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_jobMutex);
+      std::lock_guard<std::mutex> lock(m_jobMutex);
       return (m_state & ossimJob_FINISHED);
    }
 
+   /**
+   * @return true if the state of the object is in a finished state.
+   */
    bool isFinished()const
    {
-      OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_jobMutex);
+      std::lock_guard<std::mutex> lock(m_jobMutex);
       return (m_state & ossimJob_FINISHED);
    }
 
+   /**
+   * @return true if the state of the object is in a running state.
+   */
    bool isRunning()const
    {
-      OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_jobMutex);
+      std::lock_guard<std::mutex> lock(m_jobMutex);
       return (m_state & ossimJob_RUNNING);
    }
 
-   void setCallback(ossimJobCallback* callback)
+   /**
+   * @param callback callback used to call different state of a job
+   */
+   void setCallback(std::shared_ptr<ossimJobCallback> callback)
    {
-      OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_jobMutex);
+      std::lock_guard<std::mutex> lock(m_jobMutex);
       m_callback = callback;
    }
 
+   /**
+   * Sets the name of a job
+   *
+   * @param value the name of the job
+   */
    void setName(const ossimString& value)
    {
       bool changed = false;
-      ossimRefPtr<ossimJobCallback> callback;
+      std::shared_ptr<ossimJobCallback> callback;
       {
-         OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_jobMutex);
+         std::lock_guard<std::mutex> lock(m_jobMutex);
          changed = value!=m_name;
          m_name = value;
          callback = m_callback;
       }
-      if(changed&&callback.valid())
+      if(changed&&callback)
       {
-         callback->nameChanged(value, this);
+         callback->nameChanged(value, getSharedFromThis());
       }
    }
 
+   /**
+   * @return the name of the job
+   */
    const ossimString& name()const
    {
-      OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_jobMutex);
+      std::lock_guard<std::mutex> lock(m_jobMutex);
       return m_name;
    }
 
+   /*
+   * sets the ID
+   *
+   * @param value the id to set the job to
+   */
    void setId(const ossimString& value)
    {
       bool changed = false;
-      ossimRefPtr<ossimJobCallback> callback;
+      std::shared_ptr<ossimJobCallback> callback;
       {
-         OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_jobMutex);
+         std::lock_guard<std::mutex> lock(m_jobMutex);
          changed = value!=m_id;
          m_id = value;
          callback = m_callback;
       }
-      if(changed&&callback.valid())
+      if(changed&&callback)
       {
-         callback->idChanged(value, this);
+         callback->idChanged(value, getSharedFromThis());
       }
    }
 
+   /*
+   * @return id of the job
+   */
    const ossimString& id()const
    {
-      OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_jobMutex);
+      std::lock_guard<std::mutex> lock(m_jobMutex);
       return m_id;
    }
 
+   /*
+   * @param value the description to set on the job
+   */
    void setDescription(const ossimString& value)
    {
       bool changed = false;
-      ossimRefPtr<ossimJobCallback> callback;
+      std::shared_ptr<ossimJobCallback> callback;
       {
-         OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_jobMutex);
+         std::lock_guard<std::mutex> lock(m_jobMutex);
          changed = value!=m_description;
          m_description = value;
          callback = m_callback;
       }
-      if(changed&&callback.valid())
+      if(changed&&callback)
       {
-         callback->descriptionChanged(value, this);
+         callback->descriptionChanged(value, getSharedFromThis());
       }
    }
 
+   /**
+   * @return the desciption of the job
+   */
    const ossimString& description()const
    {
-      OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_jobMutex);
+      std::lock_guard<std::mutex> lock(m_jobMutex);
       return m_description;
    }
-   ossimJobCallback* callback() {return m_callback.get();}
+
+   /**
+   * @return the callback
+   */
+   std::shared_ptr<ossimJobCallback> callback() {return m_callback;}
 
 protected:
-   mutable OpenThreads::Mutex m_jobMutex;
+   mutable std::mutex m_jobMutex;
    ossimString m_name;
    ossimString m_description;
    ossimString m_id;
    State       m_state;
    double      m_priority;
-   ossimRefPtr<ossimJobCallback> m_callback;
+   std::shared_ptr<ossimJobCallback> m_callback;
+
+   /**
+   * Abstract method and must be overriden by the base class.  The base ossimJob
+   * will call run from the start method after setting some variables.
+   */
+   virtual void run()=0;
 };
 
 #endif
diff --git a/include/ossim/parallel/ossimJobMultiThreadQueue.h b/include/ossim/parallel/ossimJobMultiThreadQueue.h
index 43c08d0..434d166 100644
--- a/include/ossim/parallel/ossimJobMultiThreadQueue.h
+++ b/include/ossim/parallel/ossimJobMultiThreadQueue.h
@@ -1,27 +1,144 @@
 #ifndef ossimJobMultiThreadQueue_HEADER
 #define ossimJobMultiThreadQueue_HEADER
 #include <ossim/parallel/ossimJobThreadQueue.h>
+#include <mutex>
 
-class OSSIM_DLL ossimJobMultiThreadQueue : public ossimReferenced
+/**
+* This allocates a thread pool used to listen on a shared job queue
+*
+* @code
+* #include <ossim/base/Thread.h>
+* #include <ossim/parallel/ossimJob.h>
+* #include <ossim/parallel/ossimJobMultiThreadQueue.h>
+* #include <ossim/parallel/ossimJobQueue.h>
+* #include <memory>
+* #include <iostream>
+* 
+* class TestJob : public ossimJob
+* {
+* public:
+*    TestJob(){}
+* protected:
+*    virtual void run()
+*    {
+*       ossim::Thread::sleepInSeconds(2);
+*    }
+* };
+* class MyCallback : public ossimJobCallback
+* {
+* public:
+*    MyCallback(){}
+*    virtual void started(std::shared_ptr<ossimJob> job)  
+*    {
+*       std::cout << "Started job\n";
+*       ossimJobCallback::started(job);
+*    }
+*    virtual void finished(std::shared_ptr<ossimJob> job) 
+*    {
+*       std::cout << "Finished job\n";
+*       ossimJobCallback::finished(job);
+*    }
+* };
+* 
+* int main(int argc, char *argv[])
+* {
+*    int nThreads = 5;
+*    int nJobs = 10;
+*    std::shared_ptr<ossimJobQueue> jobQueue = std::make_shared<ossimJobQueue>();
+*    std::shared_ptr<ossimJobMultiThreadQueue> jobThreadQueue = std::make_shared<ossimJobMultiThreadQueue>(jobQueue, nThreads);
+*    for(int i = 0; i < nJobs; ++i)
+*    {
+*       std::shared_ptr<TestJob> job = std::make_shared<TestJob>();
+*       job->setCallback(std::make_shared<MyCallback>());
+*       jobQueue->add(job);
+*    }
+* 
+*    while(jobThreadQueue->hasJobsToProcess())
+*    {
+*       ossim::Thread::sleepInMilliSeconds(10);
+*    }
+* 
+*    std::cout << "Finished and cancelling thread queue\n";
+*    jobThreadQueue->cancel();
+*    jobThreadQueue->waitForCompletion();
+* 
+*    return 0;
+* }
+* @endcode
+*/
+class OSSIM_DLL ossimJobMultiThreadQueue
 {
 public:
-   typedef std::vector<ossimRefPtr<ossimJobThreadQueue> > ThreadQueueList;
+   typedef std::vector<std::shared_ptr<ossimJobThreadQueue> > ThreadQueueList;
    
-   ossimJobMultiThreadQueue(ossimJobQueue* q=0, ossim_uint32 nThreads=0);
-   ossimJobQueue* getJobQueue();
-   const ossimJobQueue* getJobQueue()const;
-   void setQueue(ossimJobQueue* q);
+   /**
+   * allows one to create a pool of threads with a shared job queue
+   */
+   ossimJobMultiThreadQueue(std::shared_ptr<ossimJobQueue> q=0, 
+                            ossim_uint32 nThreads=0);
+   /**
+   * Will cancel all threads and wait for completion and clear the thread queue
+   * list
+   */
+   virtual ~ossimJobMultiThreadQueue();
+
+   /**
+   * @return the job queue
+   */
+   std::shared_ptr<ossimJobQueue> getJobQueue();
+
+   /**
+   * @return the job queue
+   */
+   const std::shared_ptr<ossimJobQueue> getJobQueue()const;
+
+   /**
+   * set the job queue to all threads
+   *
+   * @param q the job queue to set
+   */
+   void setJobQueue(std::shared_ptr<ossimJobQueue> q);
+
+   /**
+   * Will set the number of threads
+   */
    void setNumberOfThreads(ossim_uint32 nThreads);
+
+   /**
+   * @return the number of threads
+   */
    ossim_uint32 getNumberOfThreads() const;
+
+   /**
+   * @return the number of threads that are busy
+   */
    ossim_uint32 numberOfBusyThreads()const;
+
+   /**
+   * @return true if all threads are busy and false otherwise
+   */
    bool areAllThreadsBusy()const;
-   
+
+   /**
+   * @return true if it has jobs that it's processing
+   */
    bool hasJobsToProcess()const;
 
+   /**
+   * Allows one to cancel all threads
+   */
+   void cancel();
+
+   /**
+   * Allows on to wait for all thread completions.  Usually called after
+   * @see cancel
+   */
+   void waitForCompletion();
+
 protected:
-   mutable OpenThreads::Mutex  m_mutex;
-   ossimRefPtr<ossimJobQueue> m_jobQueue;
-   ThreadQueueList m_threadQueueList;
+   mutable std::mutex             m_mutex;
+   std::shared_ptr<ossimJobQueue> m_jobQueue;
+   ThreadQueueList                m_threadQueueList;
 };
 
 #endif
diff --git a/include/ossim/parallel/ossimJobQueue.h b/include/ossim/parallel/ossimJobQueue.h
index 4a9c4b4..e930714 100644
--- a/include/ossim/parallel/ossimJobQueue.h
+++ b/include/ossim/parallel/ossimJobQueue.h
@@ -9,50 +9,264 @@
 #define ossimJobQueue_HEADER
 
 #include <ossim/parallel/ossimJob.h>
-#include <OpenThreads/Block>
+#include <ossim/base/Block.h>
+#include <mutex>
+#include <memory>
 
-//*************************************************************************************************
-//! Class for maintaining an ordered list of jobs to be processed. As the jobs are completed and
-//! the product consumed, the jobs are removed from this list
-//*************************************************************************************************
-class OSSIM_DLL ossimJobQueue : public ossimReferenced
+/**
+* This is the base implementation for the job queue.  It allows one to add and remove
+* jobs and to call the nextJob and, if specified, block the call if no jobs are on
+* the queue.  we derived from std::enable_shared_from_this which allows us access to 
+* a safe shared 'this' pointer.  This is used internal to our callbacks.
+*
+* The job queue is thread safe and can be shared by multiple threads.
+*
+* Here is a quick code example on how to create a shared queue and to attach
+* a thread to it.  In this example we do not block the calling thread for nextJob
+* @code
+* #include <ossim/base/Thread.h>
+* #include <ossim/parallel/ossimJob.h>
+* #include <ossim/parallel/ossimJobQueue.h>
+* #include <iostream>
+* class TestJobQueueThread : public ossim::Thread
+* {
+* public:
+*    TestJobQueueThread(std::shared_ptr<ossimJobQueue> q):m_q(q){}
+*    void run()
+*    {
+*       if(m_q)
+*       {
+*          while(true)
+*          {
+*             interrupt();
+*             std::shared_ptr<ossimJob> job = m_q->nextJob(false);
+*             if(job)
+*             {
+*                job->start();
+*             }
+*             yieldCurrentThread();
+*             sleepInMilliSeconds(20);
+*          }
+*       }
+*    }
+* 
+* private:
+*   std::shared_ptr<ossimJobQueue> m_q;
+* };
+* 
+* class TestJob : public ossimJob
+* {
+* public:
+*    virtual void run()
+*    {
+*       std:cout << "Running Job\n";
+*       ossim::Thread::sleepInSeconds(2);
+*       std::cout << "Finished Running Job\n";
+*    }
+* };
+* int main(int argc, char *argv[])
+* {
+*    std::shared_ptr<ossimJobQueue> q = std::make_shared<ossimJobQueue>();
+*    std::shared_ptr<TestJobQueueThread> jobQueueThread = std::make_shared<TestJobQueueThread>(q);
+* 
+*    jobQueueThread->start();
+* 
+*    q->add(std::make_shared<TestJob>());
+*    q->add(std::make_shared<TestJob>());
+*    q->add(std::make_shared<TestJob>());
+* 
+*    ossim::Thread::sleepInSeconds(10);
+*    jobQueueThread->cancel();
+*    jobQueueThread->waitForCompletion();
+* }
+* @endcode
+*/
+class OSSIM_DLL ossimJobQueue : public std::enable_shared_from_this<ossimJobQueue>
 {
 public:
-   class OSSIM_DLL Callback : public ossimReferenced
+   /**
+   * The callback allows one to attach and listen for certain things.  In 
+   * the ossimJobQueue it will notify just before adding a job, after adding a job
+   * and if a job is removed.
+   */
+   class OSSIM_DLL Callback
    {
    public:
       Callback(){}
-      virtual void adding(ossimJobQueue* /*q*/, ossimJob* /*job*/){}
-      virtual void added(ossimJobQueue* /*q*/, ossimJob* /*job*/){}
-      virtual void removed(ossimJobQueue* /*q*/, ossimJob* /*job*/){}
-   protected:
+
+      /**
+      * Called just before a job is added
+      * 
+      * @param q Is a shared_ptr to 'this' job queue
+      * @param job Is a shared ptr to the job we are adding
+      */
+      virtual void adding(std::shared_ptr<ossimJobQueue> /*q*/, 
+                          std::shared_ptr<ossimJob> /*job*/){};
+
+      /**
+      * Called after a job is added to the queue
+      * @param q Is a shared_ptr to 'this' job queue
+      * @param job Is a shared ptr to the job we are added     
+      */
+      virtual void added(std::shared_ptr<ossimJobQueue> /*q*/, 
+                         std::shared_ptr<ossimJob> /*job*/){}
+
+
+      /**
+      * Called after a job is removed from the queue
+      * @param q Is a shared_ptr to 'this' job queue
+      * @param job Is a shared ptr to the job we have removed
+      */
+      virtual void removed(std::shared_ptr<ossimJobQueue> /*q*/, 
+                           std::shared_ptr<ossimJob>/*job*/){}
    };
+
+   /**
+   * Default constructor
+   */
    ossimJobQueue();
+  
+   /**
+   * This is the safe way to create a std::shared_ptr for 'this'.  Calls the derived
+   * method shared_from_this
+   */  
+   std::shared_ptr<ossimJobQueue> getSharedFromThis(){
+      return shared_from_this();
+   }
+
+   /**
+   * This is the safe way to create a std::shared_ptr for 'this'.  Calls the derived
+   * method shared_from_this
+   */  
+   std::shared_ptr<const ossimJobQueue> getSharedFromThis()const{
+      return shared_from_this();
+   }
+
+   /**
+   * Will add a job to the queue and if the guaranteeUniqueFlag is set it will
+   * scan and make sure the job is not on the queue before adding
+   *
+   * @param job The job to add to the queue.
+   * @param guaranteeUniqueFlag if set to true will force a find to make sure the job
+   *        does not already exist
+   */
+   virtual void add(std::shared_ptr<ossimJob> job, bool guaranteeUniqueFlag=true);
    
-   virtual void add(ossimJob* job, bool guaranteeUniqueFlag=true);
-   virtual ossimRefPtr<ossimJob> removeByName(const ossimString& name);
-   virtual ossimRefPtr<ossimJob> removeById(const ossimString& id);
-   virtual void remove(const ossimJob* Job);
+   /**
+   * Allows one to remove a job passing in it's name.
+   *
+   * @param name The job name
+   * @return a shared_ptr to the job.  This will be nullptr if not found.
+   */
+   virtual std::shared_ptr<ossimJob> removeByName(const ossimString& name);
+
+   /**
+   * Allows one to remove a job passing in it's id.
+   *
+   * @param id The job id
+   * @return a shared_ptr to the job.  This will be nullptr if not found.
+   */
+   virtual std::shared_ptr<ossimJob> removeById(const ossimString& id);
+
+   /**
+   * Allows one to pass in a job pointer to remove
+   *
+   * @param job the job you wish to remove from the list
+   */
+   virtual void remove(const std::shared_ptr<ossimJob> Job);
+
+   /**
+   * Will remove any stopped jobs from the queue
+   */
    virtual void removeStoppedJobs();
+
+   /**
+   * Will clear the queue
+   */
    virtual void clear();
-   virtual ossimRefPtr<ossimJob> nextJob(bool blockIfEmptyFlag=true);
+
+   /**
+   * Will grab the next job on the list and will return the job or 
+   * a null shared_ptr.  You can block the caller if the queueis empty forcing it
+   * to wait for more jobs to come onto the queue
+   *
+   * @param blockIfEmptyFlag If true it will block the calling thread until more jobs appear
+   *        on the queue.  If false, it will return without blocking
+   * @return a shared pointer to a job
+   */
+   virtual std::shared_ptr<ossimJob> nextJob(bool blockIfEmptyFlag=true);
+
+   /**
+   * will release the block and have any blocked threads continue
+   */
    virtual void releaseBlock();
+
+   /**
+   * @return true if the queue is empty false otherwise
+   */
    bool isEmpty()const;
+
+   /**
+   * @return the number of jobs on the queue
+   */
    ossim_uint32 size();
-   void setCallback(Callback* c);
-   Callback* callback();
+
+   /**
+   *  Allows one to set the callback to the list
+   *
+   * @param c shared_ptr to a callback
+   */
+   void setCallback(std::shared_ptr<Callback> c);
+
+   /**
+   * @return the callback
+   */
+   std::shared_ptr<Callback> callback();
    
 protected:
+   /**
+   * Internal method that returns an iterator
+   *
+   * @param the id of the job to search for
+   * @return the iterator
+   */
    ossimJob::List::iterator findById(const ossimString& id);
+
+   /**
+   * Internal method that returns an iterator
+   *
+   * @param name the name of the job to search for
+   * @return the iterator
+   */
    ossimJob::List::iterator findByName(const ossimString& name);
-   ossimJob::List::iterator findByPointer(const ossimJob* job);
-   ossimJob::List::iterator findByNameOrPointer(const ossimJob* job);
-   bool hasJob(ossimJob* job);
+
+   /**
+   * Internal method that returns an iterator
+   *
+   * @param job the job to search for
+   * @return the iterator
+   */
+   ossimJob::List::iterator findByPointer(const std::shared_ptr<ossimJob> job);
+
+   /**
+   * Internal method that returns an iterator
+   * 
+   * @param job it will find by the name or by the pointer
+   * @return the iterator
+   */
+   ossimJob::List::iterator findByNameOrPointer(const std::shared_ptr<ossimJob> job);
+
+   /**
+   * Internal method that determines if we have the job
+   * 
+   * @param job the job you wish to search for
+   */
+   bool hasJob(std::shared_ptr<ossimJob> job);
    
-   mutable OpenThreads::Mutex m_jobQueueMutex;
-   OpenThreads::Block m_block;
+   mutable std::mutex m_jobQueueMutex;
+   ossim::Block m_block;
    ossimJob::List m_jobQueue;
-   ossimRefPtr<Callback> m_callback;
+   std::shared_ptr<Callback> m_callback;
 };
 
 #endif
diff --git a/include/ossim/parallel/ossimJobThreadQueue.h b/include/ossim/parallel/ossimJobThreadQueue.h
index 1e03dc5..adcd48c 100644
--- a/include/ossim/parallel/ossimJobThreadQueue.h
+++ b/include/ossim/parallel/ossimJobThreadQueue.h
@@ -1,47 +1,165 @@
 #ifndef ossimJobThreadQueue_HEADER
 #define ossimJobThreadQueue_HEADER
 #include <ossim/parallel/ossimJobQueue.h>
-#include <OpenThreads/Mutex>
-#include <OpenThreads/Thread>
+#include <ossim/base/Thread.h>
+#include <mutex>
 
-class OSSIM_DLL ossimJobThreadQueue : public ossimReferenced, 
-                                      public OpenThreads::Thread
+/**
+* ossimJobThreadQueue allows one to instantiate a thread with a shared
+* queue. the thread will block if the queue is empty and will continue
+* to pop jobs off the queue calling the start method on the job.  Once it
+* finishes the job it is disguarded and then the next job will be popped off the 
+* queue.
+*  
+* @code
+* class TestJob : public ossimJob
+* {
+* public:
+*    TestJob(){}
+* protected:
+*    virtual void run()
+*    {
+*       ossim::Thread::sleepInSeconds(2);
+*    }
+* };
+* class MyCallback : public ossimJobCallback
+* {
+* public:
+*    MyCallback(){}
+*    virtual void started(std::shared_ptr<ossimJob> job)  
+*    {
+*       std::cout << "Started job\n";
+*       ossimJobCallback::started(job);
+*    }
+*    virtual void finished(std::shared_ptr<ossimJob> job) 
+*    {
+*       std::cout << "Finished job\n";
+*       ossimJobCallback::finished(job);
+*    }
+* };
+* int main(int argc, char *argv[])
+* {
+*    std::shared_ptr<ossimJobQueue> jobQueue = std::make_shared<ossimJobQueue>();
+*    std::shared_ptr<ossimJobThreadQueue> jobThreadQueue = std::make_shared<ossimJobThreadQueue>(jobQueue);
+*    jobThreadQueue->start();
+*    std::shared_ptr<TestJob> job = std::make_shared<TestJob>();
+*    job->setCallback(std::make_shared<MyCallback>());
+*    jobQueue->add(job);
+*    std::cout << "Waiting 5 seconds before terminating\n";
+*    ossim::Thread::sleepInSeconds(5);
+*    jobThreadQueue->cancel();
+*    jobThreadQueue->waitForCompletion();
+* 
+*    return 0;
+* }
+* @endcode
+*/
+class OSSIM_DLL ossimJobThreadQueue : public ossim::Thread
 {
 public:
-   ossimJobThreadQueue(ossimJobQueue* jqueue=0);
-   void setJobQueue(ossimJobQueue* jqueue);
+   /**
+   * constructor that allows one to instantiat the thread with 
+   * a shared job queue.
+   *
+   * @param jqueue shared job queue
+   */
+   ossimJobThreadQueue(std::shared_ptr<ossimJobQueue> jqueue=0);
    
-   ossimJobQueue* getJobQueue();
+   /**
+   * destructor.  Will terminate the thread and stop current jobs
+   */
+   virtual ~ossimJobThreadQueue();
+
+   /**
+   *
+   * Sets the shared queue that this thread will be pulling jobs from
+   *
+   * @param jqueue the shared job queue to set
+   */
+   void setJobQueue(std::shared_ptr<ossimJobQueue> jqueue);
+   
+   /**
+   * @return the current shared job queue
+   */
+   std::shared_ptr<ossimJobQueue> getJobQueue();
    
-   const ossimJobQueue* getJobQueue() const; 
+   /**
+   * @return the current shared job queue
+   */
+   const std::shared_ptr<ossimJobQueue> getJobQueue() const; 
    
-   ossimRefPtr<ossimJob> currentJob();
+   /**
+   * @return the current job that is being handled.
+   */
+   std::shared_ptr<ossimJob> currentJob();
    
+   /**
+   * Will cancel the current job
+   */
    void cancelCurrentJob();
+
+   /**
+   * @return is the queue valid
+   */
    bool isValidQueue()const;
    
+   /**
+   * This is method is overriden from the base thread class and is
+   * the main entry point of the thread
+   */
    virtual void run();
    
+   /**
+   * Sets the done flag.
+   *
+   * @param done the value to set
+   */
    void setDone(bool done);
    
+   /**
+   * @return if the done flag is set
+   */
    bool isDone()const;
-   virtual int cancel();
+
+   /**
+   * Cancels the thread
+   */
+   virtual void cancel();
+
+   /**
+   * @return true if the queue is empty
+   *         false otherwise.
+   */
    bool isEmpty()const;
    
+   /**
+   * @return true if a job is currently being processed
+   *         false otherwise.
+   */
    bool isProcessingJob()const;
    
+   /**
+   * @return true if there are still jobs to be processed
+   *         false otherwise.
+   */
    bool hasJobsToProcess()const;
    
 protected:
-   virtual ~ossimJobThreadQueue();
-   
+   /**
+   * Internal method.  If setJobQueue is set on this thread
+   * it will auto start this thread.
+   */
    void startThreadForQueue();
-   virtual ossimRefPtr<ossimJob> nextJob();
+
+   /**
+   * Will return the next job on the queue
+   */
+   virtual std::shared_ptr<ossimJob> nextJob();
    
-   bool                       m_doneFlag;
-   mutable OpenThreads::Mutex m_threadMutex;
-   ossimRefPtr<ossimJobQueue> m_jobQueue;
-   ossimRefPtr<ossimJob>      m_currentJob;
+   bool                           m_doneFlag;
+   mutable std::mutex             m_threadMutex;
+   std::shared_ptr<ossimJobQueue> m_jobQueue;
+   std::shared_ptr<ossimJob>      m_currentJob;
    
 };
 
diff --git a/include/ossim/parallel/ossimMultiThreadSequencer.h b/include/ossim/parallel/ossimMultiThreadSequencer.h
index 379f1d5..c70f334 100644
--- a/include/ossim/parallel/ossimMultiThreadSequencer.h
+++ b/include/ossim/parallel/ossimMultiThreadSequencer.h
@@ -15,8 +15,9 @@
 #include <ossim/base/ossimConnectableObjectListener.h>
 #include <ossim/parallel/ossimJobMultiThreadQueue.h>
 #include <ossim/parallel/ossimImageChainMtAdaptor.h>
-#include <OpenThreads/Thread>
-
+#include <ossim/base/Thread.h>
+#include <ossim/base/Block.h>
+#include <mutex>
 //*************************************************************************************************
 //! This class manages the sequencing of tile requests across multiple threads. Note that multi-
 //! threading can only be achieved through the use of getNextTile() method for sequencing. 
@@ -82,8 +83,8 @@ protected:
             m_chainID(chain_id), 
             m_sequencer(sequencer),
             t_launchNewJob(true) {}
-
-      virtual void start();
+protected:
+      virtual void run();
 
    private:
       ossim_uint32                 m_tileID;
@@ -100,7 +101,7 @@ protected:
    {
    public:
       ossimGetTileCallback() {}
-      virtual void finished(ossimJob* job)
+      virtual void finished(std::shared_ptr<ossimJob> job)
       {
          if (job != NULL)
             job->finished();
@@ -124,22 +125,22 @@ protected:
    void print(ostringstream& msg) const;
 
    ossimRefPtr<ossimImageChainMtAdaptor> m_inputChain; //!< Same as base class' theInputConnection
-   ossimRefPtr<ossimJobMultiThreadQueue> m_jobMtQueue;
+   std::shared_ptr<ossimJobMultiThreadQueue> m_jobMtQueue;
    ossim_uint32                          m_numThreads;
-   ossimRefPtr<ossimGetTileCallback>     m_callback;
+   std::shared_ptr<ossimGetTileCallback> m_callback;
    ossim_uint32                          m_nextTileID; //!< ID of next tile to be threaded, different from base class' theCurrentTileNumber
    TileCache                             m_tileCache;  //!< Saves tiles output by threaded jobs
    ossim_uint32                          m_maxCacheSize;
    ossim_uint32                          m_maxTileCacheFactor;
-   mutable OpenThreads::Mutex            m_cacheMutex;   
-   mutable OpenThreads::Mutex            m_jobMutex;   
+   mutable std::mutex                    m_cacheMutex;   
+   mutable std::mutex                    m_jobMutex;   
    ossim_uint32                          m_totalNumberOfTiles;
-   OpenThreads::Block                    m_getTileBlock; //<! Blocks execution of main thread while waiting for tile to become available
-   OpenThreads::Block                    m_nextJobBlock; //<! Blocks execution of worker threads
+   ossim::Block                          m_getTileBlock; //<! Blocks execution of main thread while waiting for tile to become available
+   ossim::Block                          m_nextJobBlock; //<! Blocks execution of worker threads
 
    // FOR DEBUG:
-   mutable OpenThreads::Mutex d_printMutex;
-   mutable OpenThreads::Mutex d_timerMutex;
+   mutable std::mutex d_printMutex;
+   mutable std::mutex d_timerMutex;
    bool d_debugEnabled;
    ossim_uint32 d_timedBlocksDt;
    bool d_timeMetricsEnabled;
diff --git a/include/ossim/plugin/ossimDynamicLibrary.h b/include/ossim/plugin/ossimDynamicLibrary.h
index 6612003..e2b3313 100644
--- a/include/ossim/plugin/ossimDynamicLibrary.h
+++ b/include/ossim/plugin/ossimDynamicLibrary.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc.
 //
-// LICENSE: LGPL
+// LICENSE: MIT
 //
 // See LICENSE.txt file in the top level directory for more details.
 // 
diff --git a/include/ossim/plugin/ossimPluginConstants.h b/include/ossim/plugin/ossimPluginConstants.h
index 64e979a..abf93aa 100644
--- a/include/ossim/plugin/ossimPluginConstants.h
+++ b/include/ossim/plugin/ossimPluginConstants.h
@@ -1,7 +1,7 @@
 //----------------------------------------------------------------------------
 // Copyright (c) 2005, David Burken, all rights reserved.
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/point_cloud/ossimGenericPointCloudHandler.h b/include/ossim/point_cloud/ossimGenericPointCloudHandler.h
index 8b802da..b90c746 100644
--- a/include/ossim/point_cloud/ossimGenericPointCloudHandler.h
+++ b/include/ossim/point_cloud/ossimGenericPointCloudHandler.h
@@ -2,7 +2,7 @@
 //
 // OSSIM (http://trac.osgeo.org/ossim/)
 //
-// License:  LGPL -- See LICENSE.txt file in the top level directory for more details.
+// License:  MIT -- See LICENSE.txt file in the top level directory for more details.
 //
 //**************************************************************************************************
 // $Id: ossimGenericPointCloudHandler.h 23654 2015-12-08 19:04:09Z gpotts $
diff --git a/include/ossim/point_cloud/ossimPointBlock.h b/include/ossim/point_cloud/ossimPointBlock.h
index 54462aa..22b1f7f 100755
--- a/include/ossim/point_cloud/ossimPointBlock.h
+++ b/include/ossim/point_cloud/ossimPointBlock.h
@@ -2,7 +2,7 @@
 //
 // OSSIM (http://trac.osgeo.org/ossim/)
 //
-// License:  LGPL -- See LICENSE.txt file in the top level directory for more details.
+// License:  MIT -- See LICENSE.txt file in the top level directory for more details.
 //
 //**************************************************************************************************
 #ifndef ossimPointBlock_HEADER
diff --git a/include/ossim/point_cloud/ossimPointCloudGeometry.h b/include/ossim/point_cloud/ossimPointCloudGeometry.h
index d21f6ac..582a103 100644
--- a/include/ossim/point_cloud/ossimPointCloudGeometry.h
+++ b/include/ossim/point_cloud/ossimPointCloudGeometry.h
@@ -2,7 +2,7 @@
 //
 // OSSIM (http://trac.osgeo.org/ossim/)
 //
-// License:  LGPL -- See LICENSE.txt file in the top level directory for more details.
+// License:  MIT -- See LICENSE.txt file in the top level directory for more details.
 //
 //**************************************************************************************************
 // $Id$
diff --git a/include/ossim/point_cloud/ossimPointCloudHandler.h b/include/ossim/point_cloud/ossimPointCloudHandler.h
index 73d1f26..b614dd6 100644
--- a/include/ossim/point_cloud/ossimPointCloudHandler.h
+++ b/include/ossim/point_cloud/ossimPointCloudHandler.h
@@ -2,7 +2,7 @@
 //
 // OSSIM (http://trac.osgeo.org/ossim/)
 //
-// License:  LGPL -- See LICENSE.txt file in the top level directory for more details.
+// License:  MIT -- See LICENSE.txt file in the top level directory for more details.
 //
 //**************************************************************************************************
 // $Id$
diff --git a/include/ossim/point_cloud/ossimPointCloudHandlerFactory.h b/include/ossim/point_cloud/ossimPointCloudHandlerFactory.h
index a2c29f8..ac366cc 100644
--- a/include/ossim/point_cloud/ossimPointCloudHandlerFactory.h
+++ b/include/ossim/point_cloud/ossimPointCloudHandlerFactory.h
@@ -2,7 +2,7 @@
 //
 // OSSIM (http://trac.osgeo.org/ossim/)
 //
-// License:  LGPL -- See LICENSE.txt file in the top level directory for more details.
+// License:  MIT -- See LICENSE.txt file in the top level directory for more details.
 //
 //**************************************************************************************************
 // $Id$
diff --git a/include/ossim/point_cloud/ossimPointCloudHandlerRegistry.h b/include/ossim/point_cloud/ossimPointCloudHandlerRegistry.h
index b1dc8df..bf7ae6d 100644
--- a/include/ossim/point_cloud/ossimPointCloudHandlerRegistry.h
+++ b/include/ossim/point_cloud/ossimPointCloudHandlerRegistry.h
@@ -2,7 +2,7 @@
 //
 // OSSIM (http://trac.osgeo.org/ossim/)
 //
-// License:  LGPL -- See LICENSE.txt file in the top level directory for more details.
+// License:  MIT -- See LICENSE.txt file in the top level directory for more details.
 //
 //**************************************************************************************************
 // $Id$
diff --git a/include/ossim/point_cloud/ossimPointCloudImageHandler.h b/include/ossim/point_cloud/ossimPointCloudImageHandler.h
index 1879bbe..b9eda4b 100644
--- a/include/ossim/point_cloud/ossimPointCloudImageHandler.h
+++ b/include/ossim/point_cloud/ossimPointCloudImageHandler.h
@@ -2,7 +2,7 @@
 //
 // OSSIM (http://trac.osgeo.org/ossim/)
 //
-// License:  LGPL -- See LICENSE.txt file in the top level directory for more details.
+// License:  MIT -- See LICENSE.txt file in the top level directory for more details.
 //
 //**************************************************************************************************
 // $Id$
@@ -16,6 +16,7 @@
 #include <ossim/base/ossimIrect.h>
 #include <ossim/point_cloud/ossimPointCloudHandler.h>
 #include <vector>
+#include <mutex>
 
 class ossimImageData;
 class ossimTiffOverviewTileSource;
@@ -244,7 +245,7 @@ protected:
    ossimDpt                     m_gsd;
    ossim_float64                m_gsdFactor;
    ossimRefPtr<ossimImageData>  m_tile;
-   OpenThreads::Mutex           m_mutex;
+   std::mutex                   m_mutex;
    Components                   m_activeComponent;
    std::vector<ossimString>     m_componentNames;
 
diff --git a/include/ossim/point_cloud/ossimPointCloudSource.h b/include/ossim/point_cloud/ossimPointCloudSource.h
index 9fa47e3..41eec0b 100644
--- a/include/ossim/point_cloud/ossimPointCloudSource.h
+++ b/include/ossim/point_cloud/ossimPointCloudSource.h
@@ -2,7 +2,7 @@
 //
 // OSSIM (http://trac.osgeo.org/ossim/)
 //
-// License:  LGPL -- See LICENSE.txt file in the top level directory for more details.
+// License:  MIT -- See LICENSE.txt file in the top level directory for more details.
 //
 //**************************************************************************************************
 #ifndef ossimPointCloudSource_HEADER
diff --git a/include/ossim/point_cloud/ossimPointCloudUtilityFilter.h b/include/ossim/point_cloud/ossimPointCloudUtilityFilter.h
index 0425cee..a5fc3ce 100644
--- a/include/ossim/point_cloud/ossimPointCloudUtilityFilter.h
+++ b/include/ossim/point_cloud/ossimPointCloudUtilityFilter.h
@@ -2,7 +2,7 @@
 //
 // OSSIM (http://trac.osgeo.org/ossim/)
 //
-// License:  LGPL -- See LICENSE.txt file in the top level directory for more details.
+// License:  MIT -- See LICENSE.txt file in the top level directory for more details.
 //
 //**************************************************************************************************
 // $Id$
diff --git a/include/ossim/point_cloud/ossimPointRecord.h b/include/ossim/point_cloud/ossimPointRecord.h
index a448117..83270db 100644
--- a/include/ossim/point_cloud/ossimPointRecord.h
+++ b/include/ossim/point_cloud/ossimPointRecord.h
@@ -2,7 +2,7 @@
 //
 // OSSIM (http://trac.osgeo.org/ossim/)
 //
-// License:  LGPL -- See LICENSE.txt file in the top level directory for more details.
+// License:  MIT -- See LICENSE.txt file in the top level directory for more details.
 //
 //**************************************************************************************************
 // $Id: ossimPointRecord.h 23352 2015-05-29 17:38:12Z okramer $
diff --git a/include/ossim/projection/ossimAdjMapModel.h b/include/ossim/projection/ossimAdjMapModel.h
index 0637f46..b6a3329 100644
--- a/include/ossim/projection/ossimAdjMapModel.h
+++ b/include/ossim/projection/ossimAdjMapModel.h
@@ -1,7 +1,7 @@
 //----------------------------------------------------------------------------
 // Copyright (c) 2005, Oscar Kramer, all rights reserved.
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/projection/ossimApplanixEcefModel.h b/include/ossim/projection/ossimApplanixEcefModel.h
index 2c8ac0d..85d5498 100644
--- a/include/ossim/projection/ossimApplanixEcefModel.h
+++ b/include/ossim/projection/ossimApplanixEcefModel.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2005 Garrett Potts
 //
-// LGPL
+// MIT
 // 
 // Author:  Garrett Potts
 //
diff --git a/include/ossim/projection/ossimApplanixUtmModel.h b/include/ossim/projection/ossimApplanixUtmModel.h
index 21b01ad..24718bd 100644
--- a/include/ossim/projection/ossimApplanixUtmModel.h
+++ b/include/ossim/projection/ossimApplanixUtmModel.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2005 Garrett Potts
 //
-// LGPL
+// MIT
 // 
 // Author:  Garrett Potts
 //
diff --git a/include/ossim/projection/ossimCadrgProjection.h b/include/ossim/projection/ossimCadrgProjection.h
index 38048cb..32d0988 100644
--- a/include/ossim/projection/ossimCadrgProjection.h
+++ b/include/ossim/projection/ossimCadrgProjection.h
@@ -1,6 +1,6 @@
 //*******************************************************************
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/projection/ossimCoarseGridModel.h b/include/ossim/projection/ossimCoarseGridModel.h
index bf24bba..b36e61f 100644
--- a/include/ossim/projection/ossimCoarseGridModel.h
+++ b/include/ossim/projection/ossimCoarseGridModel.h
@@ -3,7 +3,7 @@
 //
 // Copyright (C) 2001 ImageLinks, Inc.
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/projection/ossimEpsgProjectionDatabase.h b/include/ossim/projection/ossimEpsgProjectionDatabase.h
index dd50b6b..de167ae 100644
--- a/include/ossim/projection/ossimEpsgProjectionDatabase.h
+++ b/include/ossim/projection/ossimEpsgProjectionDatabase.h
@@ -14,9 +14,8 @@
 #include <ossim/projection/ossimProjectionFactoryBase.h>
 #include <ossim/base/ossimFilename.h>
 #include <ossim/projection/ossimMapProjection.h>
-#include <OpenThreads/Mutex>
 #include <fstream>
-
+#include <mutex>
 
 class ossimProjection;
 class ossimString;
@@ -124,7 +123,7 @@ protected:
    void initialize() const;
 
    mutable std::multimap<ossim_uint32, ossimRefPtr<ProjDbRecord> > m_projDatabase;
-   mutable OpenThreads::Mutex m_mutex;
+   mutable std::mutex m_mutex;
    //static ossimEpsgProjectionDatabase*  m_instance; //!< Singleton implementation
    
 };
diff --git a/include/ossim/projection/ossimGoogleProjection.h b/include/ossim/projection/ossimGoogleProjection.h
index 73d0816..6f42f33 100644
--- a/include/ossim/projection/ossimGoogleProjection.h
+++ b/include/ossim/projection/ossimGoogleProjection.h
@@ -1,6 +1,6 @@
 //*******************************************************************
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/projection/ossimIkonosRpcModel.h b/include/ossim/projection/ossimIkonosRpcModel.h
index 3943aa3..fedf403 100644
--- a/include/ossim/projection/ossimIkonosRpcModel.h
+++ b/include/ossim/projection/ossimIkonosRpcModel.h
@@ -1,6 +1,6 @@
 //*******************************************************************
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 // 
diff --git a/include/ossim/projection/ossimImageProjectionModel.h b/include/ossim/projection/ossimImageProjectionModel.h
index 4ce5f86..412282c 100644
--- a/include/ossim/projection/ossimImageProjectionModel.h
+++ b/include/ossim/projection/ossimImageProjectionModel.h
@@ -1,6 +1,6 @@
 //-----------------------------------------------------------------------------
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/projection/ossimImageViewAffineTransform.h b/include/ossim/projection/ossimImageViewAffineTransform.h
index 4f4c9d7..67bc5cf 100644
--- a/include/ossim/projection/ossimImageViewAffineTransform.h
+++ b/include/ossim/projection/ossimImageViewAffineTransform.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc.
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/projection/ossimLensDistortion.h b/include/ossim/projection/ossimLensDistortion.h
index 988bef1..fac6f57 100644
--- a/include/ossim/projection/ossimLensDistortion.h
+++ b/include/ossim/projection/ossimLensDistortion.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc.
 //
-// LGPL
+// MIT
 // 
 // Author:  Garrett Potts (gpotts at imagelinks.com)
 //
diff --git a/include/ossim/projection/ossimMapProjectionFactory.h b/include/ossim/projection/ossimMapProjectionFactory.h
index 38b1d26..8b1c5d6 100644
--- a/include/ossim/projection/ossimMapProjectionFactory.h
+++ b/include/ossim/projection/ossimMapProjectionFactory.h
@@ -1,6 +1,6 @@
 //*******************************************************************
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 // 
diff --git a/include/ossim/projection/ossimMapProjectionInfo.h b/include/ossim/projection/ossimMapProjectionInfo.h
index f2e2a6b..d24e0a8 100644
--- a/include/ossim/projection/ossimMapProjectionInfo.h
+++ b/include/ossim/projection/ossimMapProjectionInfo.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2001 ImageLinks Inc.
 //
-// License:  LGPL
+// License:  MIT
 //
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/projection/ossimMeanRadialLensDistortion.h b/include/ossim/projection/ossimMeanRadialLensDistortion.h
index 46449c6..fcc7344 100644
--- a/include/ossim/projection/ossimMeanRadialLensDistortion.h
+++ b/include/ossim/projection/ossimMeanRadialLensDistortion.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc.
 //
-// LGPL
+// MIT
 // 
 // Author:  Garrett Potts (gpotts at imagelinks.com)
 //
diff --git a/include/ossim/projection/ossimNgaProjectionFactory.h b/include/ossim/projection/ossimNgaProjectionFactory.h
index 9f3db5a..8504aa0 100644
--- a/include/ossim/projection/ossimNgaProjectionFactory.h
+++ b/include/ossim/projection/ossimNgaProjectionFactory.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2014 RadiantBlue, Inc.
 //
-// License:  LGPL
+// License:  MIT
 //
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/projection/ossimNitfRpcModel.h b/include/ossim/projection/ossimNitfRpcModel.h
index 9f6ed16..8705473 100644
--- a/include/ossim/projection/ossimNitfRpcModel.h
+++ b/include/ossim/projection/ossimNitfRpcModel.h
@@ -1,7 +1,7 @@
 //*****************************************************************************
 // FILE: ossimNitfRpcModel.h
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/projection/ossimQuickbirdRpcModel.h b/include/ossim/projection/ossimQuickbirdRpcModel.h
index 736e346..1170f87 100644
--- a/include/ossim/projection/ossimQuickbirdRpcModel.h
+++ b/include/ossim/projection/ossimQuickbirdRpcModel.h
@@ -3,7 +3,7 @@
 //
 // Copyright (C) 2001 ImageLinks, Inc.
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/projection/ossimRpcModel.h b/include/ossim/projection/ossimRpcModel.h
index ff1004c..62ab664 100644
--- a/include/ossim/projection/ossimRpcModel.h
+++ b/include/ossim/projection/ossimRpcModel.h
@@ -20,7 +20,8 @@
 #include <ossim/base/ossimIpt.h>
 #include <ossim/base/ossimDblGrid.h>
 #include <ossim/base/ossimFilename.h>
-
+#include <ossim/ossimConfig.h>
+#include <ossim/base/ossim2dTo2dTransform.h>
 
 /*!****************************************************************************
  *
@@ -209,6 +210,23 @@ public:
     */
    void getRpcParameters(ossimRpcModel::rpcModelStruct& model) const;
    
+   /** Allows setting an offset to a subimage while using the coefficients of a full-image model.
+    * This adds a shift to the line and sample offsets so they corresond to the local subimage
+    * image space coordinates. Note thatthe base class' theImageRect will be adjusted to reflect the
+    * shift, even though the chip's LR corner will probably be wrong.
+    */
+   void setImageOffset(const ossimDpt& offset_to_chip_ul);
+
+   /**
+    * Serializes RPC to JSON format.
+    */
+   bool toJSON(std::ostream& json) const;
+
+   /**
+    * Serialize to WorldView-style .RPB file to the stream provided.
+    * Returns TRUE on successful write.
+    * */
+   bool toRPB(std::ostream& out) const;
 
 protected:
    enum AdjustParamIndex
@@ -285,6 +303,8 @@ protected:
    double theSampNumCoef[20];
    double theSampDenCoef[20];
  
+   friend class ossimRpcSolver;
+   friend class ossimNitfRpcBase;
 
    TYPE_DATA
 };
diff --git a/include/ossim/projection/ossimRpcProjection.h b/include/ossim/projection/ossimRpcProjection.h
index 4e32397..650c79d 100644
--- a/include/ossim/projection/ossimRpcProjection.h
+++ b/include/ossim/projection/ossimRpcProjection.h
@@ -1,7 +1,7 @@
 //*****************************************************************************
 // FILE: ossimRpcProjection.h
 //
-// LGPL
+// MIT
 //
 // DESCRIPTION: Contains declaration of class ossimRpcProjection.
 //   This is a replacement model utilizing the Rational Polynomial Coefficients
diff --git a/include/ossim/projection/ossimRpcSolver.h b/include/ossim/projection/ossimRpcSolver.h
index 2a281f3..046efb5 100644
--- a/include/ossim/projection/ossimRpcSolver.h
+++ b/include/ossim/projection/ossimRpcSolver.h
@@ -1,14 +1,9 @@
-//*****************************************************************************
-// FILE: ossimRpcModel.h
+//**************************************************************************************************
 //
-// License:  LGPL
-// 
-// See LICENSE.txt file in the top level directory for more details.
+//     OSSIM Open Source Geospatial Data Processing Library
+//     See top level LICENSE.txt file for license information
 //
-// AUTHOR: Garrett Potts
-//
-//*****************************************************************************
-//  $Id: ossimRpcSolver.h 15766 2009-10-20 12:37:09Z gpotts $
+//**************************************************************************************************
 #ifndef ossimRpcSolver_HEADER
 #define ossimRpcSolver_HEADER
 
@@ -43,14 +38,11 @@ class ossimNitfRegisteredTag;
  *       where coeff is one of XNum, XDen, YNum, and YDen.  So there are 80
  *       coefficients all together.
  *
- *       
  * Currently we use a linear least squares fit to solve the coefficients.
  * This is the simplest to implement.  We probably relly need a nonlinear
  * minimizer to fit the coefficients but I don't have time to experiment.
  * Levenberg Marquardt might be a solution to look into.
  *
- *
- * 
  * HOW TO USE:
  * 
  *        ossimRpcSolver solver;
@@ -64,11 +56,17 @@ class ossimNitfRegisteredTag;
  *        solver.solveCoefficients(imagePoints,
  *                                 groundPoints);
  *                                 
- *                                 
  * Once you call solveCoefficients you can create the projector:
  *                                 
  *        ossimRefPtr<ossimRpcProjection> rpc = solver.createRpcProjection();
  *
+ * Note that a sub-image bounding rect can be passed into the solve methods. This
+ * constrains the solution fit to cover only that rectangle in the original image space,
+ * but the image coordinates used are still based on the full image. If the intent is to
+ * generate an RPC that will work for an image chip in that chip's local image coordinate
+ * system (i.e., the UL corner of the chip is 0, 0), then you'll need to call
+ * rpcModel->setImageOffset(chip_offset) on the output RPC model.
+ *
  * </pre>
  * 
  */ 
@@ -90,18 +88,31 @@ public:
    /**
     * This will convert any projector to an RPC model
     */
-   void solveCoefficients(const ossimDrect& imageBouunds,
+   void solveCoefficients(const ossimDrect& imageBounds,
                           ossimProjection* imageProj,
                           ossim_uint32 xSamples=8,
-                          ossim_uint32 ySamples=8,
-                          bool shiftTo0Flag=true);
+                          ossim_uint32 ySamples=8);
    
-   void solveCoefficients(const ossimDrect& imageBouunds,
+   void solveCoefficients(const ossimDrect& imageBounds,
                           ossimImageGeometry* geom,
                           ossim_uint32 xSamples=8,
-                          ossim_uint32 ySamples=8,
-                          bool shiftTo0Flag=true);
-   
+                          ossim_uint32 ySamples=8);
+
+   /**
+    * Similar to the other solve methods except that the final grid size is established
+    * iteratively so that the error at the midpoints between grid nodes falls below tolerance.
+    * The RPC is computed for the specified image bounds range only, not the full image. The
+    * expectation here (when the imageBounds is less than the full valid image rect) is to
+    * generate an RPC to accompany a subimage that will be written to disk.
+    * @param imageBounds The AOI in image space for the RPC computation.
+    * @param geom Represents the geometry of the input image
+    * @param pixel_tolerance Maximum error in pixels (typically fraction of a pixel) to achieve.
+    * @return true if solution converged below pixel tolerance.
+    */
+   bool solve(const ossimDrect& aoiBounds,
+              ossimImageGeometry* geom,
+              const double& pixel_tolerance=0.5);
+
    /**
     * takes associated image points and ground points
     * and solves the coefficents for the rational polynomial for
@@ -111,58 +122,16 @@ public:
     *       numerical robustness.
     */ 
    void solveCoefficients(const std::vector<ossimDpt>& imagePoints,
-                          const std::vector<ossimGpt>& groundControlPoints,
-                          const ossimDpt& imageShift = ossimDpt(0.0,0.0));
+                          const std::vector<ossimGpt>& groundControlPoints);
 
    /**
-    * Creates and Rpc model from the coefficients
+    * Fetches the solved-for RPC model. See note in header above on setting the image offset
+    * if this model will be applied to a sub-image chip.
     */
-   ossimImageGeometry* createRpcModel()const;
-
-   /**
-    * Create a simple rpc projection which is a dumbed down
-    * rpc model.
-    */
-   ossimImageGeometry* createRpcProjection()const;
-
-
-   /**
-    * Gives access to the solved coefficients.  For the image
-    * X numerator
-    */
-   const std::vector<double>& getImageXNumCoefficients()const;
-
-   /**
-    * Gives access to the solved coefficients.  For the image
-    * X denominator
-    */
-   const std::vector<double>& getImageXDenCoefficients()const;
-
-   /**
-    * Gives access to the solved coefficients.  For the image
-    * Y numerator
-    */
-   const std::vector<double>& getImageYNumCoefficients()const;
-
-   /**
-    * Gives access to the solved coefficients. For the image
-    * Y denominator
-    */
-   const std::vector<double>& getImageYDenCoefficients()const;
-
-   
-   double getImageXOffset()const;
-   double getImageYOffset()const;
-   double getLatOffset()const;
-   double getLonOffset()const;
-   double getHeightOffset()const;
-   double getImageXScale()const;
-   double getImageYScale()const;
-   double getLatScale()const;
-   double getLonScale()const;
-   double getHeightScale()const;
+   const ossimRefPtr<ossimRpcModel> getRpcModel() const { return theRpcModel; }
 
    double getRmsError()const;
+   double getMaxError()const;
 
    /**
     * @return ossimRefPtr<ossimNitfRegisteredTag>
@@ -171,6 +140,11 @@ public:
     */
    ossimRefPtr<ossimNitfRegisteredTag> getNitfRpcBTag() const;
    
+   /**
+    * Sets the image rect over which to compute the RPCs. The Resulting RPC will only be valid
+    * over that range of image space. */
+   void setValidImageRect(const ossimIrect& imageRect);
+
 protected:
 	virtual ~ossimRpcSolver(){}
    
@@ -187,9 +161,9 @@ protected:
                                   const std::vector<double>& z)const;
    
    double eval(const std::vector<double>& coeff,
-               double x,
-               double y,
-               double z)const;
+               const double& x, const double& y, const double& z)const;
+
+   void evalPoint(const ossimGpt& gpt, ossimDpt& ipt) const;
 
    /**
     * Inverts using the SVD method
@@ -211,33 +185,12 @@ protected:
 
    bool theUseElevationFlag;
    bool theHeightAboveMSLFlag;
-   ossimDpt      theImageOffset;
-   ossimGpt      theGroundOffset;
-   ossimDpt      theImageScale;
-   ossim_float64 theLatScale;
-   ossim_float64 theLonScale;
-   ossim_float64 theHeightScale;
-   ossim_float64 theError;
-   /**
-    * there are 20 coefficients in the cubic RPC model
-    */ 
-   std::vector<ossim_float64> theXNumCoeffs;
-
-   /**
-    * there are 20 coefficients in the cubic RPC model
-    */ 
-   std::vector<ossim_float64> theXDenCoeffs;
+   ossim_float64 theMeanResidual;
+   ossim_float64 theMaxResidual;
+   ossimRefPtr<ossimImageGeometry> theRefGeom;
+   ossimRefPtr<ossimRpcModel> theRpcModel;
 
-   /**
-    * there are 20 coefficients in the cubic RPC model
-    */ 
-   std::vector<ossim_float64> theYNumCoeffs;
 
-   /**
-    * there are 20 coefficients in the cubic RPC model
-    */ 
-   std::vector<ossim_float64> theYDenCoeffs;
-   
 };
 
 #endif
diff --git a/include/ossim/projection/ossimUtmpt.h b/include/ossim/projection/ossimUtmpt.h
index dcbd93d..ea538eb 100644
--- a/include/ossim/projection/ossimUtmpt.h
+++ b/include/ossim/projection/ossimUtmpt.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc.
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
@@ -39,7 +39,7 @@ public:
    /**
     * Return the zone for this utm point.
     */
-   long zone() const { return theZone; }
+   ossim_int32 zone() const { return theZone; }
 
    /**
     * Return the hemisphere ( Northern or Southern).
diff --git a/include/ossim/support_data/ImageHandlerState.h b/include/ossim/support_data/ImageHandlerState.h
new file mode 100644
index 0000000..77c5f60
--- /dev/null
+++ b/include/ossim/support_data/ImageHandlerState.h
@@ -0,0 +1,145 @@
+//*******************************************************************
+//
+// License:  See top level LICENSE.txt file.
+// 
+//*****************************************************************************
+#ifndef ossimImageHandlerState_HEADER
+#define ossimImageHandlerState_HEADER 1
+#include <ossim/base/State.h>
+#include <ossim/base/ossimIpt.h>
+#include <ossim/base/ossimFilename.h>
+#include <ossim/support_data/ossimImageMetaData.h>
+#include <memory>
+
+namespace ossim
+{
+  /**
+  * This is a Image handler state object.  This handles caching
+  * state of a ossimImageHandler.  The example code provided will 
+  * work for any Image handler that supports state caching.  Note,  
+  * if anything changes on the input image then the state will need 
+  * to be recalculated by opening the image without the state and 
+  * grabbing it's state again.
+  *
+  * Example code to get a state of an image source:
+  *
+  * @code
+  * #include <ossim/base/ossimKeywordlist.h>
+  * #include <ossim/imaging/ossimImageHandlerRegistry.h>
+  * #include <ossim/imaging/ossimImageHandler.h>
+  * #include <ossim/support_data/ImageHandlerState.h>
+  *
+  * ossimRefPtr<ossimImageHandler> h = ossimImageHandlerRegistry::instance()->open(filename);
+  *
+  * if(h)
+  * {
+  *   std::shared_ptr<ossim::ImageHandlerState> state = h->getState();
+  *   if(state)
+  *   {
+  *     ossimKeywordlist kwl;
+  *     state->save(kwl);
+  *     std::cout << kwl << "\n";
+  *   }
+  * }
+  * @endCode
+  *
+  * Example code using a state
+  *
+  * @code
+  * #include <ossim/base/ossimKeywordlist.h>
+  * #include <ossim/imaging/ossimImageHandlerRegistry.h>
+  * #include <ossim/imaging/ossimImageHandler.h>
+  * #include <ossim/support_data/ImageHandlerState.h>
+  *
+  * ossimRefPtr<ossimImageHandler> h = ossimImageHandlerRegistry::instance()->open(filename);
+  *
+  * if(h)
+  * {
+  *   std::shared_ptr<ossim::ImageHandlerState> state = h->getState();
+  *   if(state)
+  *   {
+  *      h = ossimImageHandlerRegistry::instance()->open(state);
+  *      if(h)
+  *      {
+  *         std::cout << "Successfully opened with a state\n";  
+  *      } 
+  *   }
+  * }
+  * @endCode
+  */
+   class OSSIM_DLL ImageHandlerState : public ossim::State
+   {
+   public:
+      ImageHandlerState();
+      virtual ~ImageHandlerState();
+      virtual const ossimString& getTypeName()const override;
+      static const ossimString& getStaticTypeName();
+      
+      /**
+      * Loads the the state object from keywordlist.
+      *
+      * @param kwl keywordlist that olds the state of the object
+      * @param prefix optional prefix value that is used as a prefix 
+      *        for all keywords.
+      */
+      virtual bool load(const ossimKeywordlist& kwl,
+                        const ossimString& prefix="") override;
+      /**
+      * Saves the state of the object to a keyword list.
+      *
+      * @param kwl keywordlist that the state will be saved to
+      * @param prefix optional prefix value that is used as a prefix 
+      *        for all keywords.
+      */
+      virtual bool save(ossimKeywordlist& kwl,
+                        const ossimString& prefix="")const override;
+
+      /**
+      * @return if one exists it will have a valid overview state.
+      */
+      std::shared_ptr<ImageHandlerState> getOverviewState(){return m_overviewState;}
+
+      /**
+      * @return if one exists it will have a valid overview state.
+      */
+      std::shared_ptr<const ImageHandlerState> getOverviewState()const{return m_overviewState;}
+
+      /**
+      * Allows one to set the overview state object for this handler
+      */
+      void setOverviewState(std::shared_ptr<ImageHandlerState> overviewState){m_overviewState=overviewState;}
+      void setConnectionString(const ossimString& connectionString){m_connectionString = connectionString;}
+      const ossimString& getConnectionString()const{return m_connectionString;}
+      void setImageHandlerType(const ossimString& typeName){m_imageHandlerType = typeName;}
+      const ossimString& getImageHandlerType()const{return m_imageHandlerType;}
+      void setCurrentEntry(ossim_uint32 entry){m_currentEntry = entry;}
+      const ossim_uint32 getCurrentEntry()const{return m_currentEntry;}
+      std::shared_ptr<const ossimImageMetaData> getMetaData()const{return m_omd;}
+      std::shared_ptr<ossimImageMetaData> getMetaData(){return m_omd;}
+      void setMetaData(std::shared_ptr<ossimImageMetaData> omd){m_omd=omd;}
+      void setValidVertices(std::shared_ptr<ossimKeywordlist> kwl){m_validVertices=kwl;}
+      std::shared_ptr<ossimKeywordlist> getValidVertices(){return m_validVertices;}
+      std::shared_ptr<const ossimKeywordlist> getValidVertices()const{return m_validVertices;}
+      
+      /**
+      * @return true if it has metadata
+      */
+      bool hasMetaData()const;
+
+      /**
+      * Overridable and loads the defaults given the main entry. 
+      */
+      bool virtual loadDefaults(const ossimFilename& filename, 
+                                ossim_uint32 entry=0);
+    private:
+      static const ossimString            m_typeName;
+      std::shared_ptr<ImageHandlerState>  m_overviewState;
+      std::shared_ptr<ossimImageMetaData> m_omd;
+      std::shared_ptr<ossimKeywordlist>   m_validVertices;
+      ossimString                         m_connectionString;
+      ossimString                         m_imageHandlerType;
+      ossim_uint32                        m_currentEntry;
+   };
+};
+
+#endif
\ No newline at end of file
diff --git a/include/ossim/support_data/ImageHandlerStateFactory.h b/include/ossim/support_data/ImageHandlerStateFactory.h
new file mode 100644
index 0000000..00e9798
--- /dev/null
+++ b/include/ossim/support_data/ImageHandlerStateFactory.h
@@ -0,0 +1,26 @@
+//*******************************************************************
+//
+// License:  See top level LICENSE.txt file.
+// 
+//*****************************************************************************
+#ifndef ossimImageHandlerStateFactory_HEADER
+#define ossimImageHandlerStateFactory_HEADER 1
+#include <ossim/base/StateFactoryBase.h>
+#include <ossim/support_data/ImageHandlerState.h>
+#include <memory>
+
+namespace ossim
+{
+   class OSSIM_DLL ImageHandlerStateFactory : public StateFactoryBase< std::shared_ptr<ossim::ImageHandlerState> >
+   {
+   public:
+      ImageHandlerStateFactory();
+      static std::shared_ptr<ossim::ImageHandlerStateFactory> instance();
+
+      virtual std::shared_ptr<ossim::ImageHandlerState> createState(const ossimKeywordlist& kwl, 
+                                                                    const ossimString& prefix="")const override;
+      virtual std::shared_ptr<ossim::ImageHandlerState> createState(const ossimString& typeName)const override; 
+
+   };
+}
+#endif
diff --git a/include/ossim/support_data/ImageHandlerStateRegistry.h b/include/ossim/support_data/ImageHandlerStateRegistry.h
new file mode 100644
index 0000000..4114a3b
--- /dev/null
+++ b/include/ossim/support_data/ImageHandlerStateRegistry.h
@@ -0,0 +1,32 @@
+//*******************************************************************
+//
+// License:  See top level LICENSE.txt file.
+// 
+//*****************************************************************************
+#ifndef ossimImageHandlerStateRegistry_HEADER
+#define ossimImageHandlerStateRegistry_HEADER 1
+#include <ossim/base/ossimConstants.h>
+#include <ossim/support_data/ImageHandlerState.h>
+#include <ossim/base/StateFactoryBase.h>
+#include <ossim/base/FactoryListBase.h>
+#include <memory>
+
+namespace ossim
+{
+   /**
+   * This is the state registry for all image handler states that
+   * will be supported.
+   */
+   class OSSIM_DLL ImageHandlerStateRegistry : public ossim::FactoryListBase<
+                                                      std::shared_ptr<ossim::StateFactoryBase< std::shared_ptr<ossim::ImageHandlerState> > > >
+   {
+   public:
+      ImageHandlerStateRegistry();
+      static std::shared_ptr<ImageHandlerStateRegistry> instance();
+      std::shared_ptr<ossim::ImageHandlerState> createState(const ossimKeywordlist& kwl, 
+                                                            const ossimString& prefix = "")const;
+      std::shared_ptr<ossim::ImageHandlerState> createState(const ossimString& typeName)const;
+   };
+};
+#endif
+
diff --git a/include/ossim/support_data/TiffHandlerState.h b/include/ossim/support_data/TiffHandlerState.h
new file mode 100644
index 0000000..3b14ac2
--- /dev/null
+++ b/include/ossim/support_data/TiffHandlerState.h
@@ -0,0 +1,474 @@
+//*******************************************************************
+//
+// License:  See top level LICENSE.txt file.
+// 
+//*****************************************************************************
+#ifndef ossimTiffHandlerState_HEADER
+#define ossimTiffHandlerState_HEADER 1
+#include <ossim/support_data/ImageHandlerState.h>
+#include <ossim/projection/ossimProjection.h>
+
+typedef struct tiff TIFF;  
+class ossimTieGptSet;
+namespace ossim
+{
+  /**
+  * This is a Tiff handler state object.  This handles caching
+  * state of a ossimTiffTileSource.  The example code provided will 
+  * work for any Image handler that supports state caching.  Note,  
+  * if anything changes on the input image then the state will need 
+  * to be recalculated by opening the image without the state and 
+  * grabbing it's state again.
+  *
+  * Example code to get a state of an image source:
+  *
+  * @code
+  * #include <ossim/base/ossimKeywordlist.h>
+  * #include <ossim/imaging/ossimImageHandlerRegistry.h>
+  * #include <ossim/imaging/ossimImageHandler.h>
+  * #include <ossim/support_data/ImageHandlerState.h>
+  *
+  * ossimRefPtr<ossimImageHandler> h = ossimImageHandlerRegistry::instance()->open(filename);
+  *
+  * if(h)
+  * {
+  *   std::shared_ptr<ossim::ImageHandlerState> state = h->getState();
+  *   if(state)
+  *   {
+  *     ossimKeywordlist kwl;
+  *     state->save(kwl);
+  *     std::cout << kwl << "\n";
+  *   }
+  * }
+  * @endCode
+  *
+  * Example code using a state
+  *
+  * @code
+  * #include <ossim/base/ossimKeywordlist.h>
+  * #include <ossim/imaging/ossimImageHandlerRegistry.h>
+  * #include <ossim/imaging/ossimImageHandler.h>
+  * #include <ossim/support_data/ImageHandlerState.h>
+  *
+  * ossimRefPtr<ossimImageHandler> h = ossimImageHandlerRegistry::instance()->open(filename);
+  *
+  * if(h)
+  * {
+  *   std::shared_ptr<ossim::ImageHandlerState> state = h->getState();
+  *   if(state)
+  *   {
+  *      h = ossimImageHandlerRegistry::instance()->open(state);
+  *      if(h)
+  *      {
+  *         std::cout << "Successfully opened with a state\n";  
+  *      } 
+  *   }
+  * }
+  * @endCode
+  *
+  * Small Keywordklist example from just the tiff.  Typically this is grabbed
+  * from the image handler but here we will just show the tiff tags
+  *
+  * @code
+  * connection_string:  /data/sanfran_utm.tif
+  * current_entry:  0
+  * dir0.is_geotiff:  1
+  * dir0.is_tiled:  true
+  * dir0.tifftag.angular_units:  9108
+  * dir0.tifftag.bits_per_sample:  8
+  * dir0.tifftag.compression:  1
+  * dir0.tifftag.datum_code:  6326
+  * dir0.tifftag.false_easting:  500000
+  * dir0.tifftag.false_northing:  0
+  * dir0.tifftag.gcs_code:  4326
+  * dir0.tifftag.geo_double_params:  (6378137,6356752.3141999999061)
+  * dir0.tifftag.geo_pixel_scale:  (5,5,0)
+  * dir0.tifftag.geo_tie_points:  (0,0,0,538185,4208785,0)
+  * dir0.tifftag.image_length:  8000
+  * dir0.tifftag.image_width:  8000
+  * dir0.tifftag.linear_units:  9001
+  * dir0.tifftag.max_sample_value:  255
+  * dir0.tifftag.min_sample_value:  1
+  * dir0.tifftag.model_type:  1
+  * dir0.tifftag.origin_lat:  0
+  * dir0.tifftag.origin_lon:  -123
+  * dir0.tifftag.pcs_code:  32610
+  * dir0.tifftag.photometric:  2
+  * dir0.tifftag.planar_config:  1
+  * dir0.tifftag.raster_type:  2
+  * dir0.tifftag.sample_format:  1
+  * dir0.tifftag.samples_per_pixel:  3
+  * dir0.tifftag.scale_factor:  0.9996
+  * dir0.tifftag.tile_length:  64
+  * dir0.tifftag.tile_width:  64
+  * image_handler_type:
+  * number_of_directories:  1
+  * type:  ossim::TiffHandlerState
+  * @endCode
+  */
+  class OSSIM_DLL TiffHandlerState : public ossim::ImageHandlerState
+  {
+  public:
+    TiffHandlerState();
+    virtual ~TiffHandlerState();
+    virtual const ossimString& getTypeName()const override;
+    static const ossimString& getStaticTypeName();
+
+    /**
+    * General access to get the tags of an image
+    *
+    * @return ossimKeywordlist that contains the tags
+    */
+    ossimKeywordlist& getTags(){return m_tags;}
+
+    /**
+    * General access to the the tags of an image
+    *
+    * @return ossimKeywordlist that contains the tags
+    */
+    const ossimKeywordlist& getTags()const{return m_tags;}
+
+    /**
+    * Is used by this state to add a valud to the tags
+    *
+    * @param key is the identifier for the value
+    * @param value is the value to add to the tags
+    */
+    void addValue(const ossimString& key, const ossimString& value);
+
+    /**
+    * Given a key return the value
+    * 
+    * @param value returns the value
+    * @param key is the key holding the value
+    *
+    * @return true if the value was found and false otherwise
+    */
+    bool getValue(ossimString& value, const ossimString& key)const;
+
+
+    /**
+    * Convenience method to return the value of a key given the 
+    * directory.  It will construct a new key from the directory.  If 
+    * the directory is 0 and the key is sub_file_type then the key that
+    * is actually queried internally is "dir0.sub_file_type"
+    * 
+    * @param value returns the value
+    * @param directory is the directory to return the key
+    * @param key is the key holding the value
+    *
+    * @return true if the value was found and false otherwise
+    */
+    bool getValue(ossimString& value,
+                  const ossim_uint32 directory, 
+                  const ossimString& key)const;
+
+    /**
+    * Will return true or false if the directory and key is in the
+    * tags.
+    *
+    * @return 
+    */
+    bool exists(ossim_uint32 directory, const ossimString& key)const;
+
+    /**
+    *   Will check if a key exists
+    */
+    bool exists(const ossimString& key)const;
+    bool checkBool(const ossimString& key)const;
+    bool checkBool(ossim_uint32 directory, const ossimString& key)const;
+    
+    /**
+    * This is overriden from the base and will load the main entry.  For Tiff we 
+    * do not support multiple pages yet so this value will
+    * be ignored.  In the future it will be used to load the state
+    * of individual pages.  For now,  what is loaded is based on the sub_file_type and
+    * this entry is treated as the main entry point
+    *
+    * @param file file to to open
+    *
+    * @return true if defaults were loaded and false 
+    *         otheriwse
+    */
+    virtual bool loadDefaults(const ossimFilename& file, ossim_uint32 entry=0)override;
+
+    /**
+    * Will load default values
+    *
+    * @param tiffPtr tiff pointer
+    */
+    void loadDefaults(TIFF* tiffPtr);
+
+    /**
+    * Will load only value for the current directory
+    *
+    * @param tiffPtr tiff pointer
+    */
+    void loadCurrentDirectory(TIFF* tiffPtr);
+
+    /**
+    * Will change and load the directory provided
+    *
+    * @param tiffPtr tiff pointer
+    * @param directory the directory to load
+    */
+    void loadDirectory(TIFF* tiffPtr, ossim_uint32 directory);
+
+    /**
+    * Convenience method to check if the directory 
+    * is a reduced image specification
+    *
+    * @param directory the directory to test
+    */
+    bool isReduced(ossim_uint32 directory)const;
+
+    /**
+    * Convenience method to check if the directory 
+    * is a image mask specification
+    *
+    * @param directory the directory to test
+    */
+    bool isMask(ossim_uint32 directory)const;
+
+    /**
+    * Convenience method to check if the directory 
+    * is a paged image specification
+    *
+    * @param directory the directory to test
+    */
+    bool isPage(ossim_uint32 directory)const;
+
+
+    /**
+    * Convenience method to check if a directory 
+    * is tiled
+    *
+    * @param directory the directory to test
+    * @return true if tiled and false otherwise
+    */
+    bool isTiled(ossim_uint32 directory)const;
+
+    /**
+    * Convenience method to get an Int32 value.  
+    *
+    * This does not supply a way to check if a value existed or not.
+    */
+    ossim_int32 getInt32Value(const ossimString& key, ossim_int32 directory=0)const;
+
+    /**
+    * Convenience method to get an Double value.  
+    *
+    * This does not supply a way to check if a value existed or not.
+    */
+    ossim_float64 getDoubleValue(const ossimString& key, ossim_int32 directory=0)const;
+
+    /**
+    * Convenience method to get a raster type.  
+    *
+    * This does not supply a way to check if a value existed or not.
+    */
+    ossim_int32 getRasterType(ossim_int32 directory=0)const;
+
+    /**
+    * Convenience method to get a pcs code.  
+    *
+    * This does not supply a way to check if a value existed or not.
+    */
+    ossim_int32 getPcsCode(ossim_int32 directory=0)const;
+
+    /**
+    * Convenience method to get a datum code.  
+    *
+    * This does not supply a way to check if a value existed or not.
+    */
+    ossim_int32 getDatumCode(ossim_int32 directory=0)const;
+
+    /**
+    * Convenience method to get a gcs code.  
+    *
+    * This does not supply a way to check if a value existed or not.
+    */
+    ossim_int32 getGcsCode(ossim_int32 directory=0)const;
+
+    /**
+    * Convenience method to get a model type.  
+    *
+    * This does not supply a way to check if a value existed or not.
+    */
+    ossim_int32 getModelType(ossim_int32 directory=0)const;
+
+    /**
+    * Convenience method to get angular units.  
+    *
+    * This does not supply a way to check if a value existed or not.
+    */
+    ossim_int32 getAngularUnits(ossim_int32 directory=0)const;
+
+    /**
+    * Convenience method to get linear units.  
+    *
+    * This does not supply a way to check if a value existed or not.
+    */
+    ossim_int32 getLinearUnits(ossim_int32 directory=0)const;
+
+    /**
+    * Convenience method to get image length.  
+    *
+    * This does not supply a way to check if a value existed or not.
+    */
+    ossim_int64 getImageLength(ossim_int32 directory=0)const;
+
+    /**
+    * Convenience method to get image width.  
+    *
+    * This does not supply a way to check if a value existed or not.
+    */
+    ossim_int64 getImageWidth(ossim_int32 directory=0)const;
+
+    /**
+    * Convenience method to get origin lat.  
+    *
+    * This does not supply a way to check if a value existed or not.
+    */
+    ossim_float64 getOriginLat(ossim_int32 directory=0)const;
+
+    /**
+    * Convenience method to get origin lon.  
+    *
+    * This does not supply a way to check if a value existed or not.
+    */
+    ossim_float64 getOriginLon(ossim_int32 directory=0)const;
+
+    /**
+    * Convenience method to get standard parallel 1.  
+    *
+    * This does not supply a way to check if a value existed or not.
+    */
+    ossim_float64 getStandardParallel1(ossim_int32 directory=0)const;
+
+    /**
+    * Convenience method to get standard parallel 2.  
+    *
+    * This does not supply a way to check if a value existed or not.
+    */
+    ossim_float64 getStandardParallel2(ossim_int32 directory=0)const;
+
+    /**
+    * Convenience method to get false easting.  
+    *
+    * This does not supply a way to check if a value existed or not.
+    */
+    ossim_float64 getFalseEasting(ossim_int32 directory=0)const;
+
+    /**
+    * Convenience method to get false northing.  
+    *
+    * This does not supply a way to check if a value existed or not.
+    */
+    ossim_float64 getFalseNorthing(ossim_int32 directory=0)const;
+
+    /**
+    * Convenience method to get scale factor.  
+    *
+    * This does not supply a way to check if a value existed or not.
+    */
+    ossim_float64 getScaleFactor(ossim_int32 directory=0)const;
+
+    /**
+    * Convenience method to get a double array.  
+    *
+    * @param result resulting double array
+    * @param directory to use
+    * @param key to get a double array.      
+    */
+    bool getDoubleArray(std::vector<ossim_float64>& result, 
+                        ossim_int32 directory,
+                        const ossimString& key)const;
+
+    /**
+    * Convenience method to get a Geo double params array.  
+    *
+    * @param result resulting double array
+    * @param directory to use
+    */
+    bool getGeoDoubleParams(std::vector<ossim_float64>& result,
+                            ossim_int32 directory)const;
+
+    /**
+    * Convenience method to get a Geo double params array.  
+    *
+    * @param result resulting double array
+    * @param directory to use
+    */
+    bool getGeoPixelScale(std::vector<ossim_float64>& result,
+                          ossim_int32 directory)const;
+
+    /**
+    * Convenience method to get a Geo Tie points array.  
+    *
+    * @param result resulting double array
+    * @param directory to use
+    */
+    bool getGeoTiePoints(std::vector<ossim_float64>& result,
+                         ossim_int32 directory)const;
+
+    /**
+    * Convenience method to get a Geo trans matrix array.  
+    *
+    * @param result resulting double array
+    * @param directory to use
+    */
+    bool getGeoTransMatrix(std::vector<ossim_float64>& result,
+                           ossim_int32 directory)const;
+
+    /**
+    * Loads the the state object from keywordlist.
+    *
+    * @param kwl keywordlist that olds the state of the object
+    * @param prefix optional prefix value that is used as a prefix 
+    *        for all keywords.
+    */
+    virtual bool load(const ossimKeywordlist& kwl,
+                           const ossimString& prefix="") override;
+
+    /**
+    * Saves the state of the object to a keyword list.
+    *
+    * @param kwl keywordlist that the state will be saved to
+    * @param prefix optional prefix value that is used as a prefix 
+    *        for all keywords.
+    */
+    virtual bool save(ossimKeywordlist& kwl,
+                           const ossimString& prefix="")const override;
+  private:
+    static const ossimString m_typeName;
+
+    /**
+    * Used to save a color map.  Will save the map into the
+    * tag list as arrays for colormap.red, colormap.blue, colormap.green
+    * Each list is a string of the form "(valu1,valu2, .... valueN)" with 
+    * the parenthesis included
+    */
+    void saveColorMap(const ossimString& dirPrefix,
+                      const ossim_uint16* red, 
+                      const ossim_uint16* green,
+                      const ossim_uint16* blue,
+                      ossim_uint32 numberOfEntries);
+
+    /**
+    * loads tags into the keywordlist for a given directory
+    */
+    void loadGeotiffTags(TIFF* tiffPtr, const ossimString& dirPrefix);
+
+    /**
+    * converts an array into a string list of the form
+    *
+    * (vale1,value2,...,valueN)
+    */
+    void convertArrayToStringList(ossimString& result, double* doubleArray, ossim_int32 doubleArraSize)const;
+
+    ossimKeywordlist  m_tags; 
+  };
+
+}
+#endif
diff --git a/include/ossim/support_data/TiffStreamAdaptor.h b/include/ossim/support_data/TiffStreamAdaptor.h
new file mode 100644
index 0000000..8c94cc3
--- /dev/null
+++ b/include/ossim/support_data/TiffStreamAdaptor.h
@@ -0,0 +1,93 @@
+#ifndef ossimTiffStreamAdaptor_HEADER
+#define ossimTiffStreamAdaptor_HEADER
+#include <ossim/base/ossimConstants.h>
+#include <ossim/base/ossimString.h>
+#include <ossim/base/ossimIoStream.h>
+#include <ossim/base/ossimStreamFactoryRegistry.h>
+#include <tiffio.h>
+
+namespace ossim
+{
+   /**
+   * This is the stream adaptor used by our tiff reader
+   * We use the adaptor so we can support direct S3 access or later be
+   * able to support blocked reads, ... etc
+   *
+   * Code snip for Input stream:
+   * @code
+   * m_streamAdaptor = std::make_shared<ossim::TiffIStreamAdaptor>(str,
+   *                                                               connectionString);
+   * 
+   * theTiffPtr = XTIFFClientOpen(connectionString.c_str(), "rm", 
+   *                              (thandle_t)m_streamAdaptor.get(),
+   *                              ossim::TiffIStreamAdaptor::tiffRead, 
+   *                              ossim::TiffIStreamAdaptor::tiffWrite, 
+   *                              ossim::TiffIStreamAdaptor::tiffSeek, 
+   *                              ossim::TiffIStreamAdaptor::tiffClose, 
+   *                              ossim::TiffIStreamAdaptor::tiffSize,
+   *                              ossim::TiffIStreamAdaptor::tiffMap, 
+   *                              ossim::TiffIStreamAdaptor::tiffUnmap);
+   * @endCode
+   */
+   class OSSIM_DLL TiffIStreamAdaptor
+   {
+   public:
+      TiffIStreamAdaptor()
+      {
+      }
+      TiffIStreamAdaptor(const ossimString& connectionString)
+      {
+         openStream(connectionString);
+      }
+      TiffIStreamAdaptor(std::shared_ptr<ossim::istream> inputStream,
+                         const ossimString& connectionString="")
+      {
+         setStream(inputStream, connectionString);
+      }
+
+      ~TiffIStreamAdaptor()
+      {
+         close();
+      }
+
+      bool openStream(const ossimString& connectionString)
+      {
+         setStream(ossim::StreamFactoryRegistry::instance()->createIstream(connectionString));
+      
+         return (m_tiffStream != nullptr);
+      }
+
+      void setStream(std::shared_ptr<ossim::istream> inputStream, 
+                     const ossimString& connectionString="")
+      {
+         m_tiffStream       = inputStream;
+         m_connectionString = connectionString;
+      }
+
+      const ossimString& getConnectionString()const{return m_connectionString;}
+
+      std::shared_ptr<ossim::istream> getStream()
+      {
+         return m_tiffStream;
+      }
+      
+      void close()
+      {
+         m_tiffStream.reset();
+      }
+
+      static tsize_t tiffRead(thandle_t st,tdata_t buffer,tsize_t size);
+      static tsize_t tiffWrite(thandle_t st,tdata_t buffer,tsize_t size);
+      static int tiffClose(thandle_t st);
+      static toff_t tiffSeek(thandle_t st,toff_t pos, int whence);
+      static toff_t tiffSize(thandle_t st);
+      static int tiffMap(thandle_t, tdata_t*, toff_t*);
+      static void tiffUnmap(thandle_t, tdata_t, toff_t);
+
+   private:
+      std::shared_ptr<ossim::istream> m_tiffStream;
+      ossimString                     m_connectionString;
+   };   
+}
+
+#endif
\ No newline at end of file
diff --git a/include/ossim/support_data/ossimAuxFileHandler.h b/include/ossim/support_data/ossimAuxFileHandler.h
index d28cbba..438f4a8 100644
--- a/include/ossim/support_data/ossimAuxFileHandler.h
+++ b/include/ossim/support_data/ossimAuxFileHandler.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc. 
 //
-// License:  LGPL
+// License:  MIT
 //
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/support_data/ossimAuxXmlSupportData.h b/include/ossim/support_data/ossimAuxXmlSupportData.h
index 6b17d89..3329821 100644
--- a/include/ossim/support_data/ossimAuxXmlSupportData.h
+++ b/include/ossim/support_data/ossimAuxXmlSupportData.h
@@ -1,6 +1,6 @@
 //----------------------------------------------------------------------------
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/support_data/ossimCcfInfo.h b/include/ossim/support_data/ossimCcfInfo.h
index bb9cb76..f811f80 100644
--- a/include/ossim/support_data/ossimCcfInfo.h
+++ b/include/ossim/support_data/ossimCcfInfo.h
@@ -1,6 +1,6 @@
 //----------------------------------------------------------------------------
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/support_data/ossimDemInfo.h b/include/ossim/support_data/ossimDemInfo.h
index e4263c5..c67dd0e 100644
--- a/include/ossim/support_data/ossimDemInfo.h
+++ b/include/ossim/support_data/ossimDemInfo.h
@@ -1,6 +1,6 @@
 //----------------------------------------------------------------------------
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/support_data/ossimDemStats.h b/include/ossim/support_data/ossimDemStats.h
index f678e74..8d5d275 100644
--- a/include/ossim/support_data/ossimDemStats.h
+++ b/include/ossim/support_data/ossimDemStats.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc. 
 //
-// License:  LGPL
+// License:  MIT
 //
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/support_data/ossimDoqq.h b/include/ossim/support_data/ossimDoqq.h
index 1a59e5d..465e41d 100644
--- a/include/ossim/support_data/ossimDoqq.h
+++ b/include/ossim/support_data/ossimDoqq.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc. 
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/support_data/ossimDtedAcc.h b/include/ossim/support_data/ossimDtedAcc.h
index 5674d64..c211d0d 100644
--- a/include/ossim/support_data/ossimDtedAcc.h
+++ b/include/ossim/support_data/ossimDtedAcc.h
@@ -1,6 +1,6 @@
 //*******************************************************************
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/support_data/ossimDtedDsi.h b/include/ossim/support_data/ossimDtedDsi.h
index dd20410..fa9bbd0 100644
--- a/include/ossim/support_data/ossimDtedDsi.h
+++ b/include/ossim/support_data/ossimDtedDsi.h
@@ -1,6 +1,6 @@
 //*******************************************************************
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/support_data/ossimDtedHdr.h b/include/ossim/support_data/ossimDtedHdr.h
index df8e933..28686c1 100644
--- a/include/ossim/support_data/ossimDtedHdr.h
+++ b/include/ossim/support_data/ossimDtedHdr.h
@@ -1,6 +1,6 @@
 //*******************************************************************
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/support_data/ossimDtedInfo.h b/include/ossim/support_data/ossimDtedInfo.h
index 46c27fa..553518f 100644
--- a/include/ossim/support_data/ossimDtedInfo.h
+++ b/include/ossim/support_data/ossimDtedInfo.h
@@ -1,6 +1,6 @@
 //----------------------------------------------------------------------------
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/support_data/ossimDtedRecord.h b/include/ossim/support_data/ossimDtedRecord.h
index 9772b23..8695f25 100644
--- a/include/ossim/support_data/ossimDtedRecord.h
+++ b/include/ossim/support_data/ossimDtedRecord.h
@@ -1,6 +1,6 @@
 //*******************************************************************
 //
-// License:  LGPL
+// License:  MIT
 //
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/support_data/ossimDtedUhl.h b/include/ossim/support_data/ossimDtedUhl.h
index ff5c34a..c5f092f 100644
--- a/include/ossim/support_data/ossimDtedUhl.h
+++ b/include/ossim/support_data/ossimDtedUhl.h
@@ -1,6 +1,6 @@
 //*******************************************************************
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 // 
diff --git a/include/ossim/support_data/ossimDtedVol.h b/include/ossim/support_data/ossimDtedVol.h
index 40e6829..02d6208 100644
--- a/include/ossim/support_data/ossimDtedVol.h
+++ b/include/ossim/support_data/ossimDtedVol.h
@@ -1,6 +1,6 @@
 //*******************************************************************
 //
-// License:  LGPL
+// License:  MIT
 //
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/support_data/ossimEnviInfo.h b/include/ossim/support_data/ossimEnviInfo.h
index 3de69f0..d2d6d87 100644
--- a/include/ossim/support_data/ossimEnviInfo.h
+++ b/include/ossim/support_data/ossimEnviInfo.h
@@ -1,6 +1,6 @@
 //----------------------------------------------------------------------------
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/support_data/ossimFgdcTxtDoc.h b/include/ossim/support_data/ossimFgdcTxtDoc.h
index 19a603f..d94a676 100644
--- a/include/ossim/support_data/ossimFgdcTxtDoc.h
+++ b/include/ossim/support_data/ossimFgdcTxtDoc.h
@@ -2,7 +2,7 @@
 //
 // File ossimFgdcTxtDoc.h
 // 
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/support_data/ossimFgdcXmlDoc.h b/include/ossim/support_data/ossimFgdcXmlDoc.h
index a28896f..e000375 100644
--- a/include/ossim/support_data/ossimFgdcXmlDoc.h
+++ b/include/ossim/support_data/ossimFgdcXmlDoc.h
@@ -1,6 +1,6 @@
 //----------------------------------------------------------------------------
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/support_data/ossimGeoTiff.h b/include/ossim/support_data/ossimGeoTiff.h
index 052f9e9..07d5229 100644
--- a/include/ossim/support_data/ossimGeoTiff.h
+++ b/include/ossim/support_data/ossimGeoTiff.h
@@ -20,12 +20,11 @@
 #include <ossim/projection/ossimMapProjectionInfo.h>
 #include <ossim/projection/ossimProjection.h>
 #include <ossim/base/ossimRefPtr.h>
-
+#include <ossim/support_data/TiffHandlerState.h>
 #include <vector>
 
 #include <tiffio.h>
-#include <OpenThreads/Mutex>
-#include <OpenThreads/ScopedLock>
+#include <mutex>
 
 class ossimFilename;
 class ossimKeywordlist;
@@ -157,6 +156,8 @@ public:
     */
    bool readTags(TIFF* tiff, ossim_uint32 entryIdx, bool ownTiffPtrFlag);
 
+   bool readTags(std::shared_ptr<ossim::TiffHandlerState> state, 
+                 ossim_uint32 entryIdx);
    /**
     *  Returns the map zone as an interger.
     */
@@ -181,6 +182,11 @@ public:
    void setOssimProjectionName();
 
    /**
+    *  Attempts to set the ossim projection name from keys read.
+    */
+   void setOssimProjectionName(std::shared_ptr<ossim::TiffHandlerState> state, ossim_int32 entryIdx=0);
+
+   /**
     *  Returns an ossimString representing the ossim datum name code.
     *  Returns "unknown" if it can't find a match.
     */
@@ -191,6 +197,8 @@ public:
     */
    void setOssimDatumName();
 
+   void setOssimDatumName(std::shared_ptr<ossim::TiffHandlerState> state, ossim_int32 entryIdx=0);
+
    void getScale(std::vector<double>& scale) const;
    void getTiePoint(std::vector<double>& tie_point) const;
    void getModelTransformation(std::vector<double>& transform) const;
@@ -283,7 +291,7 @@ private:
    
    ossimPrivateGtifDef*  thePrivateDefinitions;
    
-   static OpenThreads::Mutex theMutex;
+   static std::mutex theMutex;
 };
 
 #endif
diff --git a/include/ossim/support_data/ossimIkonosMetaData.h b/include/ossim/support_data/ossimIkonosMetaData.h
index d6aae7b..1037cd9 100644
--- a/include/ossim/support_data/ossimIkonosMetaData.h
+++ b/include/ossim/support_data/ossimIkonosMetaData.h
@@ -1,6 +1,6 @@
 //*******************************************************************
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 // 
diff --git a/include/ossim/imaging/ossimImageMetaData.h b/include/ossim/support_data/ossimImageMetaData.h
similarity index 99%
rename from include/ossim/imaging/ossimImageMetaData.h
rename to include/ossim/support_data/ossimImageMetaData.h
index 88cdcfe..ceb2b74 100644
--- a/include/ossim/imaging/ossimImageMetaData.h
+++ b/include/ossim/support_data/ossimImageMetaData.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc.
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/support_data/ossimInfoBase.h b/include/ossim/support_data/ossimInfoBase.h
index 25d1980..cb0e6b0 100755
--- a/include/ossim/support_data/ossimInfoBase.h
+++ b/include/ossim/support_data/ossimInfoBase.h
@@ -1,6 +1,6 @@
 //----------------------------------------------------------------------------
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/support_data/ossimInfoFactoryRegistry.h b/include/ossim/support_data/ossimInfoFactoryRegistry.h
index d286eb8..70eb629 100644
--- a/include/ossim/support_data/ossimInfoFactoryRegistry.h
+++ b/include/ossim/support_data/ossimInfoFactoryRegistry.h
@@ -15,9 +15,9 @@
 #include <ossim/base/ossimConstants.h> /* for OSSIM_DLL macro */
 #include <ossim/base/ossimIosFwd.h> 
 #include <ossim/support_data/ossimInfoBase.h> 
-#include <OpenThreads/Mutex>
 #include <memory>
 #include <vector>
+#include <mutex>
 
 // Forward class declarations.
 class ossimInfoFactoryInterface;
@@ -95,7 +95,7 @@ protected:
    
    std::vector<ossimInfoFactoryInterface*> m_factoryList;
 
-   OpenThreads::Mutex m_mutex;
+   std::mutex m_mutex;
 
    static ossimInfoFactoryRegistry* m_instance;
 };
diff --git a/include/ossim/support_data/ossimJ2kInfo.h b/include/ossim/support_data/ossimJ2kInfo.h
index 38e8956..ed7d0fc 100644
--- a/include/ossim/support_data/ossimJ2kInfo.h
+++ b/include/ossim/support_data/ossimJ2kInfo.h
@@ -1,6 +1,6 @@
 //----------------------------------------------------------------------------
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/support_data/ossimJp2Info.h b/include/ossim/support_data/ossimJp2Info.h
index 594ab61..514699b 100644
--- a/include/ossim/support_data/ossimJp2Info.h
+++ b/include/ossim/support_data/ossimJp2Info.h
@@ -1,6 +1,6 @@
 //----------------------------------------------------------------------------
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/support_data/ossimJpipMessage.h b/include/ossim/support_data/ossimJpipMessage.h
index 88838de..9c81429 100644
--- a/include/ossim/support_data/ossimJpipMessage.h
+++ b/include/ossim/support_data/ossimJpipMessage.h
@@ -1,6 +1,6 @@
 /*********************************************************************************************
  *
- * License: LGPL Please see the top level LICENSE.txt
+ * License: MIT Please see the top level LICENSE.txt
  *
  * Author: Garrett Potts
  * 
diff --git a/include/ossim/support_data/ossimLasHdr.h b/include/ossim/support_data/ossimLasHdr.h
index 5d9a1c7..e1b1d32 100644
--- a/include/ossim/support_data/ossimLasHdr.h
+++ b/include/ossim/support_data/ossimLasHdr.h
@@ -2,7 +2,7 @@
 //
 // File: ossimLasHdr.h
 // 
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/support_data/ossimLasInfo.h b/include/ossim/support_data/ossimLasInfo.h
index 5a542de..0c470de 100644
--- a/include/ossim/support_data/ossimLasInfo.h
+++ b/include/ossim/support_data/ossimLasInfo.h
@@ -2,7 +2,7 @@
 //
 // File: ossimLibLasInfo.h
 // 
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/support_data/ossimNitfCommon.h b/include/ossim/support_data/ossimNitfCommon.h
index d3b4102..5e4c27f 100644
--- a/include/ossim/support_data/ossimNitfCommon.h
+++ b/include/ossim/support_data/ossimNitfCommon.h
@@ -1,6 +1,6 @@
 //----------------------------------------------------------------------------
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/support_data/ossimNitfCscrnaTag.h b/include/ossim/support_data/ossimNitfCscrnaTag.h
index 07eb738..e8bff64 100644
--- a/include/ossim/support_data/ossimNitfCscrnaTag.h
+++ b/include/ossim/support_data/ossimNitfCscrnaTag.h
@@ -1,6 +1,6 @@
 //----------------------------------------------------------------------------
 //
-// License:  LGPL
+// License:  MIT
 //
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/support_data/ossimNitfCsdidaTag.h b/include/ossim/support_data/ossimNitfCsdidaTag.h
index 661e11b..9fd1fa2 100644
--- a/include/ossim/support_data/ossimNitfCsdidaTag.h
+++ b/include/ossim/support_data/ossimNitfCsdidaTag.h
@@ -1,6 +1,6 @@
 //----------------------------------------------------------------------------
 //
-// License:  LGPL
+// License:  MIT
 //
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/support_data/ossimNitfCsexraTag.h b/include/ossim/support_data/ossimNitfCsexraTag.h
index 3c97b9a..6f3b838 100644
--- a/include/ossim/support_data/ossimNitfCsexraTag.h
+++ b/include/ossim/support_data/ossimNitfCsexraTag.h
@@ -1,6 +1,6 @@
 //----------------------------------------------------------------------------
 //
-// License:  LGPL
+// License:  MIT
 //
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/support_data/ossimNitfDesInformation.h b/include/ossim/support_data/ossimNitfDesInformation.h
index d988a20..8f652fe 100644
--- a/include/ossim/support_data/ossimNitfDesInformation.h
+++ b/include/ossim/support_data/ossimNitfDesInformation.h
@@ -88,7 +88,7 @@ private:
 
    char           m_de[DE_SIZE+1];
    char           m_desid[DESID_SIZE+1];
-   char 	  m_desver[DESVER_SIZE+1];
+   char 	        m_desver[DESVER_SIZE+1];
    char           m_declas[DECLAS_SIZE+1];
    char           m_desclsy[DESCLSY_SIZE+1];
    char           m_descode[DESCODE_SIZE+1];
diff --git a/include/ossim/support_data/ossimNitfEmbeddedRpfDes.h b/include/ossim/support_data/ossimNitfEmbeddedRpfDes.h
index b9edb5c..5400528 100644
--- a/include/ossim/support_data/ossimNitfEmbeddedRpfDes.h
+++ b/include/ossim/support_data/ossimNitfEmbeddedRpfDes.h
@@ -1,6 +1,6 @@
 //*******************************************************************
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/support_data/ossimNitfEngrdaTag.h b/include/ossim/support_data/ossimNitfEngrdaTag.h
index 76c0759..18eccbd 100644
--- a/include/ossim/support_data/ossimNitfEngrdaTag.h
+++ b/include/ossim/support_data/ossimNitfEngrdaTag.h
@@ -1,6 +1,6 @@
 //----------------------------------------------------------------------------
 //
-// License:  LGPL
+// License:  MIT
 //
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/support_data/ossimNitfGeoPositioningTag.h b/include/ossim/support_data/ossimNitfGeoPositioningTag.h
index dbf5c84..8c868de 100644
--- a/include/ossim/support_data/ossimNitfGeoPositioningTag.h
+++ b/include/ossim/support_data/ossimNitfGeoPositioningTag.h
@@ -1,6 +1,6 @@
 //********************************************************************
 //
-// License:  LGPL
+// License:  MIT
 //
 // See LICENSE.txt file in the top level directory for more details.
 // 
diff --git a/include/ossim/support_data/ossimNitfJ2klraTag.h b/include/ossim/support_data/ossimNitfJ2klraTag.h
index 5902809..6ff62a2 100644
--- a/include/ossim/support_data/ossimNitfJ2klraTag.h
+++ b/include/ossim/support_data/ossimNitfJ2klraTag.h
@@ -2,7 +2,7 @@
 //
 // File: ossimNitfJ2klraTag.h
 // 
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/support_data/ossimNitfLocalGeographicTag.h b/include/ossim/support_data/ossimNitfLocalGeographicTag.h
index 4b0cf85..0d44b32 100644
--- a/include/ossim/support_data/ossimNitfLocalGeographicTag.h
+++ b/include/ossim/support_data/ossimNitfLocalGeographicTag.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2004 Intelligence Data Systems. 
 //
-// LICENSE: LGPL
+// LICENSE: MIT
 //
 // see top level LICENSE.txt
 // 
diff --git a/include/ossim/support_data/ossimNitfMstgtaTag.h b/include/ossim/support_data/ossimNitfMstgtaTag.h
index b1e8e4a..c64da76 100644
--- a/include/ossim/support_data/ossimNitfMstgtaTag.h
+++ b/include/ossim/support_data/ossimNitfMstgtaTag.h
@@ -1,6 +1,6 @@
 //----------------------------------------------------------------------------
 //
-// License:  LGPL
+// License:  MIT
 //
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/support_data/ossimNitfNameConversionTables.h b/include/ossim/support_data/ossimNitfNameConversionTables.h
index cad4d09..d5a0116 100644
--- a/include/ossim/support_data/ossimNitfNameConversionTables.h
+++ b/include/ossim/support_data/ossimNitfNameConversionTables.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2004 Garrett Potts.
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/support_data/ossimNitfPiaimcTag.h b/include/ossim/support_data/ossimNitfPiaimcTag.h
index df30dce..13a311e 100644
--- a/include/ossim/support_data/ossimNitfPiaimcTag.h
+++ b/include/ossim/support_data/ossimNitfPiaimcTag.h
@@ -1,6 +1,6 @@
 //----------------------------------------------------------------------------
 //
-// License:  LGPL
+// License:  MIT
 //
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/support_data/ossimNitfProjectionParameterTag.h b/include/ossim/support_data/ossimNitfProjectionParameterTag.h
index 283aaea..48b9803 100644
--- a/include/ossim/support_data/ossimNitfProjectionParameterTag.h
+++ b/include/ossim/support_data/ossimNitfProjectionParameterTag.h
@@ -1,6 +1,6 @@
 //*******************************************************************
 //
-// License:  LGPL
+// License:  MIT
 //
 // See LICENSE.txt file in the top level directory for more details.
 // 
diff --git a/include/ossim/support_data/ossimNitfRegisteredDes.h b/include/ossim/support_data/ossimNitfRegisteredDes.h
index 692f8fb..83dd95c 100644
--- a/include/ossim/support_data/ossimNitfRegisteredDes.h
+++ b/include/ossim/support_data/ossimNitfRegisteredDes.h
@@ -1,6 +1,6 @@
 //*******************************************************************
 //
-// License:  LGPL
+// License:  MIT
 //
 // See LICENSE.txt file in the top level directory for more details.
 // 
diff --git a/include/ossim/support_data/ossimNitfRegisteredDesFactory.h b/include/ossim/support_data/ossimNitfRegisteredDesFactory.h
index 6659c64..457687d 100644
--- a/include/ossim/support_data/ossimNitfRegisteredDesFactory.h
+++ b/include/ossim/support_data/ossimNitfRegisteredDesFactory.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc. 
 //
-// LICENSE: LGPL see top level LICENSE.txt
+// LICENSE: MIT see top level LICENSE.txt
 // 
 // Author: Garrett Potts
 // Description: Nitf support class
diff --git a/include/ossim/support_data/ossimNitfRegisteredTagFactory.h b/include/ossim/support_data/ossimNitfRegisteredTagFactory.h
index 39b9668..0401469 100644
--- a/include/ossim/support_data/ossimNitfRegisteredTagFactory.h
+++ b/include/ossim/support_data/ossimNitfRegisteredTagFactory.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc. 
 //
-// LICENSE: LGPL see top level LICENSE.txt
+// LICENSE: MIT see top level LICENSE.txt
 // 
 // Author: Garrett Potts
 // Description: Nitf support class
diff --git a/include/ossim/support_data/ossimNitfRpcATag.h b/include/ossim/support_data/ossimNitfRpcATag.h
index f95f166..6315d82 100644
--- a/include/ossim/support_data/ossimNitfRpcATag.h
+++ b/include/ossim/support_data/ossimNitfRpcATag.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 Intelligence Data Systems. 
 //
-// LICENSE: LGPL
+// LICENSE: MIT
 //
 // see top level LICENSE.txt
 // 
diff --git a/include/ossim/support_data/ossimNitfRpcBTag.h b/include/ossim/support_data/ossimNitfRpcBTag.h
index f792086..98872f8 100644
--- a/include/ossim/support_data/ossimNitfRpcBTag.h
+++ b/include/ossim/support_data/ossimNitfRpcBTag.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 Intelligence Data Systems. 
 //
-// LICENSE: LGPL
+// LICENSE: MIT
 //
 // see top level LICENSE.txt
 // 
diff --git a/include/ossim/support_data/ossimNitfRpcBase.h b/include/ossim/support_data/ossimNitfRpcBase.h
index e85cfe2..a1f977e 100644
--- a/include/ossim/support_data/ossimNitfRpcBase.h
+++ b/include/ossim/support_data/ossimNitfRpcBase.h
@@ -1,6 +1,6 @@
 //*******************************************************************
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 // 
@@ -17,6 +17,7 @@
 #ifndef ossimNitfRpcBase_HEADER
 #define ossimNitfRpcBase_HEADER 1
 #include <ossim/support_data/ossimNitfRegisteredTag.h>
+#include <ossim/projection/ossimRpcModel.h>
 
 class OSSIM_DLL ossimNitfRpcBase : public ossimNitfRegisteredTag
 {
@@ -71,6 +72,11 @@ class OSSIM_DLL ossimNitfRpcBase : public ossimNitfRegisteredTag
   virtual void clearFields();
 
   /**
+   * For generating the RPC tag from existing RPC Model.
+   */
+  virtual void setRpcModelParams(ossimRefPtr<ossimRpcModel> rpc);
+
+  /**
    * @return The success record as a boolean.
    */
   bool getSuccess()const;
@@ -500,7 +506,7 @@ protected:
    *
    * Line Numerator Coefficients.
    *
-   * required 12 byte field ranging �0.999999E�9 Twenty coefficients for the
+   * required 12 byte field ranging �0.999999E�9 Twenty coefficients for the
    * polynomial
    *
    */     
@@ -511,7 +517,7 @@ protected:
    *
    * Line Denominato Coefficients.
    *
-   * required 12 byte field ranging �0.999999E�9 Twenty coefficients for the
+   * required 12 byte field ranging �0.999999E�9 Twenty coefficients for the
    * polynomial
    *
    */     
@@ -522,7 +528,7 @@ protected:
    *
    * samp Numerator Coefficients.
    *
-   * required 12 byte field ranging �0.999999E�9 Twenty coefficients for the
+   * required 12 byte field ranging �0.999999E�9 Twenty coefficients for the
    * polynomial
    *
    */     
@@ -533,7 +539,7 @@ protected:
    *
    * samp Denominator Coefficients.
    *
-   * required 12 byte field ranging �0.999999E�9 Twenty coefficients for the
+   * required 12 byte field ranging �0.999999E�9 Twenty coefficients for the
    * polynomial
    *
    */     
diff --git a/include/ossim/support_data/ossimNitfRpfTagFactory.h b/include/ossim/support_data/ossimNitfRpfTagFactory.h
index 520b592..555165a 100644
--- a/include/ossim/support_data/ossimNitfRpfTagFactory.h
+++ b/include/ossim/support_data/ossimNitfRpfTagFactory.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc. 
 //
-// LICENSE: LGPL  see top level LICENSE.txt
+// LICENSE: MIT  see top level LICENSE.txt
 // 
 // Author: Garrett Potts
 // Description: Nitf support class
diff --git a/include/ossim/support_data/ossimNitfSensraTag.h b/include/ossim/support_data/ossimNitfSensraTag.h
index 5e159ab..8c5d0ae 100644
--- a/include/ossim/support_data/ossimNitfSensraTag.h
+++ b/include/ossim/support_data/ossimNitfSensraTag.h
@@ -1,6 +1,6 @@
 //*******************************************************************
 //
-// License:  LGPL
+// License:  MIT
 //
 // See LICENSE.txt file in the top level directory for more details.
 // 
diff --git a/include/ossim/support_data/ossimNitfStdidcTag.h b/include/ossim/support_data/ossimNitfStdidcTag.h
index 2eb681c..9d51fde 100644
--- a/include/ossim/support_data/ossimNitfStdidcTag.h
+++ b/include/ossim/support_data/ossimNitfStdidcTag.h
@@ -1,6 +1,6 @@
 //*******************************************************************
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 // 
diff --git a/include/ossim/support_data/ossimNitfStreobTag.h b/include/ossim/support_data/ossimNitfStreobTag.h
index ffe0c20..27ce036 100644
--- a/include/ossim/support_data/ossimNitfStreobTag.h
+++ b/include/ossim/support_data/ossimNitfStreobTag.h
@@ -1,6 +1,6 @@
 //----------------------------------------------------------------------------
 //
-// License:  LGPL
+// License:  MIT
 //
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/support_data/ossimNitfUnknownTag.h b/include/ossim/support_data/ossimNitfUnknownTag.h
index 1ea6504..35799e0 100644
--- a/include/ossim/support_data/ossimNitfUnknownTag.h
+++ b/include/ossim/support_data/ossimNitfUnknownTag.h
@@ -1,6 +1,6 @@
 //----------------------------------------------------------------------------
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/support_data/ossimNitfUse00aTag.h b/include/ossim/support_data/ossimNitfUse00aTag.h
index cdbcfb9..3a7ce65 100644
--- a/include/ossim/support_data/ossimNitfUse00aTag.h
+++ b/include/ossim/support_data/ossimNitfUse00aTag.h
@@ -1,6 +1,6 @@
 //*******************************************************************
 //
-// License:  LGPL
+// License:  MIT
 //
 // See LICENSE.txt file in the top level directory for more details.
 // 
diff --git a/include/ossim/support_data/ossimNitfVqCompressionHeader.h b/include/ossim/support_data/ossimNitfVqCompressionHeader.h
index da09281..e2d4392 100644
--- a/include/ossim/support_data/ossimNitfVqCompressionHeader.h
+++ b/include/ossim/support_data/ossimNitfVqCompressionHeader.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2004 Garrett Potts
 //
-// LICENSE: LGPL see top level LICENSE.txt for more details
+// LICENSE: MIT see top level LICENSE.txt for more details
 // 
 // Author: Garrett Potts
 // Description: Nitf support class
diff --git a/include/ossim/support_data/ossimNitfXmlDataContentDes.h b/include/ossim/support_data/ossimNitfXmlDataContentDes.h
index 1915f41..fa815f1 100644
--- a/include/ossim/support_data/ossimNitfXmlDataContentDes.h
+++ b/include/ossim/support_data/ossimNitfXmlDataContentDes.h
@@ -15,7 +15,12 @@ public:
       DESSHSI_SIZE = 60,
       DESSHSV_SIZE = 10,
       DESSHSD_SIZE = 20,
-      DESSHTN_SIZE = 120
+      DESSHTN_SIZE = 120,
+      DESSHLPG_SIZE = 125,
+      DESSHLPT_SIZE = 25,
+      DESSHLI_SIZE = 20,
+      DESSHLIN_SIZE = 120,
+      DESSHABS_SIZE = 200
    };
    ossimNitfXmlDataContentDes();
 
@@ -58,7 +63,12 @@ protected:
    char m_desshsv[DESSHSV_SIZE+1];
    char m_desshsd[DESSHSD_SIZE+1];
    char m_desshtn[DESSHTN_SIZE+1];
-
+   char m_desshlpg[DESSHLPG_SIZE+1];
+   char m_desshlpt[DESSHLPT_SIZE+1];
+   char m_desshli[DESSHLI_SIZE+1];
+   char m_desshlin[DESSHLIN_SIZE+1];
+   char m_desshabs[DESSHABS_SIZE+1];
+   
    ossimString m_xmlString;
    ossimRefPtr<ossimXmlDocument> m_xmlDocument;
 };
diff --git a/include/ossim/support_data/ossimNmeaMessage.h b/include/ossim/support_data/ossimNmeaMessage.h
index 51223a6..48b6a3a 100644
--- a/include/ossim/support_data/ossimNmeaMessage.h
+++ b/include/ossim/support_data/ossimNmeaMessage.h
@@ -1,6 +1,6 @@
 //----------------------------------------------------------------------------
 //
-// License:  LGPL See top level LICENSE.txt file.
+// License:  MIT See top level LICENSE.txt file.
 //
 // File: ossimNmeaMessage.h
 //
diff --git a/include/ossim/support_data/ossimQuickbirdMetaData.h b/include/ossim/support_data/ossimQuickbirdMetaData.h
index bafe186..720246f 100644
--- a/include/ossim/support_data/ossimQuickbirdMetaData.h
+++ b/include/ossim/support_data/ossimQuickbirdMetaData.h
@@ -1,6 +1,6 @@
 //*******************************************************************
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 // 
diff --git a/include/ossim/support_data/ossimRpfAttributes.h b/include/ossim/support_data/ossimRpfAttributes.h
index 6cb64b0..3fa0671 100644
--- a/include/ossim/support_data/ossimRpfAttributes.h
+++ b/include/ossim/support_data/ossimRpfAttributes.h
@@ -1,6 +1,6 @@
 //----------------------------------------------------------------------------
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 // 
diff --git a/include/ossim/support_data/ossimRpfCoverageSection.h b/include/ossim/support_data/ossimRpfCoverageSection.h
index d0cd294..1401ec4 100644
--- a/include/ossim/support_data/ossimRpfCoverageSection.h
+++ b/include/ossim/support_data/ossimRpfCoverageSection.h
@@ -1,6 +1,6 @@
 //*******************************************************************
 //
-// License:  LGPL
+// License:  MIT
 //
 // See LICENSE.txt file in the top level directory for more details.
 // 
diff --git a/include/ossim/support_data/ossimRpfFrame.h b/include/ossim/support_data/ossimRpfFrame.h
index 0629955..41685d6 100644
--- a/include/ossim/support_data/ossimRpfFrame.h
+++ b/include/ossim/support_data/ossimRpfFrame.h
@@ -1,6 +1,6 @@
 //*******************************************************************
 //
-// License:  LGPL
+// License:  MIT
 //
 // See LICENSE.txt file in the top level directory for more details.
 // 
diff --git a/include/ossim/support_data/ossimRpfFrameEntry.h b/include/ossim/support_data/ossimRpfFrameEntry.h
index 9397efd..e2ec9ad 100644
--- a/include/ossim/support_data/ossimRpfFrameEntry.h
+++ b/include/ossim/support_data/ossimRpfFrameEntry.h
@@ -1,6 +1,6 @@
 //*******************************************************************
 //
-// License:  LGPL
+// License:  MIT
 //
 // See LICENSE.txt file in the top level directory for more details.
 // 
diff --git a/include/ossim/support_data/ossimRpfHeader.h b/include/ossim/support_data/ossimRpfHeader.h
index 502fccd..a818ffc 100644
--- a/include/ossim/support_data/ossimRpfHeader.h
+++ b/include/ossim/support_data/ossimRpfHeader.h
@@ -1,6 +1,6 @@
 //*******************************************************************
 //
-// License:  LGPL
+// License:  MIT
 //
 // See LICENSE.txt file in the top level directory for more details.
 // 
diff --git a/include/ossim/support_data/ossimRpfImageDescriptionSubheader.h b/include/ossim/support_data/ossimRpfImageDescriptionSubheader.h
index 1ed8554..b9858a5 100644
--- a/include/ossim/support_data/ossimRpfImageDescriptionSubheader.h
+++ b/include/ossim/support_data/ossimRpfImageDescriptionSubheader.h
@@ -1,6 +1,6 @@
 //*******************************************************************
 //
-// License:  LGPL
+// License:  MIT
 //
 // See LICENSE.txt file in the top level directory for more details.
 // 
diff --git a/include/ossim/support_data/ossimRpfInfo.h b/include/ossim/support_data/ossimRpfInfo.h
index 290924d..a621566 100644
--- a/include/ossim/support_data/ossimRpfInfo.h
+++ b/include/ossim/support_data/ossimRpfInfo.h
@@ -1,6 +1,6 @@
 //----------------------------------------------------------------------------
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/support_data/ossimRpfLocationSection.h b/include/ossim/support_data/ossimRpfLocationSection.h
index a1eeaaf..5d4a210 100644
--- a/include/ossim/support_data/ossimRpfLocationSection.h
+++ b/include/ossim/support_data/ossimRpfLocationSection.h
@@ -1,6 +1,6 @@
 //*******************************************************************
 //
-// License:  LGPL
+// License:  MIT
 //
 // See LICENSE.txt file in the top level directory for more details.
 // 
diff --git a/include/ossim/support_data/ossimRpfToc.h b/include/ossim/support_data/ossimRpfToc.h
index 95d6b77..df0d50b 100644
--- a/include/ossim/support_data/ossimRpfToc.h
+++ b/include/ossim/support_data/ossimRpfToc.h
@@ -1,6 +1,6 @@
 //*******************************************************************
 //
-// License:  LGPL
+// License:  MIT
 //
 // See LICENSE.txt file in the top level directory for more details.
 // 
diff --git a/include/ossim/support_data/ossimRpfTocEntry.h b/include/ossim/support_data/ossimRpfTocEntry.h
index 9debe6c..554e317 100644
--- a/include/ossim/support_data/ossimRpfTocEntry.h
+++ b/include/ossim/support_data/ossimRpfTocEntry.h
@@ -1,6 +1,6 @@
 //*******************************************************************
 //
-// License:  LGPL
+// License:  MIT
 //
 // See LICENSE.txt file in the top level directory for more details.
 // 
diff --git a/include/ossim/support_data/ossimSupportFilesList.h b/include/ossim/support_data/ossimSupportFilesList.h
index 0a46e38..62f67c7 100644
--- a/include/ossim/support_data/ossimSupportFilesList.h
+++ b/include/ossim/support_data/ossimSupportFilesList.h
@@ -1,6 +1,6 @@
 //*******************************************************************
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/support_data/ossimWavelength.h b/include/ossim/support_data/ossimWavelength.h
index 6535960..3c9f948 100644
--- a/include/ossim/support_data/ossimWavelength.h
+++ b/include/ossim/support_data/ossimWavelength.h
@@ -1,6 +1,6 @@
 //----------------------------------------------------------------------------
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/support_data/ossimWkt.h b/include/ossim/support_data/ossimWkt.h
index 58241c3..1ddaeff 100644
--- a/include/ossim/support_data/ossimWkt.h
+++ b/include/ossim/support_data/ossimWkt.h
@@ -1,6 +1,6 @@
 //----------------------------------------------------------------------------
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/support_data/ossimXmpInfo.h b/include/ossim/support_data/ossimXmpInfo.h
index 9a49de5..ad39e41 100644
--- a/include/ossim/support_data/ossimXmpInfo.h
+++ b/include/ossim/support_data/ossimXmpInfo.h
@@ -1,6 +1,6 @@
 //----------------------------------------------------------------------------
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/util/ossimAutRegUtil.h b/include/ossim/util/ossimAutRegUtil.h
index 4de0a48..0cffca4 100644
--- a/include/ossim/util/ossimAutRegUtil.h
+++ b/include/ossim/util/ossimAutRegUtil.h
@@ -1,7 +1,7 @@
 //----------------------------------------------------------------------------
 // File: ossimAutRegUtil.h
 // 
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/util/ossimChipperUtil.h b/include/ossim/util/ossimChipperUtil.h
index 73baf45..cdda53e 100644
--- a/include/ossim/util/ossimChipperUtil.h
+++ b/include/ossim/util/ossimChipperUtil.h
@@ -2,7 +2,7 @@
 //
 // File: ossimChipperUtil.h
 // 
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/util/ossimFileWalker.h b/include/ossim/util/ossimFileWalker.h
index c7c1f7a..2c9b398 100644
--- a/include/ossim/util/ossimFileWalker.h
+++ b/include/ossim/util/ossimFileWalker.h
@@ -2,7 +2,7 @@
 //
 // File: ossimFileWalker.h
 // 
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
@@ -20,9 +20,10 @@
 #include <ossim/base/ossimFilename.h>
 #include <ossim/parallel/ossimJob.h>
 #include <ossim/parallel/ossimJobMultiThreadQueue.h>
-#include <OpenThreads/Mutex>
 #include <string>
 #include <vector>
+#include <mutex>
+#include <memory>
 
 class ossimFilename;
 class ossimFileProcessorInterface;
@@ -157,12 +158,14 @@ private:
        */
       ossimFileWalkerJob(ossimFileProcessorInterface* fpi,
                          const ossimFilename& file);
+
+protected:
       /**
        * @brief Defines pure virtual ossimJob::start.
        *
        * This executes the call to m_processFileCallBackPtr.
        */
-      virtual void start();
+      virtual void run();
       
    private:
       ossimFileProcessorInterface* m_fileProcessor;
@@ -175,9 +178,9 @@ private:
    {
    public:
       ossimFileWalkerJobCallback();
-      virtual void started(ossimJob* job);
-      virtual void finished(ossimJob* job);
-      virtual void canceled(ossimJob* job);
+      virtual void started(std::shared_ptr<ossimJob> job);
+      virtual void finished(std::shared_ptr<ossimJob> job);
+      virtual void canceled(std::shared_ptr<ossimJob> job);
    };
 
    /**
@@ -211,12 +214,12 @@ private:
     * @param const ossimFilename& First parameter(argument) file to process.
     */
    ossimFileProcessorInterface*          m_fileProcessor;
-   ossimRefPtr<ossimJobMultiThreadQueue> m_jobQueue;
+   std::shared_ptr<ossimJobMultiThreadQueue> m_jobQueue;
    std::vector<std::string>              m_filteredExtensions;
    bool                                  m_recurseFlag;
    bool                                  m_waitOnDirFlag;
    bool                                  m_abortFlag;
-   OpenThreads::Mutex                    m_mutex;
+   std::mutex                            m_mutex;
 };
 
 #endif /* #ifndef ossimFileWalker_HEADER */
diff --git a/include/ossim/util/ossimHlzTool.h b/include/ossim/util/ossimHlzTool.h
index 7f4850a..d07be96 100644
--- a/include/ossim/util/ossimHlzTool.h
+++ b/include/ossim/util/ossimHlzTool.h
@@ -25,9 +25,9 @@
 #include <ossim/parallel/ossimJobMultiThreadQueue.h>
 #include <ossim/point_cloud/ossimPointCloudHandler.h>
 #include <ossim/util/ossimChipProcTool.h>
-#include <OpenThreads/ReadWriteMutex>
 #include <vector>
 
+#include <mutex>
 /*!
  *  Class for finding helicopter landing zones (HLZ) on a DEM given the final destination and max
  *  range from destination.
@@ -100,7 +100,6 @@ protected:
    public:
       PatchProcessorJob(ossimHlzTool* hlzUtil, const ossimIpt& origin, ossim_uint32 chip_id=0);
 
-      virtual void start();
       virtual bool level1Test() = 0;
       bool level2Test();
       bool maskTest();
@@ -112,7 +111,11 @@ protected:
       float m_nullValue;
 
       // ossim_uint32 m_chipId; // for debug
-      static OpenThreads::ReadWriteMutex m_bufMutex;
+      static std::mutex m_bufMutex;
+
+   protected:
+      virtual void run();
+
    };
 
    class LsFitPatchProcessorJob : public PatchProcessorJob
diff --git a/include/ossim/util/ossimImageUtil.h b/include/ossim/util/ossimImageUtil.h
index 86364d1..0740114 100644
--- a/include/ossim/util/ossimImageUtil.h
+++ b/include/ossim/util/ossimImageUtil.h
@@ -1,7 +1,7 @@
 //----------------------------------------------------------------------------
 // File: ossimImageUtil.h
 // 
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
@@ -24,9 +24,9 @@
 #include <ossim/base/ossimRefPtr.h>
 #include <ossim/imaging/ossimImageHandler.h>
 #include <ossim/imaging/ossimOverviewBuilderBase.h>
-#include <OpenThreads/Mutex>
 #include <ostream>
 #include <vector>
+#include <mutex>
 
 class ossimArgumentParser;
 class ossimFileWalker;
@@ -499,7 +499,7 @@ private:
    ossimRefPtr<ossimKeywordlist> m_kwl;
 
    ossimFileWalker*   m_fileWalker;
-   OpenThreads::Mutex m_mutex;
+   std::mutex m_mutex;
 
    ossim_int32 m_errorStatus;
 
diff --git a/include/ossim/util/ossimInfo.h b/include/ossim/util/ossimInfo.h
index 9dda4d1..f17a907 100644
--- a/include/ossim/util/ossimInfo.h
+++ b/include/ossim/util/ossimInfo.h
@@ -133,6 +133,13 @@ public:
     */
    void openImage(const ossimFilename& file);
 
+   /**
+    * @brief Opens image handler and stores in m_img data member.
+    * @param Image to open.
+    * @note Throws ossimException if image cannot be opened.
+    */
+   void openImageFromState(const ossimFilename& file);
+
    /** @brief Closes image if open. */
    void closeImage();
 
diff --git a/include/ossim/util/ossimOrthoIgen.h b/include/ossim/util/ossimOrthoIgen.h
index 09be91d..9185d28 100644
--- a/include/ossim/util/ossimOrthoIgen.h
+++ b/include/ossim/util/ossimOrthoIgen.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc. 
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/util/ossimRpfUtil.h b/include/ossim/util/ossimRpfUtil.h
index 95842e3..eeb3a5b 100644
--- a/include/ossim/util/ossimRpfUtil.h
+++ b/include/ossim/util/ossimRpfUtil.h
@@ -1,6 +1,6 @@
 //----------------------------------------------------------------------------
 //
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/include/ossim/util/ossimShorelineTool.h b/include/ossim/util/ossimShorelineTool.h
index 5d5f452..5ffe494 100644
--- a/include/ossim/util/ossimShorelineTool.h
+++ b/include/ossim/util/ossimShorelineTool.h
@@ -8,6 +8,7 @@
 #ifndef ossimShorelineUtil_HEADER
 #define ossimShorelineUtil_HEADER
 
+#include <ossim/ossimConfig.h>
 #include <ossim/base/ossimRefPtr.h>
 #include <ossim/base/ossimProcessInterface.h>
 #include <ossim/base/ossimFilename.h>
@@ -25,8 +26,8 @@
 #include <ossim/parallel/ossimJobMultiThreadQueue.h>
 #include <ossim/point_cloud/ossimPointCloudHandler.h>
 #include <ossim/util/ossimChipProcTool.h>
-#include <OpenThreads/ReadWriteMutex>
 #include <vector>
+#include <mutex>
 
 /*!
  *  Class for finding helicopter landing zones (HLZ) on a DEM given the final destination and max
@@ -66,10 +67,13 @@ protected:
    /** @brief Initializes arg parser and outputs usage. */
    void usage(ossimArgumentParser& ap);
    void addArguments(ossimArgumentParser& ap);
-   bool addPropsToJSON();
    void doThreshold();
    void autoComputeThreshold();
 
+#if OSSIM_HAS_JSONCPP
+   bool addPropsToJSON();
+#endif
+
    ossim_uint8 m_waterValue;
    ossim_uint8 m_marginalValue;
    ossim_uint8 m_landValue;
diff --git a/include/ossim/util/ossimSubImageTool.h b/include/ossim/util/ossimSubImageTool.h
new file mode 100644
index 0000000..cc2a5da
--- /dev/null
+++ b/include/ossim/util/ossimSubImageTool.h
@@ -0,0 +1,68 @@
+//**************************************************************************************************
+//
+//     OSSIM Open Source Geospatial Data Processing Library
+//     See top level LICENSE.txt file for license information
+//
+//**************************************************************************************************
+
+#ifndef ossimSubImageTool_HEADER
+#define ossimSubImageTool_HEADER
+
+#include <ossim/base/ossimRefPtr.h>
+#include <ossim/base/ossimFilename.h>
+#include <ossim/base/ossimGpt.h>
+#include <ossim/imaging/ossimImageSource.h>
+#include <ossim/util/ossimChipProcTool.h>
+
+/*!
+ *  Tool class for extracting a subimage rectangle from a full image. The original sensor model
+ *  is replaced with the subimage RPC representation. This is necessary as OSSIM does not support
+ *  sub-image offset in the sensor models yet.
+ */
+class OSSIMDLLEXPORT ossimSubImageTool : public ossimChipProcTool
+{
+public:
+   enum RpcGeomFormat { OGEOM, DG, JSON, XML };
+
+   ossimSubImageTool();
+   ~ossimSubImageTool();
+
+   /**
+    * Initializes the aurgument parser with expected parameters and options. It does not output
+    * anything. To see the usage, the caller will need to do something like:
+    *
+    *   ap.getApplicationUsage()->write(<ostream>);
+    */
+   virtual void setUsage(ossimArgumentParser& ap);
+
+   /**
+    * Initializes from command line arguments.
+    * @return FALSE if --help option requested or no params provided, so that derived classes can
+    * @note Throws ossimException on error.
+    */
+   virtual bool initialize(ossimArgumentParser& ap);
+
+   /**
+    * Reads processing params from KWL and prepares for execute. Returns TRUE if successful.
+    * @note Throws ossimException on error.
+    */
+   virtual void initialize(const ossimKeywordlist& kwl);
+
+   /**
+    * Writes product to output file if applicable. The product may also beAlways returns true since using exception on error.
+    * @note Throws ossimException on error.
+    */
+   virtual bool execute();
+
+   virtual ossimString getClassName() const { return "ossimSubImageTool"; }
+
+   /** Used by ossimUtilityFactory */
+   static const char* DESCRIPTION;
+
+protected:
+   virtual void initProcessingChain() {}
+
+   RpcGeomFormat m_geomFormat;
+};
+
+#endif
diff --git a/include/ossim/util/ossimViewshedTool.h b/include/ossim/util/ossimViewshedTool.h
index e3f0b65..41de68f 100644
--- a/include/ossim/util/ossimViewshedTool.h
+++ b/include/ossim/util/ossimViewshedTool.h
@@ -13,8 +13,7 @@
 #include <ossim/parallel/ossimJob.h>
 #include <ossim/parallel/ossimJobMultiThreadQueue.h>
 #include <ossim/util/ossimChipProcTool.h>
-#include <OpenThreads/ReadWriteMutex>
-
+#include <mutex>
 /*!
  *  Class for computing the viewshed on a DEM given the viewer location and max range of visibility
  */
@@ -101,7 +100,7 @@ protected:
    ossim_uint8 m_overlayValue;
    ossim_int32 m_reticleSize;
    bool m_simulation;
-   ossimRefPtr<ossimJobMultiThreadQueue> m_jobMtQueue;
+   std::shared_ptr<ossimJobMultiThreadQueue> m_jobMtQueue;
    ossim_uint32 m_numThreads;
    double m_startFov;
    double m_stopFov;
@@ -111,7 +110,7 @@ protected:
 
    // For debugging:
    double d_accumT;
-   OpenThreads::Mutex d_mutex;
+   std::mutex d_mutex;
 };
 
 /**
@@ -123,13 +122,14 @@ protected:
 class SectorProcessorJob : public ossimJob
 {
    friend class ossimViewshedTool;
-
-private:
+public:
    SectorProcessorJob(ossimViewshedTool* vs_util, ossim_uint32 sector, ossim_uint32 numRadials)
    : m_vsUtil (vs_util), m_sector (sector), m_numRadials (numRadials)  {}
 
-   virtual void start();
+protected:
+   virtual void run();
 
+private:
    ossimViewshedTool* m_vsUtil;
    ossim_uint32 m_sector;
    ossim_uint32 m_numRadials;
@@ -139,16 +139,18 @@ private:
 class RadialProcessorJob : public ossimJob
 {
    friend class ossimViewshedTool;
-
-private:
-   RadialProcessorJob(ossimViewshedTool* vs_util,
+public:
+  RadialProcessorJob(ossimViewshedTool* vs_util,
                       ossim_uint32 sector,
                       ossim_uint32 radial,
                       ossim_uint32 numRadials)
    : m_vsUtil (vs_util), m_sector (sector), m_radial (radial), m_numRadials (numRadials) {}
 
-   virtual void start();
 
+protected:
+   virtual void run();
+
+private:
    ossimViewshedTool* m_vsUtil;
    ossim_uint32 m_sector;
    ossim_uint32 m_radial;
@@ -168,7 +170,7 @@ public:
    static void doRadial(ossimViewshedTool* vs, ossim_uint32 s, ossim_uint32 r);
 
 private:
-   static OpenThreads::ReadWriteMutex m_bufMutex;
+   static std::mutex m_bufMutex;
    RadialProcessor() {};
 };
 
diff --git a/include/ossim/vec/ossimVpfDatabaseHeaderTableValidator.h b/include/ossim/vec/ossimVpfDatabaseHeaderTableValidator.h
index cb9a195..b28565a 100644
--- a/include/ossim/vec/ossimVpfDatabaseHeaderTableValidator.h
+++ b/include/ossim/vec/ossimVpfDatabaseHeaderTableValidator.h
@@ -1,5 +1,5 @@
 //-----------------------------------------------------------------
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //-----------------------------------------------------------------
diff --git a/include/ossim/vec/ossimVpfTableValidator.h b/include/ossim/vec/ossimVpfTableValidator.h
index 6b72705..4024844 100644
--- a/include/ossim/vec/ossimVpfTableValidator.h
+++ b/include/ossim/vec/ossimVpfTableValidator.h
@@ -1,5 +1,5 @@
 //-----------------------------------------------------------------
-// License:  LGPL
+// License:  MIT
 // 
 // See LICENSE.txt file in the top level directory for more details.
 //-----------------------------------------------------------------
diff --git a/include/ossim/vec/vpf.h b/include/ossim/vec/vpf.h
index aaf85e3..f1ee11a 100644
--- a/include/ossim/vec/vpf.h
+++ b/include/ossim/vec/vpf.h
@@ -1,7 +1,7 @@
 //*******************************************************************
 // Copyright (C) 2000 ImageLinks Inc. 
 //
-// License:  LGPL
+// License:  MIT
 //
 // See LICENSE.txt file in the top level directory for more details.
 //
diff --git a/share/ossim/templates/ossim_preferences_template b/share/ossim/templates/ossim_preferences_template
index c2972a2..68ab95e 100644
--- a/share/ossim/templates/ossim_preferences_template
+++ b/share/ossim/templates/ossim_preferences_template
@@ -340,6 +340,9 @@ plugin0.file:  $(OSSIM_INSTALL_PREFIX)/lib64/ossim/plugins/libossim_png_plugin.s
 plugin1.file: $(OSSIM_INSTALL_PREFIX)/lib64/ossim/plugins/libossim_ntm_plugin.so
 plugin1.options:
 
+plugin2.file: $(OSSIM_INSTALL_PREFIX)/lib64/ossim/plugins/libossim_csm_plugin.so
+// plugin2.options:
+
 plugin3.file:  $(OSSIM_INSTALL_PREFIX)/lib64/ossim/plugins/libossim_aws_plugin.so
 // plugin3.options:
 
@@ -352,6 +355,9 @@ plugin5.file:  $(OSSIM_INSTALL_PREFIX)/lib64/ossim/plugins/libossim_kakadu_plugi
 plugin15.file: $(OSSIM_INSTALL_PREFIX)/lib64/ossim/plugins/libossim_mrsid_plugin.so
 // plugin15 .options:
 
+plugin16.file: $(OSSIM_INSTALL_PREFIX)/lib64/ossim/plugins/libossim_isa_plugin.so
+// plugin15 .options:
+
 plugin20.file: $(OSSIM_INSTALL_PREFIX)/lib64/ossim/plugins/libossim_cnes_plugin.so
 // plugin20.options:
 
@@ -749,3 +755,30 @@ ossim.plugins.aws.s3.cacheInvalidLocations: true
 //ossim.stream.factory.registry.istream.buffer1.enableBlocked: false
 //ossim.stream.factory.registry.istream.buffer1.includePattern: ^/
 //ossim.stream.factory.registry.istream.buffer1.size: 65536
+
+
+// Default the DES parser to true
+des_parser: true
+
+ossim.plugins.csm.plugin_path: $(MSP_HOME)/plugins
+
+// Used to turn off plugins.  
+//
+// example values:
+//   .*  will enable all plugins
+//   SIX|WV.* will enable all SIX library sicd and sidd plugins and 
+//            world view plugins
+ossim.plugins.csm.enable_plugins: .*
+
+// Used to turn off plugins.
+//
+// example values:
+//   .*  will disable all plugins
+//   SIX|WV.* will disable SIX library sicd and sidd plugins and 
+//            world view plugins
+//ossim.plugins.csm.disable_plugins: .*
+
+// For CSM only builds you must specify the data directory in the keywordlist.
+// Uncomment this out and specify the values
+//
+//ossim.plugins.csm.data_dir:
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 68e4586..5d92e33 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -34,7 +34,14 @@ ELSE (OSSIM_HAS_HDF5)
    message( STATUS "HDF5 components are being excluded from the build." )
 ENDIF (OSSIM_HAS_HDF5)
 
-ADD_DEFINITIONS("-DOSSIMMAKINGDLL")
+IF (WIN32)
+   IF (BUILD_SHARED)
+      ADD_DEFINITIONS("-DOSSIMMAKINGDLL")
+    ELSE (BUILD_SHARED)
+      ADD_DEFINITIONS("-DOSSIM_STATIC")
+   ENDIF (BUILD_SHARED)
+ENDIF (WIN32)
+
 ############################### GRAB HEADERS #####################################
 FILE(GLOB ossim_HDRS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/../include/ossim/*.h")
 FILE(GLOB ossim_base_HDRS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/../include/ossim/base/*.h")
diff --git a/src/base/Barrier.cpp b/src/base/Barrier.cpp
new file mode 100644
index 0000000..b0679bb
--- /dev/null
+++ b/src/base/Barrier.cpp
@@ -0,0 +1,72 @@
+#include <ossim/base/Barrier.h>
+
+ossim::Barrier::Barrier(ossim_int32 maxCount)
+: m_maxCount(maxCount),
+  m_blockedCount(0),
+  m_waitCount(0)
+{
+
+}
+
+ossim::Barrier::~Barrier()
+{
+   reset();
+}
+
+void ossim::Barrier::block()
+{
+   std::unique_lock<std::mutex> lock(m_mutex);
+   ++m_blockedCount;
+   if(m_blockedCount < m_maxCount)
+   {
+      ++m_waitCount;
+      m_conditionalBlock.wait(lock, [this]{return m_blockedCount>=m_maxCount;} );
+      --m_waitCount;         
+   }
+   else
+   {
+      m_conditionalBlock.notify_all();
+   }
+   // always notify the conditional wait just in case anyone is waiting
+   m_conditionalWait.notify_all();
+}
+
+void ossim::Barrier::reset()
+{
+   std::unique_lock<std::mutex> lock(m_mutex);
+   // force the condition on any waiting threads
+   m_blockedCount = m_maxCount;
+   if(m_waitCount.load() > 0){
+      m_conditionalBlock.notify_all(); 
+      // wait until the wait count goes back to zero
+      m_conditionalWait.wait(lock, [this]{return m_waitCount.load()<1;});
+   }
+   // should be safe to reset everything at this point 
+   m_blockedCount = 0;
+   m_waitCount    = 0;
+}
+
+void ossim::Barrier::reset(ossim_int32 maxCount)
+{
+   // all threads should be released after this call
+   reset();
+   {
+      // now safe to update the new max count
+      std::unique_lock<std::mutex> lock(m_mutex);
+      m_maxCount = maxCount;
+   }
+}
+
+ossim_int32 ossim::Barrier::getMaxCount()const
+{ 
+   std::lock_guard<std::mutex> lock(m_mutex);
+   return m_maxCount; 
+}
+
+ossim_int32 ossim::Barrier::getBlockedCount()const
+{
+   std::lock_guard<std::mutex> lock(m_mutex);
+   return m_blockedCount; 
+}
+
+
diff --git a/src/base/Block.cpp b/src/base/Block.cpp
new file mode 100644
index 0000000..8a82a37
--- /dev/null
+++ b/src/base/Block.cpp
@@ -0,0 +1,84 @@
+#include <ossim/base/Block.h>
+#include <iostream>
+
+ossim::Block::Block(bool releaseFlag)
+:m_release(releaseFlag),
+m_waitCount(0)
+{
+
+}
+
+ossim::Block::~Block()
+{
+   release();
+   {
+      std::unique_lock<std::mutex> lock(m_mutex);
+      if(m_waitCount>0)
+      {
+         m_conditionalWait.wait(lock, [this]{return m_waitCount.load()<1;});
+      }
+   }
+}
+
+void ossim::Block::set(bool releaseFlag)
+{
+   {
+      std::unique_lock<std::mutex> lock(m_mutex);
+
+      m_release = releaseFlag;      
+   }
+   m_conditionVariable.notify_all();
+}
+
+void ossim::Block::block()
+{
+   std::unique_lock<std::mutex> lock(m_mutex);
+   if(!m_release)
+   {
+      ++m_waitCount;
+      m_conditionVariable.wait(lock, [this]{
+         return (m_release.load() == true);
+      });
+      --m_waitCount;
+      if(m_waitCount < 0) m_waitCount = 0;
+   }
+   m_conditionVariable.notify_all();   
+   m_conditionalWait.notify_all();
+}
+
+void ossim::Block::block(ossim_uint64 waitTimeMillis)
+{
+   std::unique_lock<std::mutex> lock(m_mutex);
+   if(!m_release)
+   {
+      ++m_waitCount;
+      m_conditionVariable.wait_for(lock, 
+                                   std::chrono::milliseconds(waitTimeMillis),
+                                   [this]{
+         return (m_release.load() == true);
+      });
+      --m_waitCount;
+      if(m_waitCount < 0) m_waitCount = 0;
+   }
+   m_conditionVariable.notify_all();   
+   m_conditionalWait.notify_all();
+}
+void ossim::Block::release()
+{
+   {   
+      std::unique_lock<std::mutex> lock(m_mutex);
+      if(!m_release)
+      {
+         m_release = true;
+      }
+      m_conditionVariable.notify_all();
+   }
+}
+
+void ossim::Block::reset()
+{
+   std::unique_lock<std::mutex> lock(m_mutex);
+
+   m_release   = false;
+   m_waitCount = 0;
+}
diff --git a/src/base/ossimBlockStreamBuffer.cpp b/src/base/BlockStreamBuffer.cpp
similarity index 95%
rename from src/base/ossimBlockStreamBuffer.cpp
rename to src/base/BlockStreamBuffer.cpp
index e4dd6b0..dec4880 100644
--- a/src/base/ossimBlockStreamBuffer.cpp
+++ b/src/base/BlockStreamBuffer.cpp
@@ -1,12 +1,14 @@
-#include <ossim/base/ossimBlockStreamBuffer.h>
+#include <ossim/base/BlockStreamBuffer.h>
 #include <ossim/base/ossimTrace.h>
 #include <cstring> /* for memcpy */
 
 static ossimTrace traceDebug("BlockStreamBuffer:debug");
 
 ossim::BlockStreamBuffer::BlockStreamBuffer(ossim::istream* adaptStream, ossim_uint64 blockSize)
-:  m_adaptStream(adaptStream),
-   m_currentPosValue(0)
+   :  m_blockBuffer(),
+      m_currentPosValue(0),
+      m_blockInfo(),
+      m_adaptStream(adaptStream)
 {
    m_blockInfo.m_blockSize = blockSize;
    if(m_blockInfo.m_blockSize)
@@ -74,9 +76,8 @@ void ossim::BlockStreamBuffer::loadBlock()
    setgPtrs();
 }
 
-std::streambuf::pos_type ossim::BlockStreamBuffer::seekoff(off_type offset, 
-                         std::ios_base::seekdir dir,
-                         std::ios_base::openmode mode)
+std::streambuf::pos_type ossim::BlockStreamBuffer::seekoff(
+   off_type offset, std::ios_base::seekdir dir, std::ios_base::openmode /* mode */)
 {
    // make sure we are in synch with current pos
    // gptr can be updated by other means
@@ -129,7 +130,6 @@ std::streambuf::pos_type ossim::BlockStreamBuffer::seekpos(pos_type pos,
    {
       ossimNotify(ossimNotifyLevel_DEBUG)
          << "BlockStreamBuffer::seekpos DEBUG: entered with absolute position: " << pos << "\n";
-
    }
    pos_type result = pos_type(off_type(-1));
 
diff --git a/src/base/RWLock.cpp b/src/base/RWLock.cpp
new file mode 100644
index 0000000..f95787d
--- /dev/null
+++ b/src/base/RWLock.cpp
@@ -0,0 +1,68 @@
+#include <ossim/base/RWLock.h>
+
+ossim::RWLock::RWLock() :
+        m_refCounter(0),
+        MIN_INT(std::numeric_limits<int>::min())
+{
+
+}
+
+void ossim::RWLock::lockWrite()
+{
+    int expected = 0;
+    if(!m_refCounter.compare_exchange_strong(expected, MIN_INT,
+                                             std::memory_order_acquire,
+                                             std::memory_order_relaxed)){
+        expected = 0;
+
+        std::unique_lock<std::mutex> lk(m_waitMutex);
+        m_waitConditional.wait(lk, [this,&expected] {
+            if(!m_refCounter.compare_exchange_strong(expected, MIN_INT,
+                                                     std::memory_order_acquire,
+                                                     std::memory_order_relaxed)){
+                expected = 0;
+                return false;
+            }
+            return true;
+        });
+        lk.unlock();
+    }
+}
+
+bool ossim::RWLock::tryLockWrite() 
+{
+    int expected = 0;
+    return m_refCounter.compare_exchange_strong(expected, MIN_INT,
+                                                std::memory_order_acquire,
+                                                std::memory_order_relaxed);
+}
+
+void ossim::RWLock::unlockWrite() 
+{
+    m_refCounter.store(0, std::memory_order_release);
+    m_waitConditional.notify_all();
+}
+
+void ossim::RWLock::lockRead() 
+{
+    if(m_refCounter.fetch_add(1, std::memory_order_acquire) < 0){
+        m_refCounter.fetch_sub(1, std::memory_order_release);
+
+        std::unique_lock<std::mutex> lk(m_waitMutex);
+        m_waitConditional.wait(lk, [this]{
+            return m_refCounter.fetch_add(1, std::memory_order_acquire) >= 0;
+        });
+        lk.unlock();
+    }
+}
+
+bool ossim::RWLock::tryLockRead() 
+{
+    return m_refCounter.fetch_add(1, std::memory_order_acquire) >= 0;
+}
+
+void ossim::RWLock::unlockRead() 
+{
+    m_refCounter.fetch_sub(1, std::memory_order_release);
+    m_waitConditional.notify_one();
+}
diff --git a/src/base/State.cpp b/src/base/State.cpp
new file mode 100644
index 0000000..4776cbd
--- /dev/null
+++ b/src/base/State.cpp
@@ -0,0 +1,16 @@
+#include <ossim/base/State.h>
+
+
+bool ossim::State::load(const ossimKeywordlist& kwl,
+                        const ossimString& prefix)
+{
+   return true;
+}
+
+bool ossim::State::save(ossimKeywordlist& kwl,
+                        const ossimString& prefix)const
+{
+   kwl.add(prefix, "type", getTypeName(), true);
+
+   return true;
+}
diff --git a/src/base/Thread.cpp b/src/base/Thread.cpp
new file mode 100644
index 0000000..8997621
--- /dev/null
+++ b/src/base/Thread.cpp
@@ -0,0 +1,132 @@
+#include <ossim/base/Thread.h>
+
+ossim::Thread::Thread()
+:m_running(false),
+ m_interrupt(false),
+ m_pauseBarrier(std::make_shared<ossim::Barrier>(1))
+{
+}
+
+ossim::Thread::~Thread()
+{
+   if(m_thread)
+   {
+      // we will wait as a sanity but this should be done in derived Thread
+      waitForCompletion();
+      if(m_thread->joinable()) m_thread->join();
+      m_thread = 0;         
+   }
+   m_running = false;
+}
+
+void ossim::Thread::start()
+{
+   if(isInterruptable()||isRunning()) return;
+   m_running = true;
+
+   // we are managing the thread internal.  If we are not running then we may need to join
+   // before allocating a new thread
+   if(m_thread)
+   {
+      if(m_thread->joinable()) m_thread->join();
+   }
+
+   m_thread = std::make_shared<std::thread>(&Thread::runInternal, this);
+}
+
+void ossim::Thread::setCancel(bool flag)
+{
+   setInterruptable(flag);
+   if(flag)
+   {
+      // if it was paused we will resume.  Calling resume 
+      // will reset the barrier so we can cancel the process
+      //
+      resume();
+   }
+}
+
+void ossim::Thread::waitForCompletion()
+{
+   if(m_thread)
+   {
+      std::unique_lock<std::mutex> lock(m_runningMutex);
+      m_runningCondition.wait(lock, [&]{return !isRunning();} );
+   }
+}
+
+void ossim::Thread::pause()
+{
+   m_pauseBarrier->reset(2);
+}
+
+void ossim::Thread::resume()
+{
+   m_pauseBarrier->reset(1);
+}
+
+bool ossim::Thread::isPaused()const
+{
+   return (m_pauseBarrier->getBlockedCount()>0);
+}
+
+void ossim::Thread::sleepInSeconds(ossim_uint64 seconds)
+{
+   std::this_thread::sleep_for(std::chrono::seconds(seconds));
+}
+
+void ossim::Thread::sleepInMilliSeconds(ossim_uint64 millis)
+{
+   std::this_thread::sleep_for(std::chrono::milliseconds(millis));
+}
+
+void ossim::Thread::sleepInMicroSeconds(ossim_uint64 micros)
+{
+   std::this_thread::sleep_for(std::chrono::microseconds(micros));
+}
+
+ossim_uint64 ossim::Thread::getNumberOfProcessors()
+{
+   return std::thread::hardware_concurrency();
+}
+
+std::thread::id ossim::Thread::getCurrentThreadId()
+{
+   return std::this_thread::get_id();
+}
+
+void ossim::Thread::yieldCurrentThread()
+{
+    std::this_thread::yield();
+}
+
+void ossim::Thread::interrupt()
+{
+   if(m_interrupt)
+   {
+      throw ossim::Thread::Interrupt();
+   }
+   m_pauseBarrier->block();
+}
+
+void ossim::Thread::setInterruptable(bool flag)
+{
+   m_interrupt.store(flag, std::memory_order_relaxed);
+}
+
+void ossim::Thread::runInternal()
+{
+   try
+   {
+      if(!isInterruptable())
+      {
+         run();
+      }
+   }
+   catch(Interrupt& e)
+   {
+   }
+   m_running = false;
+   m_runningCondition.notify_all();
+}
+
diff --git a/src/base/jsoncpp.cpp b/src/base/jsoncpp.cpp
deleted file mode 100644
index 069ade3..0000000
--- a/src/base/jsoncpp.cpp
+++ /dev/null
@@ -1,5206 +0,0 @@
-/// Json-cpp amalgated source (http://jsoncpp.sourceforge.net/).
-/// It is intended to be used with #include "json/json.h"
-
-// //////////////////////////////////////////////////////////////////////
-// Beginning of content of file: LICENSE
-// //////////////////////////////////////////////////////////////////////
-
-/*
-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.
-
-*/
-
-// //////////////////////////////////////////////////////////////////////
-// End of content of file: LICENSE
-// //////////////////////////////////////////////////////////////////////
-
-
-
-
-
-
-#include <ossim/base/jsoncpp.h>
-
-#ifndef JSON_IS_AMALGAMATION
-#error "Compile with -I PATH_TO_JSON_DIRECTORY"
-#endif
-
-
-// //////////////////////////////////////////////////////////////////////
-// Beginning of content of file: src/lib_json/json_tool.h
-// //////////////////////////////////////////////////////////////////////
-
-// 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] = static_cast<char>(0x80 | (0x3f & (cp >> 6)));
-    result[0] = static_cast<char>(0xE0 | (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 [1,31]).
-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(LargestUInt) + 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(LargestUInt value, char*& current) {
-  *--current = 0;
-  do {
-    *--current = static_cast<signed char>(value % 10U + static_cast<unsigned>('0'));
-    value /= 10;
-  } while (value != 0);
-}
-
-/** Change ',' to '.' everywhere in buffer.
- *
- * We had a sophisticated way, but it did not work in WinCE.
- * @see https://github.com/open-source-parsers/jsoncpp/pull/9
- */
-static inline void fixNumericLocale(char* begin, char* end) {
-  while (begin < end) {
-    if (*begin == ',') {
-      *begin = '.';
-    }
-    ++begin;
-  }
-}
-
-} // namespace Json {
-
-#endif // LIB_JSONCPP_JSON_TOOL_H_INCLUDED
-
-// //////////////////////////////////////////////////////////////////////
-// End of content of file: src/lib_json/json_tool.h
-// //////////////////////////////////////////////////////////////////////
-
-
-
-
-
-
-// //////////////////////////////////////////////////////////////////////
-// Beginning of content of file: src/lib_json/json_reader.cpp
-// //////////////////////////////////////////////////////////////////////
-
-// Copyright 2007-2011 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
-
-#if !defined(JSON_IS_AMALGAMATION)
-#include <json/assertions.h>
-#include <json/reader.h>
-#include <json/value.h>
-#include "json_tool.h"
-#endif // if !defined(JSON_IS_AMALGAMATION)
-#include <utility>
-#include <cstdio>
-#include <cassert>
-#include <cstring>
-#include <istream>
-#include <sstream>
-#include <memory>
-#include <set>
-#include <limits>
-
-#if defined(_MSC_VER)
-#if !defined(WINCE) && defined(__STDC_SECURE_LIB__) && _MSC_VER >= 1500 // VC++ 9.0 and above
-#define snprintf sprintf_s
-#elif _MSC_VER >= 1900 // VC++ 14.0 and above
-#define snprintf std::snprintf
-#else
-#define snprintf _snprintf
-#endif
-#elif defined(__ANDROID__) || defined(__QNXNTO__)
-#define snprintf snprintf
-#elif __cplusplus >= 201103L
-#if !defined(__MINGW32__) && !defined(__CYGWIN__)
-#define snprintf std::snprintf
-#endif
-#endif
-
-#if defined(__QNXNTO__)
-#define sscanf std::sscanf
-#endif
-
-#if defined(_MSC_VER) && _MSC_VER >= 1400 // VC++ 8.0
-// Disable warning about strdup being deprecated.
-#pragma warning(disable : 4996)
-#endif
-
-static int const stackLimit_g = 1000;
-static int       stackDepth_g = 0;  // see readValue()
-
-namespace Json {
-
-#if __cplusplus >= 201103L || (defined(_CPPLIB_VER) && _CPPLIB_VER >= 520)
-typedef std::unique_ptr<CharReader> CharReaderPtr;
-#else
-typedef std::auto_ptr<CharReader>   CharReaderPtr;
-#endif
-
-// Implementation of class Features
-// ////////////////////////////////
-
-Features::Features()
-    : allowComments_(true), strictRoot_(false),
-      allowDroppedNullPlaceholders_(false), allowNumericKeys_(false) {}
-
-Features Features::all() { return Features(); }
-
-Features Features::strictMode() {
-  Features features;
-  features.allowComments_ = false;
-  features.strictRoot_ = true;
-  features.allowDroppedNullPlaceholders_ = false;
-  features.allowNumericKeys_ = false;
-  return features;
-}
-
-// Implementation of class Reader
-// ////////////////////////////////
-
-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()
-    : errors_(), document_(), begin_(), end_(), current_(), lastValueEnd_(),
-      lastValue_(), commentsBefore_(), features_(Features::all()),
-      collectComments_() {}
-
-Reader::Reader(const Features& features)
-    : errors_(), document_(), begin_(), end_(), current_(), lastValueEnd_(),
-      lastValue_(), commentsBefore_(), features_(features), collectComments_() {
-}
-
-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);
-
-  stackDepth_g = 0;  // Yes, this is bad coding, but options are limited.
-  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() {
-  // This is a non-reentrant way to support a stackLimit. Terrible!
-  // But this deprecated class has a security problem: Bad input can
-  // cause a seg-fault. This seems like a fair, binary-compatible way
-  // to prevent the problem.
-  if (stackDepth_g >= stackLimit_g) throwRuntimeError("Exceeded stackLimit in readValue().");
-  ++stackDepth_g;
-
-  Token token;
-  skipCommentTokens(token);
-  bool successful = true;
-
-  if (collectComments_ && !commentsBefore_.empty()) {
-    currentValue().setComment(commentsBefore_, commentBefore);
-    commentsBefore_ = "";
-  }
-
-  switch (token.type_) {
-  case tokenObjectBegin:
-    successful = readObject(token);
-    currentValue().setOffsetLimit(current_ - begin_);
-    break;
-  case tokenArrayBegin:
-    successful = readArray(token);
-    currentValue().setOffsetLimit(current_ - begin_);
-    break;
-  case tokenNumber:
-    successful = decodeNumber(token);
-    break;
-  case tokenString:
-    successful = decodeString(token);
-    break;
-  case tokenTrue:
-    {
-    Value v(true);
-    currentValue().swapPayload(v);
-    currentValue().setOffsetStart(token.start_ - begin_);
-    currentValue().setOffsetLimit(token.end_ - begin_);
-    }
-    break;
-  case tokenFalse:
-    {
-    Value v(false);
-    currentValue().swapPayload(v);
-    currentValue().setOffsetStart(token.start_ - begin_);
-    currentValue().setOffsetLimit(token.end_ - begin_);
-    }
-    break;
-  case tokenNull:
-    {
-    Value v;
-    currentValue().swapPayload(v);
-    currentValue().setOffsetStart(token.start_ - begin_);
-    currentValue().setOffsetLimit(token.end_ - begin_);
-    }
-    break;
-  case tokenArraySeparator:
-  case tokenObjectEnd:
-  case tokenArrayEnd:
-    if (features_.allowDroppedNullPlaceholders_) {
-      // "Un-read" the current token and mark the current value as a null
-      // token.
-      current_--;
-      Value v;
-      currentValue().swapPayload(v);
-      currentValue().setOffsetStart(current_ - begin_ - 1);
-      currentValue().setOffsetLimit(current_ - begin_);
-      break;
-    } // Else, fall through...
-  default:
-    currentValue().setOffsetStart(token.start_ - begin_);
-    currentValue().setOffsetLimit(token.end_ - begin_);
-    return addError("Syntax error: value, object or array expected.", token);
-  }
-
-  if (collectComments_) {
-    lastValueEnd_ = current_;
-    lastValue_ = &currentValue();
-  }
-
-  --stackDepth_g;
-  return successful;
-}
-
-void Reader::skipCommentTokens(Token& token) {
-  if (features_.allowComments_) {
-    do {
-      readToken(token);
-    } while (token.type_ == tokenComment);
-  } else {
-    readToken(token);
-  }
-}
-
-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;
-}
-
-static std::string normalizeEOL(Reader::Location begin, Reader::Location end) {
-  std::string normalized;
-  normalized.reserve(static_cast<size_t>(end - begin));
-  Reader::Location current = begin;
-  while (current != end) {
-    char c = *current++;
-    if (c == '\r') {
-      if (current != end && *current == '\n')
-         // convert dos EOL
-         ++current;
-      // convert Mac EOL
-      normalized += '\n';
-    } else {
-      normalized += c;
-    }
-  }
-  return normalized;
-}
-
-void
-Reader::addComment(Location begin, Location end, CommentPlacement placement) {
-  assert(collectComments_);
-  const std::string& normalized = normalizeEOL(begin, end);
-  if (placement == commentAfterOnSameLine) {
-    assert(lastValue_ != 0);
-    lastValue_->setComment(normalized, placement);
-  } else {
-    commentsBefore_ += normalized;
-  }
-}
-
-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 == '\n')
-      break;
-    if (c == '\r') {
-      // Consume DOS EOL. It will be normalized in addComment.
-      if (current_ != end_ && *current_ == '\n')
-        getNextChar();
-      // Break on Moc OS 9 EOL.
-      break;
-    }
-  }
-  return true;
-}
-
-void Reader::readNumber() {
-  const char *p = current_;
-  char c = '0'; // stopgap for already consumed character
-  // integral part
-  while (c >= '0' && c <= '9')
-    c = (current_ = p) < end_ ? *p++ : 0;
-  // fractional part
-  if (c == '.') {
-    c = (current_ = p) < end_ ? *p++ : 0;
-    while (c >= '0' && c <= '9')
-      c = (current_ = p) < end_ ? *p++ : 0;
-  }
-  // exponential part
-  if (c == 'e' || c == 'E') {
-    c = (current_ = p) < end_ ? *p++ : 0;
-    if (c == '+' || c == '-')
-      c = (current_ = p) < end_ ? *p++ : 0;
-    while (c >= '0' && c <= '9')
-      c = (current_ = p) < end_ ? *p++ : 0;
-  }
-}
-
-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;
-  Value init(objectValue);
-  currentValue().swapPayload(init);
-  currentValue().setOffsetStart(tokenStart.start_ - begin_);
-  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;
-    name = "";
-    if (tokenName.type_ == tokenString) {
-      if (!decodeString(tokenName, name))
-        return recoverFromError(tokenObjectEnd);
-    } else if (tokenName.type_ == tokenNumber && features_.allowNumericKeys_) {
-      Value numberName;
-      if (!decodeNumber(tokenName, numberName))
-        return recoverFromError(tokenObjectEnd);
-      name = numberName.asString();
-    } else {
-      break;
-    }
-
-    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) {
-  Value init(arrayValue);
-  currentValue().swapPayload(init);
-  currentValue().setOffsetStart(tokenStart.start_ - begin_);
-  skipSpaces();
-  if (*current_ == ']') // empty array
-  {
-    Token endArray;
-    readToken(endArray);
-    return true;
-  }
-  int index = 0;
-  for (;;) {
-    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) {
-  Value decoded;
-  if (!decodeNumber(token, decoded))
-    return false;
-  currentValue().swapPayload(decoded);
-  currentValue().setOffsetStart(token.start_ - begin_);
-  currentValue().setOffsetLimit(token.end_ - begin_);
-  return true;
-}
-
-bool Reader::decodeNumber(Token& token, Value& decoded) {
-  // 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;
-  // TODO: Help the compiler do the div and mod at compile time or get rid of them.
-  Value::LargestUInt maxIntegerValue =
-      isNegative ? Value::LargestUInt(Value::maxLargestInt) + 1
-                 : Value::maxLargestUInt;
-  Value::LargestUInt threshold = maxIntegerValue / 10;
-  Value::LargestUInt value = 0;
-  while (current < token.end_) {
-    Char c = *current++;
-    if (c < '0' || c > '9')
-      return decodeDouble(token, decoded);
-    Value::UInt digit(static_cast<Value::UInt>(c - '0'));
-    if (value >= threshold) {
-      // We've hit or exceeded the max value divided by 10 (rounded down). If
-      // a) we've only just touched the limit, b) this is the last digit, and
-      // c) it's small enough to fit in that rounding delta, we're okay.
-      // Otherwise treat this number as a double to avoid overflow.
-      if (value > threshold || current != token.end_ ||
-          digit > maxIntegerValue % 10) {
-        return decodeDouble(token, decoded);
-      }
-    }
-    value = value * 10 + digit;
-  }
-  if (isNegative && value == maxIntegerValue)
-    decoded = Value::minLargestInt;
-  else if (isNegative)
-    decoded = -Value::LargestInt(value);
-  else if (value <= Value::LargestUInt(Value::maxInt))
-    decoded = Value::LargestInt(value);
-  else
-    decoded = value;
-  return true;
-}
-
-bool Reader::decodeDouble(Token& token) {
-  Value decoded;
-  if (!decodeDouble(token, decoded))
-    return false;
-  currentValue().swapPayload(decoded);
-  currentValue().setOffsetStart(token.start_ - begin_);
-  currentValue().setOffsetLimit(token.end_ - begin_);
-  return true;
-}
-
-bool Reader::decodeDouble(Token& token, Value& decoded) {
-  double value = 0;
-  std::string buffer(token.start_, token.end_);
-  JSONCPP_ISTRINGSTREAM is(buffer);
-  if (!(is >> value))
-    return addError("'" + std::string(token.start_, token.end_) +
-                        "' is not a number.",
-                    token);
-  decoded = value;
-  return true;
-}
-
-bool Reader::decodeString(Token& token) {
-  std::string decoded_string;
-  if (!decodeString(token, decoded_string))
-    return false;
-  Value decoded(decoded_string);
-  currentValue().swapPayload(decoded);
-  currentValue().setOffsetStart(token.start_ - begin_);
-  currentValue().setOffsetLimit(token.end_ - begin_);
-  return true;
-}
-
-bool Reader::decodeString(Token& token, std::string& decoded) {
-  decoded.reserve(static_cast<size_t>(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& ret_unicode) {
-  if (end - current < 4)
-    return addError(
-        "Bad unicode escape sequence in string: four digits expected.",
-        token,
-        current);
-  int 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);
-  }
-  ret_unicode = static_cast<unsigned int>(unicode);
-  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) {
-  size_t const errorCount = errors_.size();
-  Token skip;
-  for (;;) {
-    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];
-  snprintf(buffer, sizeof(buffer), "Line %d, Column %d", line, column);
-  return buffer;
-}
-
-// Deprecated. Preserved for backward compatibility
-std::string Reader::getFormatedErrorMessages() const {
-  return getFormattedErrorMessages();
-}
-
-std::string Reader::getFormattedErrorMessages() 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::vector<Reader::StructuredError> Reader::getStructuredErrors() const {
-  std::vector<Reader::StructuredError> allErrors;
-  for (Errors::const_iterator itError = errors_.begin();
-       itError != errors_.end();
-       ++itError) {
-    const ErrorInfo& error = *itError;
-    Reader::StructuredError structured;
-    structured.offset_start = error.token_.start_ - begin_;
-    structured.offset_limit = error.token_.end_ - begin_;
-    structured.message = error.message_;
-    allErrors.push_back(structured);
-  }
-  return allErrors;
-}
-
-bool Reader::pushError(const Value& value, const std::string& message) {
-  ptrdiff_t const length = end_ - begin_;
-  if(value.getOffsetStart() > length
-    || value.getOffsetLimit() > length)
-    return false;
-  Token token;
-  token.type_ = tokenError;
-  token.start_ = begin_ + value.getOffsetStart();
-  token.end_ = end_ + value.getOffsetLimit();
-  ErrorInfo info;
-  info.token_ = token;
-  info.message_ = message;
-  info.extra_ = 0;
-  errors_.push_back(info);
-  return true;
-}
-
-bool Reader::pushError(const Value& value, const std::string& message, const Value& extra) {
-  ptrdiff_t const length = end_ - begin_;
-  if(value.getOffsetStart() > length
-    || value.getOffsetLimit() > length
-    || extra.getOffsetLimit() > length)
-    return false;
-  Token token;
-  token.type_ = tokenError;
-  token.start_ = begin_ + value.getOffsetStart();
-  token.end_ = begin_ + value.getOffsetLimit();
-  ErrorInfo info;
-  info.token_ = token;
-  info.message_ = message;
-  info.extra_ = begin_ + extra.getOffsetStart();
-  errors_.push_back(info);
-  return true;
-}
-
-bool Reader::good() const {
-  return !errors_.size();
-}
-
-// exact copy of Features
-class OurFeatures {
-public:
-  static OurFeatures all();
-  bool allowComments_;
-  bool strictRoot_;
-  bool allowDroppedNullPlaceholders_;
-  bool allowNumericKeys_;
-  bool allowSingleQuotes_;
-  bool failIfExtra_;
-  bool rejectDupKeys_;
-  bool allowSpecialFloats_;
-  int stackLimit_;
-};  // OurFeatures
-
-// exact copy of Implementation of class Features
-// ////////////////////////////////
-
-OurFeatures OurFeatures::all() { return OurFeatures(); }
-
-// Implementation of class Reader
-// ////////////////////////////////
-
-// exact copy of Reader, renamed to OurReader
-class OurReader {
-public:
-  typedef char Char;
-  typedef const Char* Location;
-  struct StructuredError {
-    ptrdiff_t offset_start;
-    ptrdiff_t offset_limit;
-    std::string message;
-  };
-
-  OurReader(OurFeatures const& features);
-  bool parse(const char* beginDoc,
-             const char* endDoc,
-             Value& root,
-             bool collectComments = true);
-  std::string getFormattedErrorMessages() const;
-  std::vector<StructuredError> getStructuredErrors() const;
-  bool pushError(const Value& value, const std::string& message);
-  bool pushError(const Value& value, const std::string& message, const Value& extra);
-  bool good() const;
-
-private:
-  OurReader(OurReader const&);  // no impl
-  void operator=(OurReader const&);  // no impl
-
-  enum TokenType {
-    tokenEndOfStream = 0,
-    tokenObjectBegin,
-    tokenObjectEnd,
-    tokenArrayBegin,
-    tokenArrayEnd,
-    tokenString,
-    tokenNumber,
-    tokenTrue,
-    tokenFalse,
-    tokenNull,
-    tokenNaN,
-    tokenPosInf,
-    tokenNegInf,
-    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 readToken(Token& token);
-  void skipSpaces();
-  bool match(Location pattern, int patternLength);
-  bool readComment();
-  bool readCStyleComment();
-  bool readCppStyleComment();
-  bool readString();
-  bool readStringSingleQuote();
-  bool readNumber(bool checkInf);
-  bool readValue();
-  bool readObject(Token& token);
-  bool readArray(Token& token);
-  bool decodeNumber(Token& token);
-  bool decodeNumber(Token& token, Value& decoded);
-  bool decodeString(Token& token);
-  bool decodeString(Token& token, std::string& decoded);
-  bool decodeDouble(Token& token);
-  bool decodeDouble(Token& token, Value& decoded);
-  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_;
-  int stackDepth_;
-
-  OurFeatures const features_;
-  bool collectComments_;
-};  // OurReader
-
-// complete copy of Read impl, for OurReader
-
-OurReader::OurReader(OurFeatures const& features)
-    : errors_(), document_(), begin_(), end_(), current_(), lastValueEnd_(),
-      lastValue_(), commentsBefore_(),
-      stackDepth_(0),
-      features_(features), collectComments_() {
-}
-
-bool OurReader::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);
-
-  stackDepth_ = 0;
-  bool successful = readValue();
-  Token token;
-  skipCommentTokens(token);
-  if (features_.failIfExtra_) {
-    if (token.type_ != tokenError && token.type_ != tokenEndOfStream) {
-      addError("Extra non-whitespace after JSON value.", token);
-      return false;
-    }
-  }
-  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 OurReader::readValue() {
-  if (stackDepth_ >= features_.stackLimit_) throwRuntimeError("Exceeded stackLimit in readValue().");
-  ++stackDepth_;
-  Token token;
-  skipCommentTokens(token);
-  bool successful = true;
-
-  if (collectComments_ && !commentsBefore_.empty()) {
-    currentValue().setComment(commentsBefore_, commentBefore);
-    commentsBefore_ = "";
-  }
-
-  switch (token.type_) {
-  case tokenObjectBegin:
-    successful = readObject(token);
-    currentValue().setOffsetLimit(current_ - begin_);
-    break;
-  case tokenArrayBegin:
-    successful = readArray(token);
-    currentValue().setOffsetLimit(current_ - begin_);
-    break;
-  case tokenNumber:
-    successful = decodeNumber(token);
-    break;
-  case tokenString:
-    successful = decodeString(token);
-    break;
-  case tokenTrue:
-    {
-    Value v(true);
-    currentValue().swapPayload(v);
-    currentValue().setOffsetStart(token.start_ - begin_);
-    currentValue().setOffsetLimit(token.end_ - begin_);
-    }
-    break;
-  case tokenFalse:
-    {
-    Value v(false);
-    currentValue().swapPayload(v);
-    currentValue().setOffsetStart(token.start_ - begin_);
-    currentValue().setOffsetLimit(token.end_ - begin_);
-    }
-    break;
-  case tokenNull:
-    {
-    Value v;
-    currentValue().swapPayload(v);
-    currentValue().setOffsetStart(token.start_ - begin_);
-    currentValue().setOffsetLimit(token.end_ - begin_);
-    }
-    break;
-  case tokenNaN:
-    {
-    Value v(std::numeric_limits<double>::quiet_NaN());
-    currentValue().swapPayload(v);
-    currentValue().setOffsetStart(token.start_ - begin_);
-    currentValue().setOffsetLimit(token.end_ - begin_);
-    }
-    break;
-  case tokenPosInf:
-    {
-    Value v(std::numeric_limits<double>::infinity());
-    currentValue().swapPayload(v);
-    currentValue().setOffsetStart(token.start_ - begin_);
-    currentValue().setOffsetLimit(token.end_ - begin_);
-    }
-    break;
-  case tokenNegInf:
-    {
-    Value v(-std::numeric_limits<double>::infinity());
-    currentValue().swapPayload(v);
-    currentValue().setOffsetStart(token.start_ - begin_);
-    currentValue().setOffsetLimit(token.end_ - begin_);
-    }
-    break;
-  case tokenArraySeparator:
-  case tokenObjectEnd:
-  case tokenArrayEnd:
-    if (features_.allowDroppedNullPlaceholders_) {
-      // "Un-read" the current token and mark the current value as a null
-      // token.
-      current_--;
-      Value v;
-      currentValue().swapPayload(v);
-      currentValue().setOffsetStart(current_ - begin_ - 1);
-      currentValue().setOffsetLimit(current_ - begin_);
-      break;
-    } // else, fall through ...
-  default:
-    currentValue().setOffsetStart(token.start_ - begin_);
-    currentValue().setOffsetLimit(token.end_ - begin_);
-    return addError("Syntax error: value, object or array expected.", token);
-  }
-
-  if (collectComments_) {
-    lastValueEnd_ = current_;
-    lastValue_ = &currentValue();
-  }
-
-  --stackDepth_;
-  return successful;
-}
-
-void OurReader::skipCommentTokens(Token& token) {
-  if (features_.allowComments_) {
-    do {
-      readToken(token);
-    } while (token.type_ == tokenComment);
-  } else {
-    readToken(token);
-  }
-}
-
-bool OurReader::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 '\'':
-    if (features_.allowSingleQuotes_) {
-    token.type_ = tokenString;
-    ok = readStringSingleQuote();
-    break;
-    } // else continue
-  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':
-    token.type_ = tokenNumber;
-    readNumber(false);
-    break;
-  case '-':
-    if (readNumber(true)) {
-      token.type_ = tokenNumber;
-    } else {
-      token.type_ = tokenNegInf;
-      ok = features_.allowSpecialFloats_ && match("nfinity", 7);
-    }
-    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 'N':
-    if (features_.allowSpecialFloats_) {
-      token.type_ = tokenNaN;
-      ok = match("aN", 2);
-    } else {
-      ok = false;
-    }
-    break;
-  case 'I':
-    if (features_.allowSpecialFloats_) {
-      token.type_ = tokenPosInf;
-      ok = match("nfinity", 7);
-    } else {
-      ok = false;
-    }
-    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 OurReader::skipSpaces() {
-  while (current_ != end_) {
-    Char c = *current_;
-    if (c == ' ' || c == '\t' || c == '\r' || c == '\n')
-      ++current_;
-    else
-      break;
-  }
-}
-
-bool OurReader::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 OurReader::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
-OurReader::addComment(Location begin, Location end, CommentPlacement placement) {
-  assert(collectComments_);
-  const std::string& normalized = normalizeEOL(begin, end);
-  if (placement == commentAfterOnSameLine) {
-    assert(lastValue_ != 0);
-    lastValue_->setComment(normalized, placement);
-  } else {
-    commentsBefore_ += normalized;
-  }
-}
-
-bool OurReader::readCStyleComment() {
-  while (current_ != end_) {
-    Char c = getNextChar();
-    if (c == '*' && *current_ == '/')
-      break;
-  }
-  return getNextChar() == '/';
-}
-
-bool OurReader::readCppStyleComment() {
-  while (current_ != end_) {
-    Char c = getNextChar();
-    if (c == '\n')
-      break;
-    if (c == '\r') {
-      // Consume DOS EOL. It will be normalized in addComment.
-      if (current_ != end_ && *current_ == '\n')
-        getNextChar();
-      // Break on Moc OS 9 EOL.
-      break;
-    }
-  }
-  return true;
-}
-
-bool OurReader::readNumber(bool checkInf) {
-  const char *p = current_;
-  if (checkInf && p != end_ && *p == 'I') {
-    current_ = ++p;
-    return false;
-  }
-  char c = '0'; // stopgap for already consumed character
-  // integral part
-  while (c >= '0' && c <= '9')
-    c = (current_ = p) < end_ ? *p++ : 0;
-  // fractional part
-  if (c == '.') {
-    c = (current_ = p) < end_ ? *p++ : 0;
-    while (c >= '0' && c <= '9')
-      c = (current_ = p) < end_ ? *p++ : 0;
-  }
-  // exponential part
-  if (c == 'e' || c == 'E') {
-    c = (current_ = p) < end_ ? *p++ : 0;
-    if (c == '+' || c == '-')
-      c = (current_ = p) < end_ ? *p++ : 0;
-    while (c >= '0' && c <= '9')
-      c = (current_ = p) < end_ ? *p++ : 0;
-  }
-  return true;
-}
-bool OurReader::readString() {
-  Char c = 0;
-  while (current_ != end_) {
-    c = getNextChar();
-    if (c == '\\')
-      getNextChar();
-    else if (c == '"')
-      break;
-  }
-  return c == '"';
-}
-
-
-bool OurReader::readStringSingleQuote() {
-  Char c = 0;
-  while (current_ != end_) {
-    c = getNextChar();
-    if (c == '\\')
-      getNextChar();
-    else if (c == '\'')
-      break;
-  }
-  return c == '\'';
-}
-
-bool OurReader::readObject(Token& tokenStart) {
-  Token tokenName;
-  std::string name;
-  Value init(objectValue);
-  currentValue().swapPayload(init);
-  currentValue().setOffsetStart(tokenStart.start_ - begin_);
-  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;
-    name = "";
-    if (tokenName.type_ == tokenString) {
-      if (!decodeString(tokenName, name))
-        return recoverFromError(tokenObjectEnd);
-    } else if (tokenName.type_ == tokenNumber && features_.allowNumericKeys_) {
-      Value numberName;
-      if (!decodeNumber(tokenName, numberName))
-        return recoverFromError(tokenObjectEnd);
-      name = numberName.asString();
-    } else {
-      break;
-    }
-
-    Token colon;
-    if (!readToken(colon) || colon.type_ != tokenMemberSeparator) {
-      return addErrorAndRecover(
-          "Missing ':' after object member name", colon, tokenObjectEnd);
-    }
-    if (name.length() >= (1U<<30)) throwRuntimeError("keylength >= 2^30");
-    if (features_.rejectDupKeys_ && currentValue().isMember(name)) {
-      std::string msg = "Duplicate key: '" + name + "'";
-      return addErrorAndRecover(
-          msg, tokenName, 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 OurReader::readArray(Token& tokenStart) {
-  Value init(arrayValue);
-  currentValue().swapPayload(init);
-  currentValue().setOffsetStart(tokenStart.start_ - begin_);
-  skipSpaces();
-  if (*current_ == ']') // empty array
-  {
-    Token endArray;
-    readToken(endArray);
-    return true;
-  }
-  int index = 0;
-  for (;;) {
-    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 OurReader::decodeNumber(Token& token) {
-  Value decoded;
-  if (!decodeNumber(token, decoded))
-    return false;
-  currentValue().swapPayload(decoded);
-  currentValue().setOffsetStart(token.start_ - begin_);
-  currentValue().setOffsetLimit(token.end_ - begin_);
-  return true;
-}
-
-bool OurReader::decodeNumber(Token& token, Value& decoded) {
-  // 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;
-  // TODO: Help the compiler do the div and mod at compile time or get rid of them.
-  Value::LargestUInt maxIntegerValue =
-      isNegative ? Value::LargestUInt(-Value::minLargestInt)
-                 : Value::maxLargestUInt;
-  Value::LargestUInt threshold = maxIntegerValue / 10;
-  Value::LargestUInt value = 0;
-  while (current < token.end_) {
-    Char c = *current++;
-    if (c < '0' || c > '9')
-      return decodeDouble(token, decoded);
-    Value::UInt digit(static_cast<Value::UInt>(c - '0'));
-    if (value >= threshold) {
-      // We've hit or exceeded the max value divided by 10 (rounded down). If
-      // a) we've only just touched the limit, b) this is the last digit, and
-      // c) it's small enough to fit in that rounding delta, we're okay.
-      // Otherwise treat this number as a double to avoid overflow.
-      if (value > threshold || current != token.end_ ||
-          digit > maxIntegerValue % 10) {
-        return decodeDouble(token, decoded);
-      }
-    }
-    value = value * 10 + digit;
-  }
-  if (isNegative)
-    decoded = -Value::LargestInt(value);
-  else if (value <= Value::LargestUInt(Value::maxInt))
-    decoded = Value::LargestInt(value);
-  else
-    decoded = value;
-  return true;
-}
-
-bool OurReader::decodeDouble(Token& token) {
-  Value decoded;
-  if (!decodeDouble(token, decoded))
-    return false;
-  currentValue().swapPayload(decoded);
-  currentValue().setOffsetStart(token.start_ - begin_);
-  currentValue().setOffsetLimit(token.end_ - begin_);
-  return true;
-}
-
-bool OurReader::decodeDouble(Token& token, Value& decoded) {
-  double value = 0;
-  const int bufferSize = 32;
-  int count;
-  ptrdiff_t const length = token.end_ - token.start_;
-
-  // Sanity check to avoid buffer overflow exploits.
-  if (length < 0) {
-    return addError("Unable to parse token length", token);
-  }
-  size_t const ulength = static_cast<size_t>(length);
-
-  // Avoid using a string constant for the format control string given to
-  // sscanf, as this can cause hard to debug crashes on OS X. See here for more
-  // info:
-  //
-  //     http://developer.apple.com/library/mac/#DOCUMENTATION/DeveloperTools/gcc-4.0.1/gcc/Incompatibilities.html
-  char format[] = "%lf";
-
-  if (length <= bufferSize) {
-    Char buffer[bufferSize + 1];
-    memcpy(buffer, token.start_, ulength);
-    buffer[length] = 0;
-    count = sscanf(buffer, format, &value);
-  } else {
-    std::string buffer(token.start_, token.end_);
-    count = sscanf(buffer.c_str(), format, &value);
-  }
-
-  if (count != 1)
-    return addError("'" + std::string(token.start_, token.end_) +
-                        "' is not a number.",
-                    token);
-  decoded = value;
-  return true;
-}
-
-bool OurReader::decodeString(Token& token) {
-  std::string decoded_string;
-  if (!decodeString(token, decoded_string))
-    return false;
-  Value decoded(decoded_string);
-  currentValue().swapPayload(decoded);
-  currentValue().setOffsetStart(token.start_ - begin_);
-  currentValue().setOffsetLimit(token.end_ - begin_);
-  return true;
-}
-
-bool OurReader::decodeString(Token& token, std::string& decoded) {
-  decoded.reserve(static_cast<size_t>(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 OurReader::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 OurReader::decodeUnicodeEscapeSequence(Token& token,
-                                         Location& current,
-                                         Location end,
-                                         unsigned int& ret_unicode) {
-  if (end - current < 4)
-    return addError(
-        "Bad unicode escape sequence in string: four digits expected.",
-        token,
-        current);
-  int 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);
-  }
-  ret_unicode = static_cast<unsigned int>(unicode);
-  return true;
-}
-
-bool
-OurReader::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 OurReader::recoverFromError(TokenType skipUntilToken) {
-  size_t errorCount = errors_.size();
-  Token skip;
-  for (;;) {
-    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 OurReader::addErrorAndRecover(const std::string& message,
-                                Token& token,
-                                TokenType skipUntilToken) {
-  addError(message, token);
-  return recoverFromError(skipUntilToken);
-}
-
-Value& OurReader::currentValue() { return *(nodes_.top()); }
-
-OurReader::Char OurReader::getNextChar() {
-  if (current_ == end_)
-    return 0;
-  return *current_++;
-}
-
-void OurReader::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 OurReader::getLocationLineAndColumn(Location location) const {
-  int line, column;
-  getLocationLineAndColumn(location, line, column);
-  char buffer[18 + 16 + 16 + 1];
-  snprintf(buffer, sizeof(buffer), "Line %d, Column %d", line, column);
-  return buffer;
-}
-
-std::string OurReader::getFormattedErrorMessages() 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::vector<OurReader::StructuredError> OurReader::getStructuredErrors() const {
-  std::vector<OurReader::StructuredError> allErrors;
-  for (Errors::const_iterator itError = errors_.begin();
-       itError != errors_.end();
-       ++itError) {
-    const ErrorInfo& error = *itError;
-    OurReader::StructuredError structured;
-    structured.offset_start = error.token_.start_ - begin_;
-    structured.offset_limit = error.token_.end_ - begin_;
-    structured.message = error.message_;
-    allErrors.push_back(structured);
-  }
-  return allErrors;
-}
-
-bool OurReader::pushError(const Value& value, const std::string& message) {
-  ptrdiff_t length = end_ - begin_;
-  if(value.getOffsetStart() > length
-    || value.getOffsetLimit() > length)
-    return false;
-  Token token;
-  token.type_ = tokenError;
-  token.start_ = begin_ + value.getOffsetStart();
-  token.end_ = end_ + value.getOffsetLimit();
-  ErrorInfo info;
-  info.token_ = token;
-  info.message_ = message;
-  info.extra_ = 0;
-  errors_.push_back(info);
-  return true;
-}
-
-bool OurReader::pushError(const Value& value, const std::string& message, const Value& extra) {
-  ptrdiff_t length = end_ - begin_;
-  if(value.getOffsetStart() > length
-    || value.getOffsetLimit() > length
-    || extra.getOffsetLimit() > length)
-    return false;
-  Token token;
-  token.type_ = tokenError;
-  token.start_ = begin_ + value.getOffsetStart();
-  token.end_ = begin_ + value.getOffsetLimit();
-  ErrorInfo info;
-  info.token_ = token;
-  info.message_ = message;
-  info.extra_ = begin_ + extra.getOffsetStart();
-  errors_.push_back(info);
-  return true;
-}
-
-bool OurReader::good() const {
-  return !errors_.size();
-}
-
-
-class OurCharReader : public CharReader {
-  bool const collectComments_;
-  OurReader reader_;
-public:
-  OurCharReader(
-    bool collectComments,
-    OurFeatures const& features)
-  : collectComments_(collectComments)
-  , reader_(features)
-  {}
-  bool parse(
-      char const* beginDoc, char const* endDoc,
-      Value* root, std::string* errs) {
-    bool ok = reader_.parse(beginDoc, endDoc, *root, collectComments_);
-    if (errs) {
-      *errs = reader_.getFormattedErrorMessages();
-    }
-    return ok;
-  }
-};
-
-CharReaderBuilder::CharReaderBuilder()
-{
-  setDefaults(&settings_);
-}
-CharReaderBuilder::~CharReaderBuilder()
-{}
-CharReader* CharReaderBuilder::newCharReader() const
-{
-  bool collectComments = settings_["collectComments"].asBool();
-  OurFeatures features = OurFeatures::all();
-  features.allowComments_ = settings_["allowComments"].asBool();
-  features.strictRoot_ = settings_["strictRoot"].asBool();
-  features.allowDroppedNullPlaceholders_ = settings_["allowDroppedNullPlaceholders"].asBool();
-  features.allowNumericKeys_ = settings_["allowNumericKeys"].asBool();
-  features.allowSingleQuotes_ = settings_["allowSingleQuotes"].asBool();
-  features.stackLimit_ = settings_["stackLimit"].asInt();
-  features.failIfExtra_ = settings_["failIfExtra"].asBool();
-  features.rejectDupKeys_ = settings_["rejectDupKeys"].asBool();
-  features.allowSpecialFloats_ = settings_["allowSpecialFloats"].asBool();
-  return new OurCharReader(collectComments, features);
-}
-static void getValidReaderKeys(std::set<std::string>* valid_keys)
-{
-  valid_keys->clear();
-  valid_keys->insert("collectComments");
-  valid_keys->insert("allowComments");
-  valid_keys->insert("strictRoot");
-  valid_keys->insert("allowDroppedNullPlaceholders");
-  valid_keys->insert("allowNumericKeys");
-  valid_keys->insert("allowSingleQuotes");
-  valid_keys->insert("stackLimit");
-  valid_keys->insert("failIfExtra");
-  valid_keys->insert("rejectDupKeys");
-  valid_keys->insert("allowSpecialFloats");
-}
-bool CharReaderBuilder::validate(Json::Value* invalid) const
-{
-  Json::Value my_invalid;
-  if (!invalid) invalid = &my_invalid;  // so we do not need to test for NULL
-  Json::Value& inv = *invalid;
-  std::set<std::string> valid_keys;
-  getValidReaderKeys(&valid_keys);
-  Value::Members keys = settings_.getMemberNames();
-  size_t n = keys.size();
-  for (size_t i = 0; i < n; ++i) {
-    std::string const& key = keys[i];
-    if (valid_keys.find(key) == valid_keys.end()) {
-      inv[key] = settings_[key];
-    }
-  }
-  return 0u == inv.size();
-}
-Value& CharReaderBuilder::operator[](std::string key)
-{
-  return settings_[key];
-}
-// static
-void CharReaderBuilder::strictMode(Json::Value* settings)
-{
-//! [CharReaderBuilderStrictMode]
-  (*settings)["allowComments"] = false;
-  (*settings)["strictRoot"] = true;
-  (*settings)["allowDroppedNullPlaceholders"] = false;
-  (*settings)["allowNumericKeys"] = false;
-  (*settings)["allowSingleQuotes"] = false;
-  (*settings)["stackLimit"] = 1000;
-  (*settings)["failIfExtra"] = true;
-  (*settings)["rejectDupKeys"] = true;
-  (*settings)["allowSpecialFloats"] = false;
-//! [CharReaderBuilderStrictMode]
-}
-// static
-void CharReaderBuilder::setDefaults(Json::Value* settings)
-{
-//! [CharReaderBuilderDefaults]
-  (*settings)["collectComments"] = true;
-  (*settings)["allowComments"] = true;
-  (*settings)["strictRoot"] = false;
-  (*settings)["allowDroppedNullPlaceholders"] = false;
-  (*settings)["allowNumericKeys"] = false;
-  (*settings)["allowSingleQuotes"] = false;
-  (*settings)["stackLimit"] = 1000;
-  (*settings)["failIfExtra"] = false;
-  (*settings)["rejectDupKeys"] = false;
-  (*settings)["allowSpecialFloats"] = false;
-//! [CharReaderBuilderDefaults]
-}
-
-//////////////////////////////////
-// global functions
-
-bool parseFromStream(
-    CharReader::Factory const& fact, JSONCPP_ISTREAM& sin,
-    Value* root, std::string* errs)
-{
-  JSONCPP_OSTRINGSTREAM ssin;
-  ssin << sin.rdbuf();
-  std::string doc = ssin.str();
-  char const* begin = doc.data();
-  char const* end = begin + doc.size();
-  // Note that we do not actually need a null-terminator.
-  CharReaderPtr const reader(fact.newCharReader());
-  return reader->parse(begin, end, root, errs);
-}
-
-JSONCPP_ISTREAM& operator>>(JSONCPP_ISTREAM& sin, Value& root) {
-  CharReaderBuilder b;
-  std::string errs;
-  bool ok = parseFromStream(b, sin, &root, &errs);
-  if (!ok) {
-    fprintf(stderr,
-            "Error from reader: %s",
-            errs.c_str());
-
-    throwRuntimeError(errs);
-  }
-  return sin;
-}
-
-} // namespace Json
-
-// //////////////////////////////////////////////////////////////////////
-// End of content of file: src/lib_json/json_reader.cpp
-// //////////////////////////////////////////////////////////////////////
-
-
-
-
-
-
-// //////////////////////////////////////////////////////////////////////
-// Beginning of content of file: src/lib_json/json_valueiterator.inl
-// //////////////////////////////////////////////////////////////////////
-
-// 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
-
-namespace Json {
-
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// class ValueIteratorBase
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-
-ValueIteratorBase::ValueIteratorBase()
-    : current_(), isNull_(true) {
-}
-
-ValueIteratorBase::ValueIteratorBase(
-    const Value::ObjectValues::iterator& current)
-    : current_(current), isNull_(false) {}
-
-Value& ValueIteratorBase::deref() const {
-  return current_->second;
-}
-
-void ValueIteratorBase::increment() {
-  ++current_;
-}
-
-void ValueIteratorBase::decrement() {
-  --current_;
-}
-
-ValueIteratorBase::difference_type
-ValueIteratorBase::computeDistance(const SelfType& other) const {
-#ifdef JSON_USE_CPPTL_SMALLMAP
-  return other.current_ - 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
-}
-
-bool ValueIteratorBase::isEqual(const SelfType& other) const {
-  if (isNull_) {
-    return other.isNull_;
-  }
-  return current_ == other.current_;
-}
-
-void ValueIteratorBase::copy(const SelfType& other) {
-  current_ = other.current_;
-  isNull_ = other.isNull_;
-}
-
-Value ValueIteratorBase::key() const {
-  const Value::CZString czstring = (*current_).first;
-  if (czstring.data()) {
-    if (czstring.isStaticString())
-      return Value(StaticString(czstring.data()));
-    return Value(czstring.data(), czstring.data() + czstring.length());
-  }
-  return Value(czstring.index());
-}
-
-UInt ValueIteratorBase::index() const {
-  const Value::CZString czstring = (*current_).first;
-  if (!czstring.data())
-    return czstring.index();
-  return Value::UInt(-1);
-}
-
-JSONCPP_STRING ValueIteratorBase::name() const {
-  char const* keey;
-  char const* end;
-  keey = memberName(&end);
-  if (!keey) return JSONCPP_STRING();
-  return JSONCPP_STRING(keey, end);
-}
-
-char const* ValueIteratorBase::memberName() const {
-  const char* cname = (*current_).first.data();
-  return cname ? cname : "";
-}
-
-char const* ValueIteratorBase::memberName(char const** end) const {
-  const char* cname = (*current_).first.data();
-  if (!cname) {
-    *end = NULL;
-    return NULL;
-  }
-  *end = cname + (*current_).first.length();
-  return cname;
-}
-
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// class ValueConstIterator
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-
-ValueConstIterator::ValueConstIterator() {}
-
-ValueConstIterator::ValueConstIterator(
-    const Value::ObjectValues::iterator& current)
-    : ValueIteratorBase(current) {}
-
-ValueConstIterator::ValueConstIterator(ValueIterator const& other)
-    : ValueIteratorBase(other) {}
-
-ValueConstIterator& ValueConstIterator::
-operator=(const ValueIteratorBase& other) {
-  copy(other);
-  return *this;
-}
-
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// class ValueIterator
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-
-ValueIterator::ValueIterator() {}
-
-ValueIterator::ValueIterator(const Value::ObjectValues::iterator& current)
-    : ValueIteratorBase(current) {}
-
-ValueIterator::ValueIterator(const ValueConstIterator& other)
-    : ValueIteratorBase(other) {
-  throwRuntimeError("ConstIterator to Iterator should never be allowed.");
-}
-
-ValueIterator::ValueIterator(const ValueIterator& other)
-    : ValueIteratorBase(other) {}
-
-ValueIterator& ValueIterator::operator=(const SelfType& other) {
-  copy(other);
-  return *this;
-}
-
-} // namespace Json
-
-// //////////////////////////////////////////////////////////////////////
-// End of content of file: src/lib_json/json_valueiterator.inl
-// //////////////////////////////////////////////////////////////////////
-
-
-
-
-
-
-// //////////////////////////////////////////////////////////////////////
-// Beginning of content of file: src/lib_json/json_value.cpp
-// //////////////////////////////////////////////////////////////////////
-
-// Copyright 2011 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
-
-#if !defined(JSON_IS_AMALGAMATION)
-#include <json/assertions.h>
-#include <json/value.h>
-#include <json/writer.h>
-#endif // if !defined(JSON_IS_AMALGAMATION)
-#include <math.h>
-#include <sstream>
-#include <utility>
-#include <cstring>
-#include <cassert>
-#ifdef JSON_USE_CPPTL
-#include <cpptl/conststring.h>
-#endif
-#include <cstddef> // size_t
-#include <algorithm> // min()
-
-#define JSON_ASSERT_UNREACHABLE assert(false)
-
-namespace Json {
-
-// This is a walkaround to avoid the static initialization of Value::null.
-// kNull must be word-aligned to avoid crashing on ARM.  We use an alignment of
-// 8 (instead of 4) as a bit of future-proofing.
-#if defined(__ARMEL__)
-#define ALIGNAS(byte_alignment) __attribute__((aligned(byte_alignment)))
-#else
-#define ALIGNAS(byte_alignment)
-#endif
-static const unsigned char ALIGNAS(8) kNull[sizeof(Value)] = { 0 };
-const unsigned char& kNullRef = kNull[0];
-const Value& Value::null = reinterpret_cast<const Value&>(kNullRef);
-const Value& Value::nullRef = null;
-
-const Int Value::minInt = Int(~(UInt(-1) / 2));
-const Int Value::maxInt = Int(UInt(-1) / 2);
-const UInt Value::maxUInt = UInt(-1);
-#if defined(JSON_HAS_INT64)
-const Int64 Value::minInt64 = Int64(~(UInt64(-1) / 2));
-const Int64 Value::maxInt64 = Int64(UInt64(-1) / 2);
-const UInt64 Value::maxUInt64 = UInt64(-1);
-// The constant is hard-coded because some compiler have trouble
-// converting Value::maxUInt64 to a double correctly (AIX/xlC).
-// Assumes that UInt64 is a 64 bits integer.
-static const double maxUInt64AsDouble = 18446744073709551615.0;
-#endif // defined(JSON_HAS_INT64)
-const LargestInt Value::minLargestInt = LargestInt(~(LargestUInt(-1) / 2));
-const LargestInt Value::maxLargestInt = LargestInt(LargestUInt(-1) / 2);
-const LargestUInt Value::maxLargestUInt = LargestUInt(-1);
-
-#if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
-template <typename T, typename U>
-static inline bool InRange(double d, T min, U max) {
-  // The casts can lose precision, but we are looking only for
-  // an approximate range. Might fail on edge cases though. ~cdunn
-  //return d >= static_cast<double>(min) && d <= static_cast<double>(max);
-  return d >= min && d <= max;
-}
-#else  // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
-static inline double integerToDouble(Json::UInt64 value) {
-  return static_cast<double>(Int64(value / 2)) * 2.0 + Int64(value & 1);
-}
-
-template <typename T> static inline double integerToDouble(T value) {
-  return static_cast<double>(value);
-}
-
-template <typename T, typename U>
-static inline bool InRange(double d, T min, U max) {
-  return d >= integerToDouble(min) && d <= integerToDouble(max);
-}
-#endif // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
-
-/** 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,
-                                         size_t length) {
-  // Avoid an integer overflow in the call to malloc below by limiting length
-  // to a sane value.
-  if (length >= static_cast<size_t>(Value::maxInt))
-    length = Value::maxInt - 1;
-
-  char* newString = static_cast<char*>(malloc(length + 1));
-  if (newString == NULL) {
-    throwRuntimeError(
-        "in Json::Value::duplicateStringValue(): "
-        "Failed to allocate string value buffer");
-  }
-  memcpy(newString, value, length);
-  newString[length] = 0;
-  return newString;
-}
-
-/* Record the length as a prefix.
- */
-static inline char* duplicateAndPrefixStringValue(
-    const char* value,
-    unsigned int length)
-{
-  // Avoid an integer overflow in the call to malloc below by limiting length
-  // to a sane value.
-  JSON_ASSERT_MESSAGE(length <= static_cast<unsigned>(Value::maxInt) - sizeof(unsigned) - 1U,
-                      "in Json::Value::duplicateAndPrefixStringValue(): "
-                      "length too big for prefixing");
-  unsigned actualLength = length + static_cast<unsigned>(sizeof(unsigned)) + 1U;
-  char* newString = static_cast<char*>(malloc(actualLength));
-  if (newString == 0) {
-    throwRuntimeError(
-        "in Json::Value::duplicateAndPrefixStringValue(): "
-        "Failed to allocate string value buffer");
-  }
-  *reinterpret_cast<unsigned*>(newString) = length;
-  memcpy(newString + sizeof(unsigned), value, length);
-  newString[actualLength - 1U] = 0; // to avoid buffer over-run accidents by users later
-  return newString;
-}
-inline static void decodePrefixedString(
-    bool isPrefixed, char const* prefixed,
-    unsigned* length, char const** value)
-{
-  if (!isPrefixed) {
-    *length = static_cast<unsigned>(strlen(prefixed));
-    *value = prefixed;
-  } else {
-    *length = *reinterpret_cast<unsigned const*>(prefixed);
-    *value = prefixed + sizeof(unsigned);
-  }
-}
-/** Free the string duplicated by duplicateStringValue()/duplicateAndPrefixStringValue().
- */
-static inline void releaseStringValue(char* value) { free(value); }
-
-} // namespace Json
-
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// ValueInternals...
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-#if !defined(JSON_IS_AMALGAMATION)
-
-#include "json_valueiterator.inl"
-#endif // if !defined(JSON_IS_AMALGAMATION)
-
-namespace Json {
-
-Exception::Exception(JSONCPP_STRING const& msg)
-  : msg_(msg)
-{}
-Exception::~Exception() throw()
-{}
-char const* Exception::what() const throw()
-{
-  return msg_.c_str();
-}
-RuntimeError::RuntimeError(JSONCPP_STRING const& msg)
-  : Exception(msg)
-{}
-LogicError::LogicError(JSONCPP_STRING const& msg)
-  : Exception(msg)
-{}
-void throwRuntimeError(JSONCPP_STRING const& msg)
-{
-  throw RuntimeError(msg);
-}
-void throwLogicError(JSONCPP_STRING const& msg)
-{
-  throw LogicError(msg);
-}
-
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// class Value::CommentInfo
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-
-Value::CommentInfo::CommentInfo() : comment_(0) {}
-
-Value::CommentInfo::~CommentInfo() {
-  if (comment_)
-    releaseStringValue(comment_);
-}
-
-void Value::CommentInfo::setComment(const char* text, size_t len) {
-  if (comment_) {
-    releaseStringValue(comment_);
-    comment_ = 0;
-  }
-  JSON_ASSERT(text != 0);
-  JSON_ASSERT_MESSAGE(
-      text[0] == '\0' || text[0] == '/',
-      "in Json::Value::setComment(): Comments must start with /");
-  // It seems that /**/ style comments are acceptable as well.
-  comment_ = duplicateStringValue(text, len);
-}
-
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// class Value::CZString
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-
-// Notes: policy_ indicates if the string was allocated when
-// a string is stored.
-
-Value::CZString::CZString(ArrayIndex aindex) : cstr_(0), index_(aindex) {}
-
-Value::CZString::CZString(char const* str, unsigned ulength, DuplicationPolicy allocate)
-    : cstr_(str) {
-  // allocate != duplicate
-  storage_.policy_ = allocate & 0x3;
-  storage_.length_ = ulength & 0x3FFFFFFF;
-}
-
-Value::CZString::CZString(const CZString& other)
-    : cstr_(other.storage_.policy_ != noDuplication && other.cstr_ != 0
-                ? duplicateStringValue(other.cstr_, other.storage_.length_)
-                : other.cstr_) {
-  storage_.policy_ = static_cast<unsigned>(other.cstr_
-                 ? (static_cast<DuplicationPolicy>(other.storage_.policy_) == noDuplication
-                     ? noDuplication : duplicate)
-                 : static_cast<DuplicationPolicy>(other.storage_.policy_));
-  storage_.length_ = other.storage_.length_;
-}
-
-#if JSON_HAS_RVALUE_REFERENCES
-Value::CZString::CZString(CZString&& other)
-  : cstr_(other.cstr_), index_(other.index_) {
-  other.cstr_ = nullptr;
-}
-#endif
-
-Value::CZString::~CZString() {
-  if (cstr_ && storage_.policy_ == 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=(CZString other) {
-  swap(other);
-  return *this;
-}
-
-bool Value::CZString::operator<(const CZString& other) const {
-  if (!cstr_) return index_ < other.index_;
-  //return strcmp(cstr_, other.cstr_) < 0;
-  // Assume both are strings.
-  unsigned this_len = this->storage_.length_;
-  unsigned other_len = other.storage_.length_;
-  unsigned min_len = std::min(this_len, other_len);
-  JSON_ASSERT(this->cstr_ && other.cstr_);
-  int comp = memcmp(this->cstr_, other.cstr_, min_len);
-  if (comp < 0) return true;
-  if (comp > 0) return false;
-  return (this_len < other_len);
-}
-
-bool Value::CZString::operator==(const CZString& other) const {
-  if (!cstr_) return index_ == other.index_;
-  //return strcmp(cstr_, other.cstr_) == 0;
-  // Assume both are strings.
-  unsigned this_len = this->storage_.length_;
-  unsigned other_len = other.storage_.length_;
-  if (this_len != other_len) return false;
-  JSON_ASSERT(this->cstr_ && other.cstr_);
-  int comp = memcmp(this->cstr_, other.cstr_, this_len);
-  return comp == 0;
-}
-
-ArrayIndex Value::CZString::index() const { return index_; }
-
-//const char* Value::CZString::c_str() const { return cstr_; }
-const char* Value::CZString::data() const { return cstr_; }
-unsigned Value::CZString::length() const { return storage_.length_; }
-bool Value::CZString::isStaticString() const { return storage_.policy_ == noDuplication; }
-
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// //////////////////////////////////////////////////////////////////
-// 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 vtype) {
-  initBasic(vtype);
-  switch (vtype) {
-  case nullValue:
-    break;
-  case intValue:
-  case uintValue:
-    value_.int_ = 0;
-    break;
-  case realValue:
-    value_.real_ = 0.0;
-    break;
-  case stringValue:
-    value_.string_ = 0;
-    break;
-  case arrayValue:
-  case objectValue:
-    value_.map_ = new ObjectValues();
-    break;
-  case booleanValue:
-    value_.bool_ = false;
-    break;
-  default:
-    JSON_ASSERT_UNREACHABLE;
-  }
-}
-
-Value::Value(Int value) {
-  initBasic(intValue);
-  value_.int_ = value;
-}
-
-Value::Value(UInt value) {
-  initBasic(uintValue);
-  value_.uint_ = value;
-}
-#if defined(JSON_HAS_INT64)
-Value::Value(Int64 value) {
-  initBasic(intValue);
-  value_.int_ = value;
-}
-Value::Value(UInt64 value) {
-  initBasic(uintValue);
-  value_.uint_ = value;
-}
-#endif // defined(JSON_HAS_INT64)
-
-Value::Value(double value) {
-  initBasic(realValue);
-  value_.real_ = value;
-}
-
-Value::Value(const char* value) {
-  initBasic(stringValue, true);
-  value_.string_ = duplicateAndPrefixStringValue(value, static_cast<unsigned>(strlen(value)));
-}
-
-Value::Value(const char* beginValue, const char* endValue) {
-  initBasic(stringValue, true);
-  value_.string_ =
-      duplicateAndPrefixStringValue(beginValue, static_cast<unsigned>(endValue - beginValue));
-}
-
-Value::Value(const JSONCPP_STRING& value) {
-  initBasic(stringValue, true);
-  value_.string_ =
-      duplicateAndPrefixStringValue(value.data(), static_cast<unsigned>(value.length()));
-}
-
-Value::Value(const StaticString& value) {
-  initBasic(stringValue);
-  value_.string_ = const_cast<char*>(value.c_str());
-}
-
-#ifdef JSON_USE_CPPTL
-Value::Value(const CppTL::ConstString& value) {
-  initBasic(stringValue, true);
-  value_.string_ = duplicateAndPrefixStringValue(value, static_cast<unsigned>(value.length()));
-}
-#endif
-
-Value::Value(bool value) {
-  initBasic(booleanValue);
-  value_.bool_ = value;
-}
-
-Value::Value(Value const& other)
-    : type_(other.type_), allocated_(false)
-      ,
-      comments_(0), start_(other.start_), limit_(other.limit_)
-{
-  switch (type_) {
-  case nullValue:
-  case intValue:
-  case uintValue:
-  case realValue:
-  case booleanValue:
-    value_ = other.value_;
-    break;
-  case stringValue:
-    if (other.value_.string_ && other.allocated_) {
-      unsigned len;
-      char const* str;
-      decodePrefixedString(other.allocated_, other.value_.string_,
-          &len, &str);
-      value_.string_ = duplicateAndPrefixStringValue(str, len);
-      allocated_ = true;
-    } else {
-      value_.string_ = other.value_.string_;
-      allocated_ = false;
-    }
-    break;
-  case arrayValue:
-  case objectValue:
-    value_.map_ = new ObjectValues(*other.value_.map_);
-    break;
-  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_, strlen(otherComment.comment_));
-    }
-  }
-}
-
-#if JSON_HAS_RVALUE_REFERENCES
-// Move constructor
-Value::Value(Value&& other) {
-  initBasic(nullValue);
-  swap(other);
-}
-#endif
-
-Value::~Value() {
-  switch (type_) {
-  case nullValue:
-  case intValue:
-  case uintValue:
-  case realValue:
-  case booleanValue:
-    break;
-  case stringValue:
-    if (allocated_)
-      releaseStringValue(value_.string_);
-    break;
-  case arrayValue:
-  case objectValue:
-    delete value_.map_;
-    break;
-  default:
-    JSON_ASSERT_UNREACHABLE;
-  }
-
-  if (comments_)
-    delete[] comments_;
-}
-
-Value& Value::operator=(Value other) {
-  swap(other);
-  return *this;
-}
-
-void Value::swapPayload(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 & 0x1;
-}
-
-void Value::swap(Value& other) {
-  swapPayload(other);
-  std::swap(comments_, other.comments_);
-  std::swap(start_, other.start_);
-  std::swap(limit_, other.limit_);
-}
-
-ValueType Value::type() const { return type_; }
-
-int Value::compare(const Value& other) const {
-  if (*this < other)
-    return -1;
-  if (*this > other)
-    return 1;
-  return 0;
-}
-
-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:
-  {
-    if ((value_.string_ == 0) || (other.value_.string_ == 0)) {
-      if (other.value_.string_) return true;
-      else return false;
-    }
-    unsigned this_len;
-    unsigned other_len;
-    char const* this_str;
-    char const* other_str;
-    decodePrefixedString(this->allocated_, this->value_.string_, &this_len, &this_str);
-    decodePrefixedString(other.allocated_, other.value_.string_, &other_len, &other_str);
-    unsigned min_len = std::min(this_len, other_len);
-    JSON_ASSERT(this_str && other_str);
-    int comp = memcmp(this_str, other_str, min_len);
-    if (comp < 0) return true;
-    if (comp > 0) return false;
-    return (this_len < other_len);
-  }
-  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_);
-  }
-  default:
-    JSON_ASSERT_UNREACHABLE;
-  }
-  return false; // 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:
-  {
-    if ((value_.string_ == 0) || (other.value_.string_ == 0)) {
-      return (value_.string_ == other.value_.string_);
-    }
-    unsigned this_len;
-    unsigned other_len;
-    char const* this_str;
-    char const* other_str;
-    decodePrefixedString(this->allocated_, this->value_.string_, &this_len, &this_str);
-    decodePrefixedString(other.allocated_, other.value_.string_, &other_len, &other_str);
-    if (this_len != other_len) return false;
-    JSON_ASSERT(this_str && other_str);
-    int comp = memcmp(this_str, other_str, this_len);
-    return comp == 0;
-  }
-  case arrayValue:
-  case objectValue:
-    return value_.map_->size() == other.value_.map_->size() &&
-           (*value_.map_) == (*other.value_.map_);
-  default:
-    JSON_ASSERT_UNREACHABLE;
-  }
-  return false; // unreachable
-}
-
-bool Value::operator!=(const Value& other) const { return !(*this == other); }
-
-const char* Value::asCString() const {
-  JSON_ASSERT_MESSAGE(type_ == stringValue,
-                      "in Json::Value::asCString(): requires stringValue");
-  if (value_.string_ == 0) return 0;
-  unsigned this_len;
-  char const* this_str;
-  decodePrefixedString(this->allocated_, this->value_.string_, &this_len, &this_str);
-  return this_str;
-}
-
-bool Value::getString(char const** str, char const** cend) const {
-  if (type_ != stringValue) return false;
-  if (value_.string_ == 0) return false;
-  unsigned length;
-  decodePrefixedString(this->allocated_, this->value_.string_, &length, str);
-  *cend = *str + length;
-  return true;
-}
-
-JSONCPP_STRING Value::asString() const {
-  switch (type_) {
-  case nullValue:
-    return "";
-  case stringValue:
-  {
-    if (value_.string_ == 0) return "";
-    unsigned this_len;
-    char const* this_str;
-    decodePrefixedString(this->allocated_, this->value_.string_, &this_len, &this_str);
-    return JSONCPP_STRING(this_str, this_len);
-  }
-  case booleanValue:
-    return value_.bool_ ? "true" : "false";
-  case intValue:
-    return valueToString(value_.int_);
-  case uintValue:
-    return valueToString(value_.uint_);
-  case realValue:
-    return valueToString(value_.real_);
-  default:
-    JSON_FAIL_MESSAGE("Type is not convertible to string");
-  }
-}
-
-#ifdef JSON_USE_CPPTL
-CppTL::ConstString Value::asConstString() const {
-  unsigned len;
-  char const* str;
-  decodePrefixedString(allocated_, value_.string_,
-      &len, &str);
-  return CppTL::ConstString(str, len);
-}
-#endif
-
-Value::Int Value::asInt() const {
-  switch (type_) {
-  case intValue:
-    JSON_ASSERT_MESSAGE(isInt(), "LargestInt out of Int range");
-    return Int(value_.int_);
-  case uintValue:
-    JSON_ASSERT_MESSAGE(isInt(), "LargestUInt out of Int range");
-    return Int(value_.uint_);
-  case realValue:
-    JSON_ASSERT_MESSAGE(InRange(value_.real_, minInt, maxInt),
-                        "double out of Int range");
-    return Int(value_.real_);
-  case nullValue:
-    return 0;
-  case booleanValue:
-    return value_.bool_ ? 1 : 0;
-  default:
-    break;
-  }
-  JSON_FAIL_MESSAGE("Value is not convertible to Int.");
-}
-
-Value::UInt Value::asUInt() const {
-  switch (type_) {
-  case intValue:
-    JSON_ASSERT_MESSAGE(isUInt(), "LargestInt out of UInt range");
-    return UInt(value_.int_);
-  case uintValue:
-    JSON_ASSERT_MESSAGE(isUInt(), "LargestUInt out of UInt range");
-    return UInt(value_.uint_);
-  case realValue:
-    JSON_ASSERT_MESSAGE(InRange(value_.real_, 0, maxUInt),
-                        "double out of UInt range");
-    return UInt(value_.real_);
-  case nullValue:
-    return 0;
-  case booleanValue:
-    return value_.bool_ ? 1 : 0;
-  default:
-    break;
-  }
-  JSON_FAIL_MESSAGE("Value is not convertible to UInt.");
-}
-
-#if defined(JSON_HAS_INT64)
-
-Value::Int64 Value::asInt64() const {
-  switch (type_) {
-  case intValue:
-    return Int64(value_.int_);
-  case uintValue:
-    JSON_ASSERT_MESSAGE(isInt64(), "LargestUInt out of Int64 range");
-    return Int64(value_.uint_);
-  case realValue:
-    JSON_ASSERT_MESSAGE(InRange(value_.real_, minInt64, maxInt64),
-                        "double out of Int64 range");
-    return Int64(value_.real_);
-  case nullValue:
-    return 0;
-  case booleanValue:
-    return value_.bool_ ? 1 : 0;
-  default:
-    break;
-  }
-  JSON_FAIL_MESSAGE("Value is not convertible to Int64.");
-}
-
-Value::UInt64 Value::asUInt64() const {
-  switch (type_) {
-  case intValue:
-    JSON_ASSERT_MESSAGE(isUInt64(), "LargestInt out of UInt64 range");
-    return UInt64(value_.int_);
-  case uintValue:
-    return UInt64(value_.uint_);
-  case realValue:
-    JSON_ASSERT_MESSAGE(InRange(value_.real_, 0, maxUInt64),
-                        "double out of UInt64 range");
-    return UInt64(value_.real_);
-  case nullValue:
-    return 0;
-  case booleanValue:
-    return value_.bool_ ? 1 : 0;
-  default:
-    break;
-  }
-  JSON_FAIL_MESSAGE("Value is not convertible to UInt64.");
-}
-#endif // if defined(JSON_HAS_INT64)
-
-LargestInt Value::asLargestInt() const {
-#if defined(JSON_NO_INT64)
-  return asInt();
-#else
-  return asInt64();
-#endif
-}
-
-LargestUInt Value::asLargestUInt() const {
-#if defined(JSON_NO_INT64)
-  return asUInt();
-#else
-  return asUInt64();
-#endif
-}
-
-double Value::asDouble() const {
-  switch (type_) {
-  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 integerToDouble(value_.uint_);
-#endif // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
-  case realValue:
-    return value_.real_;
-  case nullValue:
-    return 0.0;
-  case booleanValue:
-    return value_.bool_ ? 1.0 : 0.0;
-  default:
-    break;
-  }
-  JSON_FAIL_MESSAGE("Value is not convertible to double.");
-}
-
-float Value::asFloat() const {
-  switch (type_) {
-  case intValue:
-    return static_cast<float>(value_.int_);
-  case uintValue:
-#if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
-    return static_cast<float>(value_.uint_);
-#else  // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
-    // This can fail (silently?) if the value is bigger than MAX_FLOAT.
-    return static_cast<float>(integerToDouble(value_.uint_));
-#endif // if !defined(JSON_USE_INT64_DOUBLE_CONVERSION)
-  case realValue:
-    return static_cast<float>(value_.real_);
-  case nullValue:
-    return 0.0;
-  case booleanValue:
-    return value_.bool_ ? 1.0f : 0.0f;
-  default:
-    break;
-  }
-  JSON_FAIL_MESSAGE("Value is not convertible to float.");
-}
-
-bool Value::asBool() const {
-  switch (type_) {
-  case booleanValue:
-    return value_.bool_;
-  case nullValue:
-    return false;
-  case intValue:
-    return value_.int_ ? true : false;
-  case uintValue:
-    return value_.uint_ ? true : false;
-  case realValue:
-    // This is kind of strange. Not recommended.
-    return (value_.real_ != 0.0) ? true : false;
-  default:
-    break;
-  }
-  JSON_FAIL_MESSAGE("Value is not convertible to bool.");
-}
-
-bool Value::isConvertibleTo(ValueType other) const {
-  switch (other) {
-  case nullValue:
-    return (isNumeric() && asDouble() == 0.0) ||
-           (type_ == booleanValue && value_.bool_ == false) ||
-           (type_ == stringValue && asString() == "") ||
-           (type_ == arrayValue && value_.map_->size() == 0) ||
-           (type_ == objectValue && value_.map_->size() == 0) ||
-           type_ == nullValue;
-  case intValue:
-    return isInt() ||
-           (type_ == realValue && InRange(value_.real_, minInt, maxInt)) ||
-           type_ == booleanValue || type_ == nullValue;
-  case uintValue:
-    return isUInt() ||
-           (type_ == realValue && InRange(value_.real_, 0, maxUInt)) ||
-           type_ == booleanValue || type_ == nullValue;
-  case realValue:
-    return isNumeric() || type_ == booleanValue || type_ == nullValue;
-  case booleanValue:
-    return isNumeric() || type_ == booleanValue || type_ == nullValue;
-  case stringValue:
-    return isNumeric() || type_ == booleanValue || type_ == stringValue ||
-           type_ == nullValue;
-  case arrayValue:
-    return type_ == arrayValue || type_ == nullValue;
-  case objectValue:
-    return type_ == objectValue || type_ == nullValue;
-  }
-  JSON_ASSERT_UNREACHABLE;
-  return false;
-}
-
-/// 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;
-  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());
-  }
-  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_MESSAGE(type_ == nullValue || type_ == arrayValue ||
-                          type_ == objectValue,
-                      "in Json::Value::clear(): requires complex value");
-  start_ = 0;
-  limit_ = 0;
-  switch (type_) {
-  case arrayValue:
-  case objectValue:
-    value_.map_->clear();
-    break;
-  default:
-    break;
-  }
-}
-
-void Value::resize(ArrayIndex newSize) {
-  JSON_ASSERT_MESSAGE(type_ == nullValue || type_ == arrayValue,
-                      "in Json::Value::resize(): requires arrayValue");
-  if (type_ == nullValue)
-    *this = Value(arrayValue);
-  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);
-    }
-    JSON_ASSERT(size() == newSize);
-  }
-}
-
-Value& Value::operator[](ArrayIndex index) {
-  JSON_ASSERT_MESSAGE(
-      type_ == nullValue || type_ == arrayValue,
-      "in Json::Value::operator[](ArrayIndex): requires arrayValue");
-  if (type_ == nullValue)
-    *this = Value(arrayValue);
-  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, nullRef);
-  it = value_.map_->insert(it, defaultValue);
-  return (*it).second;
-}
-
-Value& Value::operator[](int index) {
-  JSON_ASSERT_MESSAGE(
-      index >= 0,
-      "in Json::Value::operator[](int index): index cannot be negative");
-  return (*this)[ArrayIndex(index)];
-}
-
-const Value& Value::operator[](ArrayIndex index) const {
-  JSON_ASSERT_MESSAGE(
-      type_ == nullValue || type_ == arrayValue,
-      "in Json::Value::operator[](ArrayIndex)const: requires arrayValue");
-  if (type_ == nullValue)
-    return nullRef;
-  CZString key(index);
-  ObjectValues::const_iterator it = value_.map_->find(key);
-  if (it == value_.map_->end())
-    return nullRef;
-  return (*it).second;
-}
-
-const Value& Value::operator[](int index) const {
-  JSON_ASSERT_MESSAGE(
-      index >= 0,
-      "in Json::Value::operator[](int index) const: index cannot be negative");
-  return (*this)[ArrayIndex(index)];
-}
-
-void Value::initBasic(ValueType vtype, bool allocated) {
-  type_ = vtype;
-  allocated_ = allocated;
-  comments_ = 0;
-  start_ = 0;
-  limit_ = 0;
-}
-
-// Access an object value by name, create a null member if it does not exist.
-// @pre Type of '*this' is object or null.
-// @param key is null-terminated.
-Value& Value::resolveReference(const char* key) {
-  JSON_ASSERT_MESSAGE(
-      type_ == nullValue || type_ == objectValue,
-      "in Json::Value::resolveReference(): requires objectValue");
-  if (type_ == nullValue)
-    *this = Value(objectValue);
-  CZString actualKey(
-      key, static_cast<unsigned>(strlen(key)), CZString::noDuplication); // NOTE!
-  ObjectValues::iterator it = value_.map_->lower_bound(actualKey);
-  if (it != value_.map_->end() && (*it).first == actualKey)
-    return (*it).second;
-
-  ObjectValues::value_type defaultValue(actualKey, nullRef);
-  it = value_.map_->insert(it, defaultValue);
-  Value& value = (*it).second;
-  return value;
-}
-
-// @param key is not null-terminated.
-Value& Value::resolveReference(char const* key, char const* cend)
-{
-  JSON_ASSERT_MESSAGE(
-      type_ == nullValue || type_ == objectValue,
-      "in Json::Value::resolveReference(key, end): requires objectValue");
-  if (type_ == nullValue)
-    *this = Value(objectValue);
-  CZString actualKey(
-      key, static_cast<unsigned>(cend-key), 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, nullRef);
-  it = value_.map_->insert(it, defaultValue);
-  Value& value = (*it).second;
-  return value;
-}
-
-Value Value::get(ArrayIndex index, const Value& defaultValue) const {
-  const Value* value = &((*this)[index]);
-  return value == &nullRef ? defaultValue : *value;
-}
-
-bool Value::isValidIndex(ArrayIndex index) const { return index < size(); }
-
-Value const* Value::find(char const* key, char const* cend) const
-{
-  JSON_ASSERT_MESSAGE(
-      type_ == nullValue || type_ == objectValue,
-      "in Json::Value::find(key, end, found): requires objectValue or nullValue");
-  if (type_ == nullValue) return NULL;
-  CZString actualKey(key, static_cast<unsigned>(cend-key), CZString::noDuplication);
-  ObjectValues::const_iterator it = value_.map_->find(actualKey);
-  if (it == value_.map_->end()) return NULL;
-  return &(*it).second;
-}
-const Value& Value::operator[](const char* key) const
-{
-  Value const* found = find(key, key + strlen(key));
-  if (!found) return nullRef;
-  return *found;
-}
-Value const& Value::operator[](JSONCPP_STRING const& key) const
-{
-  Value const* found = find(key.data(), key.data() + key.length());
-  if (!found) return nullRef;
-  return *found;
-}
-
-Value& Value::operator[](const char* key) {
-  return resolveReference(key, key + strlen(key));
-}
-
-Value& Value::operator[](const JSONCPP_STRING& key) {
-  return resolveReference(key.data(), key.data() + key.length());
-}
-
-Value& Value::operator[](const StaticString& key) {
-  return resolveReference(key.c_str());
-}
-
-#ifdef JSON_USE_CPPTL
-Value& Value::operator[](const CppTL::ConstString& key) {
-  return resolveReference(key.c_str(), key.end_c_str());
-}
-Value const& Value::operator[](CppTL::ConstString const& key) const
-{
-  Value const* found = find(key.c_str(), key.end_c_str());
-  if (!found) return nullRef;
-  return *found;
-}
-#endif
-
-Value& Value::append(const Value& value) { return (*this)[size()] = value; }
-
-Value Value::get(char const* key, char const* cend, Value const& defaultValue) const
-{
-  Value const* found = find(key, cend);
-  return !found ? defaultValue : *found;
-}
-Value Value::get(char const* key, Value const& defaultValue) const
-{
-  return get(key, key + strlen(key), defaultValue);
-}
-Value Value::get(JSONCPP_STRING const& key, Value const& defaultValue) const
-{
-  return get(key.data(), key.data() + key.length(), defaultValue);
-}
-
-
-bool Value::removeMember(const char* key, const char* cend, Value* removed)
-{
-  if (type_ != objectValue) {
-    return false;
-  }
-  CZString actualKey(key, static_cast<unsigned>(cend-key), CZString::noDuplication);
-  ObjectValues::iterator it = value_.map_->find(actualKey);
-  if (it == value_.map_->end())
-    return false;
-  *removed = it->second;
-  value_.map_->erase(it);
-  return true;
-}
-bool Value::removeMember(const char* key, Value* removed)
-{
-  return removeMember(key, key + strlen(key), removed);
-}
-bool Value::removeMember(JSONCPP_STRING const& key, Value* removed)
-{
-  return removeMember(key.data(), key.data() + key.length(), removed);
-}
-Value Value::removeMember(const char* key)
-{
-  JSON_ASSERT_MESSAGE(type_ == nullValue || type_ == objectValue,
-                      "in Json::Value::removeMember(): requires objectValue");
-  if (type_ == nullValue)
-    return nullRef;
-
-  Value removed;  // null
-  removeMember(key, key + strlen(key), &removed);
-  return removed; // still null if removeMember() did nothing
-}
-Value Value::removeMember(const JSONCPP_STRING& key)
-{
-  return removeMember(key.c_str());
-}
-
-bool Value::removeIndex(ArrayIndex index, Value* removed) {
-  if (type_ != arrayValue) {
-    return false;
-  }
-  CZString key(index);
-  ObjectValues::iterator it = value_.map_->find(key);
-  if (it == value_.map_->end()) {
-    return false;
-  }
-  *removed = it->second;
-  ArrayIndex oldSize = size();
-  // shift left all items left, into the place of the "removed"
-  for (ArrayIndex i = index; i < (oldSize - 1); ++i){
-    CZString keey(i);
-    (*value_.map_)[keey] = (*this)[i + 1];
-  }
-  // erase the last one ("leftover")
-  CZString keyLast(oldSize - 1);
-  ObjectValues::iterator itLast = value_.map_->find(keyLast);
-  value_.map_->erase(itLast);
-  return true;
-}
-
-#ifdef JSON_USE_CPPTL
-Value Value::get(const CppTL::ConstString& key,
-                 const Value& defaultValue) const {
-  return get(key.c_str(), key.end_c_str(), defaultValue);
-}
-#endif
-
-bool Value::isMember(char const* key, char const* cend) const
-{
-  Value const* value = find(key, cend);
-  return NULL != value;
-}
-bool Value::isMember(char const* key) const
-{
-  return isMember(key, key + strlen(key));
-}
-bool Value::isMember(JSONCPP_STRING const& key) const
-{
-  return isMember(key.data(), key.data() + key.length());
-}
-
-#ifdef JSON_USE_CPPTL
-bool Value::isMember(const CppTL::ConstString& key) const {
-  return isMember(key.c_str(), key.end_c_str());
-}
-#endif
-
-Value::Members Value::getMemberNames() const {
-  JSON_ASSERT_MESSAGE(
-      type_ == nullValue || type_ == objectValue,
-      "in Json::Value::getMemberNames(), value must be objectValue");
-  if (type_ == nullValue)
-    return Value::Members();
-  Members members;
-  members.reserve(value_.map_->size());
-  ObjectValues::const_iterator it = value_.map_->begin();
-  ObjectValues::const_iterator itEnd = value_.map_->end();
-  for (; it != itEnd; ++it) {
-    members.push_back(JSONCPP_STRING((*it).first.data(),
-                                  (*it).first.length()));
-  }
-  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
-
-static bool IsIntegral(double d) {
-  double integral_part;
-  return modf(d, &integral_part) == 0.0;
-}
-
-bool Value::isNull() const { return type_ == nullValue; }
-
-bool Value::isBool() const { return type_ == booleanValue; }
-
-bool Value::isInt() const {
-  switch (type_) {
-  case intValue:
-    return value_.int_ >= minInt && value_.int_ <= maxInt;
-  case uintValue:
-    return value_.uint_ <= UInt(maxInt);
-  case realValue:
-    return value_.real_ >= minInt && value_.real_ <= maxInt &&
-           IsIntegral(value_.real_);
-  default:
-    break;
-  }
-  return false;
-}
-
-bool Value::isUInt() const {
-  switch (type_) {
-  case intValue:
-    return value_.int_ >= 0 && LargestUInt(value_.int_) <= LargestUInt(maxUInt);
-  case uintValue:
-    return value_.uint_ <= maxUInt;
-  case realValue:
-    return value_.real_ >= 0 && value_.real_ <= maxUInt &&
-           IsIntegral(value_.real_);
-  default:
-    break;
-  }
-  return false;
-}
-
-bool Value::isInt64() const {
-#if defined(JSON_HAS_INT64)
-  switch (type_) {
-  case intValue:
-    return true;
-  case uintValue:
-    return value_.uint_ <= UInt64(maxInt64);
-  case realValue:
-    // Note that maxInt64 (= 2^63 - 1) is not exactly representable as a
-    // double, so double(maxInt64) will be rounded up to 2^63. Therefore we
-    // require the value to be strictly less than the limit.
-    return value_.real_ >= double(minInt64) &&
-           value_.real_ < double(maxInt64) && IsIntegral(value_.real_);
-  default:
-    break;
-  }
-#endif // JSON_HAS_INT64
-  return false;
-}
-
-bool Value::isUInt64() const {
-#if defined(JSON_HAS_INT64)
-  switch (type_) {
-  case intValue:
-    return value_.int_ >= 0;
-  case uintValue:
-    return true;
-  case realValue:
-    // Note that maxUInt64 (= 2^64 - 1) is not exactly representable as a
-    // double, so double(maxUInt64) will be rounded up to 2^64. Therefore we
-    // require the value to be strictly less than the limit.
-    return value_.real_ >= 0 && value_.real_ < maxUInt64AsDouble &&
-           IsIntegral(value_.real_);
-  default:
-    break;
-  }
-#endif // JSON_HAS_INT64
-  return false;
-}
-
-bool Value::isIntegral() const {
-#if defined(JSON_HAS_INT64)
-  return isInt64() || isUInt64();
-#else
-  return isInt() || isUInt();
-#endif
-}
-
-bool Value::isDouble() const { return type_ == realValue || isIntegral(); }
-
-bool Value::isNumeric() const { return isIntegral() || isDouble(); }
-
-bool Value::isString() const { return type_ == stringValue; }
-
-bool Value::isArray() const { return type_ == arrayValue; }
-
-bool Value::isObject() const { return type_ == objectValue; }
-
-void Value::setComment(const char* comment, size_t len, CommentPlacement placement) {
-  if (!comments_)
-    comments_ = new CommentInfo[numberOfCommentPlacement];
-  if ((len > 0) && (comment[len-1] == '\n')) {
-    // Always discard trailing newline, to aid indentation.
-    len -= 1;
-  }
-  comments_[placement].setComment(comment, len);
-}
-
-void Value::setComment(const char* comment, CommentPlacement placement) {
-  setComment(comment, strlen(comment), placement);
-}
-
-void Value::setComment(const JSONCPP_STRING& comment, CommentPlacement placement) {
-  setComment(comment.c_str(), comment.length(), placement);
-}
-
-bool Value::hasComment(CommentPlacement placement) const {
-  return comments_ != 0 && comments_[placement].comment_ != 0;
-}
-
-JSONCPP_STRING Value::getComment(CommentPlacement placement) const {
-  if (hasComment(placement))
-    return comments_[placement].comment_;
-  return "";
-}
-
-void Value::setOffsetStart(ptrdiff_t start) { start_ = start; }
-
-void Value::setOffsetLimit(ptrdiff_t limit) { limit_ = limit; }
-
-ptrdiff_t Value::getOffsetStart() const { return start_; }
-
-ptrdiff_t Value::getOffsetLimit() const { return limit_; }
-
-JSONCPP_STRING Value::toStyledString() const {
-  StyledWriter writer;
-  return writer.write(*this);
-}
-
-Value::const_iterator Value::begin() const {
-  switch (type_) {
-  case arrayValue:
-  case objectValue:
-    if (value_.map_)
-      return const_iterator(value_.map_->begin());
-    break;
-  default:
-    break;
-  }
-  return const_iterator();
-}
-
-Value::const_iterator Value::end() const {
-  switch (type_) {
-  case arrayValue:
-  case objectValue:
-    if (value_.map_)
-      return const_iterator(value_.map_->end());
-    break;
-  default:
-    break;
-  }
-  return const_iterator();
-}
-
-Value::iterator Value::begin() {
-  switch (type_) {
-  case arrayValue:
-  case objectValue:
-    if (value_.map_)
-      return iterator(value_.map_->begin());
-    break;
-  default:
-    break;
-  }
-  return iterator();
-}
-
-Value::iterator Value::end() {
-  switch (type_) {
-  case arrayValue:
-  case objectValue:
-    if (value_.map_)
-      return iterator(value_.map_->end());
-    break;
-  default:
-    break;
-  }
-  return iterator();
-}
-
-// class PathArgument
-// //////////////////////////////////////////////////////////////////
-
-PathArgument::PathArgument() : key_(), index_(), kind_(kindNone) {}
-
-PathArgument::PathArgument(ArrayIndex index)
-    : key_(), index_(index), kind_(kindIndex) {}
-
-PathArgument::PathArgument(const char* key)
-    : key_(key), index_(), kind_(kindKey) {}
-
-PathArgument::PathArgument(const JSONCPP_STRING& key)
-    : key_(key.c_str()), index_(), kind_(kindKey) {}
-
-// class Path
-// //////////////////////////////////////////////////////////////////
-
-Path::Path(const JSONCPP_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 JSONCPP_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(JSONCPP_STRING(beginName, current));
-    }
-  }
-}
-
-void Path::addPathInArg(const JSONCPP_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 JSONCPP_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::nullRef) {
-        // 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::nullRef)
-        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
-
-// //////////////////////////////////////////////////////////////////////
-// End of content of file: src/lib_json/json_value.cpp
-// //////////////////////////////////////////////////////////////////////
-
-
-
-
-
-
-// //////////////////////////////////////////////////////////////////////
-// Beginning of content of file: src/lib_json/json_writer.cpp
-// //////////////////////////////////////////////////////////////////////
-
-// Copyright 2011 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
-
-#if !defined(JSON_IS_AMALGAMATION)
-#include <json/writer.h>
-#include "json_tool.h"
-#endif // if !defined(JSON_IS_AMALGAMATION)
-#include <iomanip>
-#include <memory>
-#include <sstream>
-#include <utility>
-#include <set>
-#include <cassert>
-#include <cstring>
-#include <cstdio>
-
-#if defined(_MSC_VER) && _MSC_VER >= 1200 && _MSC_VER < 1800 // Between VC++ 6.0 and VC++ 11.0
-#include <float.h>
-#define isfinite _finite
-#elif defined(__sun) && defined(__SVR4) //Solaris
-#if !defined(isfinite)
-#include <ieeefp.h>
-#define isfinite finite
-#endif
-#elif defined(_AIX)
-#if !defined(isfinite)
-#include <math.h>
-#define isfinite finite
-#endif
-#elif defined(__hpux)
-#if !defined(isfinite)
-#if defined(__ia64) && !defined(finite)
-#define isfinite(x) ((sizeof(x) == sizeof(float) ? \
-                     _Isfinitef(x) : _IsFinite(x)))
-#else
-#include <math.h>
-#define isfinite finite
-#endif
-#endif
-#else
-#include <cmath>
-#if !(defined(__QNXNTO__)) // QNX already defines isfinite
-#define isfinite std::isfinite
-#endif
-#endif
-
-#if defined(_MSC_VER)
-#if !defined(WINCE) && defined(__STDC_SECURE_LIB__) && _MSC_VER >= 1500 // VC++ 9.0 and above
-#define snprintf sprintf_s
-#elif _MSC_VER >= 1900 // VC++ 14.0 and above
-#define snprintf std::snprintf
-#else
-#define snprintf _snprintf
-#endif
-#elif defined(__ANDROID__) || defined(__QNXNTO__)
-#define snprintf snprintf
-#elif __cplusplus >= 201103L
-#if !defined(__MINGW32__) && !defined(__CYGWIN__)
-#define snprintf std::snprintf
-#endif
-#endif
-
-#if defined(__BORLANDC__)
-#include <float.h>
-#define isfinite _finite
-#define snprintf _snprintf
-#endif
-
-#if defined(_MSC_VER) && _MSC_VER >= 1400 // VC++ 8.0
-// Disable warning about strdup being deprecated.
-#pragma warning(disable : 4996)
-#endif
-
-namespace Json {
-
-#if __cplusplus >= 201103L || (defined(_CPPLIB_VER) && _CPPLIB_VER >= 520)
-typedef std::unique_ptr<StreamWriter> StreamWriterPtr;
-#else
-typedef std::auto_ptr<StreamWriter>   StreamWriterPtr;
-#endif
-
-static bool containsControlCharacter(const char* str) {
-  while (*str) {
-    if (isControlCharacter(*(str++)))
-      return true;
-  }
-  return false;
-}
-
-static bool containsControlCharacter0(const char* str, unsigned len) {
-  char const* end = str + len;
-  while (end != str) {
-    if (isControlCharacter(*str) || 0==*str)
-      return true;
-    ++str;
-  }
-  return false;
-}
-
-std::string valueToString(LargestInt value) {
-  UIntToStringBuffer buffer;
-  char* current = buffer + sizeof(buffer);
-  if (value == Value::minLargestInt) {
-    uintToString(LargestUInt(Value::maxLargestInt) + 1, current);
-    *--current = '-';
-  } else if (value < 0) {
-    uintToString(LargestUInt(-value), current);
-    *--current = '-';
-  } else {
-    uintToString(LargestUInt(value), current);
-  }
-  assert(current >= buffer);
-  return current;
-}
-
-std::string valueToString(LargestUInt value) {
-  UIntToStringBuffer buffer;
-  char* current = buffer + sizeof(buffer);
-  uintToString(value, current);
-  assert(current >= buffer);
-  return current;
-}
-
-#if defined(JSON_HAS_INT64)
-
-std::string valueToString(Int value) {
-  return valueToString(LargestInt(value));
-}
-
-std::string valueToString(UInt value) {
-  return valueToString(LargestUInt(value));
-}
-
-#endif // # if defined(JSON_HAS_INT64)
-
-std::string valueToString(double value, bool useSpecialFloats, unsigned int precision) {
-  // Allocate a buffer that is more than large enough to store the 16 digits of
-  // precision requested below.
-  char buffer[32];
-  int len = -1;
-
-  char formatString[6];
-  sprintf(formatString, "%%.%dg", precision);
-
-  // Print into the buffer. We need not request the alternative representation
-  // that always has a decimal point because JSON doesn't distingish the
-  // concepts of reals and integers.
-  if (isfinite(value)) {
-    len = snprintf(buffer, sizeof(buffer), formatString, value);
-  } else {
-    // IEEE standard states that NaN values will not compare to themselves
-    if (value != value) {
-      len = snprintf(buffer, sizeof(buffer), useSpecialFloats ? "NaN" : "null");
-    } else if (value < 0) {
-      len = snprintf(buffer, sizeof(buffer), useSpecialFloats ? "-Infinity" : "-1e+9999");
-    } else {
-      len = snprintf(buffer, sizeof(buffer), useSpecialFloats ? "Infinity" : "1e+9999");
-    }
-    // For those, we do not need to call fixNumLoc, but it is fast.
-  }
-  assert(len >= 0);
-  fixNumericLocale(buffer, buffer + len);
-  return buffer;
-}
-
-std::string valueToString(double value) { return valueToString(value, false, 17); }
-
-std::string valueToString(bool value) { return value ? "true" : "false"; }
-
-std::string valueToQuotedString(const char* value) {
-  if (value == NULL)
-    return "";
-  // 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)) {
-        JSONCPP_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;
-}
-
-// https://github.com/upcaste/upcaste/blob/master/src/upcore/src/cstring/strnpbrk.cpp
-static char const* strnpbrk(char const* s, char const* accept, size_t n) {
-  assert((s || !n) && accept);
-
-  char const* const end = s + n;
-  for (char const* cur = s; cur < end; ++cur) {
-    int const c = *cur;
-    for (char const* a = accept; *a; ++a) {
-      if (*a == c) {
-        return cur;
-      }
-    }
-  }
-  return NULL;
-}
-static std::string valueToQuotedStringN(const char* value, unsigned length) {
-  if (value == NULL)
-    return "";
-  // Not sure how to handle unicode...
-  if (strnpbrk(value, "\"\\\b\f\n\r\t", length) == NULL &&
-      !containsControlCharacter0(value, length))
-    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 =
-      length * 2 + 3; // allescaped+quotes+NULL
-  std::string result;
-  result.reserve(maxsize); // to avoid lots of mallocs
-  result += "\"";
-  char const* end = value + length;
-  for (const char* c = value; c != end; ++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)) || (*c == 0)) {
-        JSONCPP_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), dropNullPlaceholders_(false),
-      omitEndingLineFeed_(false) {}
-
-void FastWriter::enableYAMLCompatibility() { yamlCompatiblityEnabled_ = true; }
-
-void FastWriter::dropNullPlaceholders() { dropNullPlaceholders_ = true; }
-
-void FastWriter::omitEndingLineFeed() { omitEndingLineFeed_ = true; }
-
-std::string FastWriter::write(const Value& root) {
-  document_ = "";
-  writeValue(root);
-  if (!omitEndingLineFeed_)
-    document_ += "\n";
-  return document_;
-}
-
-void FastWriter::writeValue(const Value& value) {
-  switch (value.type()) {
-  case nullValue:
-    if (!dropNullPlaceholders_)
-      document_ += "null";
-    break;
-  case intValue:
-    document_ += valueToString(value.asLargestInt());
-    break;
-  case uintValue:
-    document_ += valueToString(value.asLargestUInt());
-    break;
-  case realValue:
-    document_ += valueToString(value.asDouble());
-    break;
-  case stringValue:
-  {
-    // Is NULL possible for value.string_?
-    char const* str;
-    char const* end;
-    bool ok = value.getString(&str, &end);
-    if (ok) document_ += valueToQuotedStringN(str, static_cast<unsigned>(end-str));
-    break;
-  }
-  case booleanValue:
-    document_ += valueToString(value.asBool());
-    break;
-  case arrayValue: {
-    document_ += '[';
-    ArrayIndex size = value.size();
-    for (ArrayIndex 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_ += valueToQuotedStringN(name.data(), static_cast<unsigned>(name.length()));
-      document_ += yamlCompatiblityEnabled_ ? ": " : ":";
-      writeValue(value[name]);
-    }
-    document_ += '}';
-  } break;
-  }
-}
-
-// Class StyledWriter
-// //////////////////////////////////////////////////////////////////
-
-StyledWriter::StyledWriter()
-    : rightMargin_(74), indentSize_(3), addChildValues_() {}
-
-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.asLargestInt()));
-    break;
-  case uintValue:
-    pushValue(valueToString(value.asLargestUInt()));
-    break;
-  case realValue:
-    pushValue(valueToString(value.asDouble()));
-    break;
-  case stringValue:
-  {
-    // Is NULL possible for value.string_?
-    char const* str;
-    char const* end;
-    bool ok = value.getString(&str, &end);
-    if (ok) pushValue(valueToQuotedStringN(str, static_cast<unsigned>(end-str)));
-    else pushValue("");
-    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();
-      for (;;) {
-        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;
-      for (;;) {
-        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) {
-  ArrayIndex const size = value.size();
-  bool isMultiLine = size * 3 >= rightMargin_;
-  childValues_.clear();
-  for (ArrayIndex index = 0; index < size && !isMultiLine; ++index) {
-    const Value& childValue = value[index];
-    isMultiLine = ((childValue.isArray() || childValue.isObject()) &&
-                        childValue.size() > 0);
-  }
-  if (!isMultiLine) // check if line length > max line length
-  {
-    childValues_.reserve(size);
-    addChildValues_ = true;
-    ArrayIndex lineLength = 4 + (size - 1) * 2; // '[ ' + ', '*n + ' ]'
-    for (ArrayIndex index = 0; index < size; ++index) {
-      if (hasCommentForValue(value[index])) {
-        isMultiLine = true;
-      }
-      writeValue(value[index]);
-      lineLength += static_cast<ArrayIndex>(childValues_[index].length());
-    }
-    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(indentString_.size() >= indentSize_);
-  indentString_.resize(indentString_.size() - indentSize_);
-}
-
-void StyledWriter::writeCommentBeforeValue(const Value& root) {
-  if (!root.hasComment(commentBefore))
-    return;
-
-  document_ += "\n";
-  writeIndent();
-  const std::string& comment = root.getComment(commentBefore);
-  std::string::const_iterator iter = comment.begin();
-  while (iter != comment.end()) {
-    document_ += *iter;
-    if (*iter == '\n' &&
-       (iter != comment.end() && *(iter + 1) == '/'))
-      writeIndent();
-    ++iter;
-  }
-
-  // Comments are stripped of trailing newlines, so add one here
-  document_ += "\n";
-}
-
-void StyledWriter::writeCommentAfterValueOnSameLine(const Value& root) {
-  if (root.hasComment(commentAfterOnSameLine))
-    document_ += " " + root.getComment(commentAfterOnSameLine);
-
-  if (root.hasComment(commentAfter)) {
-    document_ += "\n";
-    document_ += root.getComment(commentAfter);
-    document_ += "\n";
-  }
-}
-
-bool StyledWriter::hasCommentForValue(const Value& value) {
-  return value.hasComment(commentBefore) ||
-         value.hasComment(commentAfterOnSameLine) ||
-         value.hasComment(commentAfter);
-}
-
-// Class StyledStreamWriter
-// //////////////////////////////////////////////////////////////////
-
-StyledStreamWriter::StyledStreamWriter(std::string indentation)
-    : document_(NULL), rightMargin_(74), indentation_(indentation), indented_ (true),
-      addChildValues_() {}
-
-void StyledStreamWriter::write(JSONCPP_OSTREAM& out, const Value& root) {
-  document_ = &out;
-  addChildValues_ = false;
-  indentString_ = "";
-  indented_ = true;
-  writeCommentBeforeValue(root);
-  if (!indented_) writeIndent();
-  indented_ = true;
-  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.asLargestInt()));
-    break;
-  case uintValue:
-    pushValue(valueToString(value.asLargestUInt()));
-    break;
-  case realValue:
-    pushValue(valueToString(value.asDouble()));
-    break;
-  case stringValue:
-  {
-    // Is NULL possible for value.string_?
-    char const* str;
-    char const* end;
-    bool ok = value.getString(&str, &end);
-    if (ok) pushValue(valueToQuotedStringN(str, static_cast<unsigned>(end-str)));
-    else pushValue("");
-    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();
-      for (;;) {
-        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;
-      for (;;) {
-        const Value& childValue = value[index];
-        writeCommentBeforeValue(childValue);
-        if (hasChildValue)
-          writeWithIndent(childValues_[index]);
-        else {
-          if (!indented_) writeIndent();
-          indented_ = true;
-          writeValue(childValue);
-          indented_ = false;
-        }
-        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) {
-  ArrayIndex const size = value.size();
-  bool isMultiLine = size * 3 >= rightMargin_;
-  childValues_.clear();
-  for (ArrayIndex index = 0; index < size && !isMultiLine; ++index) {
-    const Value& childValue = value[index];
-    isMultiLine = ((childValue.isArray() || childValue.isObject()) &&
-                        childValue.size() > 0);
-  }
-  if (!isMultiLine) // check if line length > max line length
-  {
-    childValues_.reserve(size);
-    addChildValues_ = true;
-    ArrayIndex lineLength = 4 + (size - 1) * 2; // '[ ' + ', '*n + ' ]'
-    for (ArrayIndex index = 0; index < size; ++index) {
-      if (hasCommentForValue(value[index])) {
-        isMultiLine = true;
-      }
-      writeValue(value[index]);
-      lineLength += static_cast<ArrayIndex>(childValues_[index].length());
-    }
-    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() {
-  // blep intended this to look at the so-far-written string
-  // to determine whether we are already indented, but
-  // with a stream we cannot do that. So we rely on some saved state.
-  // The caller checks indented_.
-  *document_ << '\n' << indentString_;
-}
-
-void StyledStreamWriter::writeWithIndent(const std::string& value) {
-  if (!indented_) writeIndent();
-  *document_ << value;
-  indented_ = false;
-}
-
-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;
-
-  if (!indented_) writeIndent();
-  const std::string& comment = root.getComment(commentBefore);
-  std::string::const_iterator iter = comment.begin();
-  while (iter != comment.end()) {
-    *document_ << *iter;
-    if (*iter == '\n' &&
-       (iter != comment.end() && *(iter + 1) == '/'))
-      // writeIndent();  // would include newline
-      *document_ << indentString_;
-    ++iter;
-  }
-  indented_ = false;
-}
-
-void StyledStreamWriter::writeCommentAfterValueOnSameLine(const Value& root) {
-  if (root.hasComment(commentAfterOnSameLine))
-    *document_ << ' ' << root.getComment(commentAfterOnSameLine);
-
-  if (root.hasComment(commentAfter)) {
-    writeIndent();
-    *document_ << root.getComment(commentAfter);
-  }
-  indented_ = false;
-}
-
-bool StyledStreamWriter::hasCommentForValue(const Value& value) {
-  return value.hasComment(commentBefore) ||
-         value.hasComment(commentAfterOnSameLine) ||
-         value.hasComment(commentAfter);
-}
-
-//////////////////////////
-// BuiltStyledStreamWriter
-
-/// Scoped enums are not available until C++11.
-struct CommentStyle {
-  /// Decide whether to write comments.
-  enum Enum {
-    None,  ///< Drop all comments.
-    Most,  ///< Recover odd behavior of previous versions (not implemented yet).
-    All  ///< Keep all comments.
-  };
-};
-
-struct BuiltStyledStreamWriter : public StreamWriter
-{
-  BuiltStyledStreamWriter(
-      std::string const& indentation,
-      CommentStyle::Enum cs,
-      std::string const& colonSymbol,
-      std::string const& nullSymbol,
-      std::string const& endingLineFeedSymbol,
-      bool useSpecialFloats,
-      unsigned int precision);
-  int write(Value const& root, JSONCPP_OSTREAM* sout) ;
-private:
-  void writeValue(Value const& value);
-  void writeArrayValue(Value const& value);
-  bool isMultineArray(Value const& value);
-  void pushValue(std::string const& value);
-  void writeIndent();
-  void writeWithIndent(std::string const& value);
-  void indent();
-  void unindent();
-  void writeCommentBeforeValue(Value const& root);
-  void writeCommentAfterValueOnSameLine(Value const& root);
-  static bool hasCommentForValue(const Value& value);
-
-  typedef std::vector<std::string> ChildValues;
-
-  ChildValues childValues_;
-  std::string indentString_;
-  unsigned int rightMargin_;
-  std::string indentation_;
-  CommentStyle::Enum cs_;
-  std::string colonSymbol_;
-  std::string nullSymbol_;
-  std::string endingLineFeedSymbol_;
-  bool addChildValues_ : 1;
-  bool indented_ : 1;
-  bool useSpecialFloats_ : 1;
-  unsigned int precision_;
-};
-BuiltStyledStreamWriter::BuiltStyledStreamWriter(
-      std::string const& indentation,
-      CommentStyle::Enum cs,
-      std::string const& colonSymbol,
-      std::string const& nullSymbol,
-      std::string const& endingLineFeedSymbol,
-      bool useSpecialFloats,
-      unsigned int precision)
-  : rightMargin_(74)
-  , indentation_(indentation)
-  , cs_(cs)
-  , colonSymbol_(colonSymbol)
-  , nullSymbol_(nullSymbol)
-  , endingLineFeedSymbol_(endingLineFeedSymbol)
-  , addChildValues_(false)
-  , indented_(false)
-  , useSpecialFloats_(useSpecialFloats)
-  , precision_(precision)
-{
-}
-int BuiltStyledStreamWriter::write(Value const& root, JSONCPP_OSTREAM* sout)
-{
-  sout_ = sout;
-  addChildValues_ = false;
-  indented_ = true;
-  indentString_ = "";
-  writeCommentBeforeValue(root);
-  if (!indented_) writeIndent();
-  indented_ = true;
-  writeValue(root);
-  writeCommentAfterValueOnSameLine(root);
-  *sout_ << endingLineFeedSymbol_;
-  sout_ = NULL;
-  return 0;
-}
-void BuiltStyledStreamWriter::writeValue(Value const& value) {
-  switch (value.type()) {
-  case nullValue:
-    pushValue(nullSymbol_);
-    break;
-  case intValue:
-    pushValue(valueToString(value.asLargestInt()));
-    break;
-  case uintValue:
-    pushValue(valueToString(value.asLargestUInt()));
-    break;
-  case realValue:
-    pushValue(valueToString(value.asDouble(), useSpecialFloats_, precision_));
-    break;
-  case stringValue:
-  {
-    // Is NULL is possible for value.string_?
-    char const* str;
-    char const* end;
-    bool ok = value.getString(&str, &end);
-    if (ok) pushValue(valueToQuotedStringN(str, static_cast<unsigned>(end-str)));
-    else pushValue("");
-    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();
-      for (;;) {
-        std::string const& name = *it;
-        Value const& childValue = value[name];
-        writeCommentBeforeValue(childValue);
-        writeWithIndent(valueToQuotedStringN(name.data(), static_cast<unsigned>(name.length())));
-        *sout_ << colonSymbol_;
-        writeValue(childValue);
-        if (++it == members.end()) {
-          writeCommentAfterValueOnSameLine(childValue);
-          break;
-        }
-        *sout_ << ",";
-        writeCommentAfterValueOnSameLine(childValue);
-      }
-      unindent();
-      writeWithIndent("}");
-    }
-  } break;
-  }
-}
-
-void BuiltStyledStreamWriter::writeArrayValue(Value const& value) {
-  unsigned size = value.size();
-  if (size == 0)
-    pushValue("[]");
-  else {
-    bool isMultiLine = (cs_ == CommentStyle::All) || isMultineArray(value);
-    if (isMultiLine) {
-      writeWithIndent("[");
-      indent();
-      bool hasChildValue = !childValues_.empty();
-      unsigned index = 0;
-      for (;;) {
-        Value const& childValue = value[index];
-        writeCommentBeforeValue(childValue);
-        if (hasChildValue)
-          writeWithIndent(childValues_[index]);
-        else {
-          if (!indented_) writeIndent();
-          indented_ = true;
-          writeValue(childValue);
-          indented_ = false;
-        }
-        if (++index == size) {
-          writeCommentAfterValueOnSameLine(childValue);
-          break;
-        }
-        *sout_ << ",";
-        writeCommentAfterValueOnSameLine(childValue);
-      }
-      unindent();
-      writeWithIndent("]");
-    } else // output on a single line
-    {
-      assert(childValues_.size() == size);
-      *sout_ << "[";
-      if (!indentation_.empty()) *sout_ << " ";
-      for (unsigned index = 0; index < size; ++index) {
-        if (index > 0)
-          *sout_ << ", ";
-        *sout_ << childValues_[index];
-      }
-      if (!indentation_.empty()) *sout_ << " ";
-      *sout_ << "]";
-    }
-  }
-}
-
-bool BuiltStyledStreamWriter::isMultineArray(Value const& value) {
-  ArrayIndex const size = value.size();
-  bool isMultiLine = size * 3 >= rightMargin_;
-  childValues_.clear();
-  for (ArrayIndex index = 0; index < size && !isMultiLine; ++index) {
-    Value const& childValue = value[index];
-    isMultiLine = ((childValue.isArray() || childValue.isObject()) &&
-                        childValue.size() > 0);
-  }
-  if (!isMultiLine) // check if line length > max line length
-  {
-    childValues_.reserve(size);
-    addChildValues_ = true;
-    ArrayIndex lineLength = 4 + (size - 1) * 2; // '[ ' + ', '*n + ' ]'
-    for (ArrayIndex index = 0; index < size; ++index) {
-      if (hasCommentForValue(value[index])) {
-        isMultiLine = true;
-      }
-      writeValue(value[index]);
-      lineLength += static_cast<ArrayIndex>(childValues_[index].length());
-    }
-    addChildValues_ = false;
-    isMultiLine = isMultiLine || lineLength >= rightMargin_;
-  }
-  return isMultiLine;
-}
-
-void BuiltStyledStreamWriter::pushValue(std::string const& value) {
-  if (addChildValues_)
-    childValues_.push_back(value);
-  else
-    *sout_ << value;
-}
-
-void BuiltStyledStreamWriter::writeIndent() {
-  // blep intended this to look at the so-far-written string
-  // to determine whether we are already indented, but
-  // with a stream we cannot do that. So we rely on some saved state.
-  // The caller checks indented_.
-
-  if (!indentation_.empty()) {
-    // In this case, drop newlines too.
-    *sout_ << '\n' << indentString_;
-  }
-}
-
-void BuiltStyledStreamWriter::writeWithIndent(std::string const& value) {
-  if (!indented_) writeIndent();
-  *sout_ << value;
-  indented_ = false;
-}
-
-void BuiltStyledStreamWriter::indent() { indentString_ += indentation_; }
-
-void BuiltStyledStreamWriter::unindent() {
-  assert(indentString_.size() >= indentation_.size());
-  indentString_.resize(indentString_.size() - indentation_.size());
-}
-
-void BuiltStyledStreamWriter::writeCommentBeforeValue(Value const& root) {
-  if (cs_ == CommentStyle::None) return;
-  if (!root.hasComment(commentBefore))
-    return;
-
-  if (!indented_) writeIndent();
-  const std::string& comment = root.getComment(commentBefore);
-  std::string::const_iterator iter = comment.begin();
-  while (iter != comment.end()) {
-    *sout_ << *iter;
-    if (*iter == '\n' &&
-       (iter != comment.end() && *(iter + 1) == '/'))
-      // writeIndent();  // would write extra newline
-      *sout_ << indentString_;
-    ++iter;
-  }
-  indented_ = false;
-}
-
-void BuiltStyledStreamWriter::writeCommentAfterValueOnSameLine(Value const& root) {
-  if (cs_ == CommentStyle::None) return;
-  if (root.hasComment(commentAfterOnSameLine))
-    *sout_ << " " + root.getComment(commentAfterOnSameLine);
-
-  if (root.hasComment(commentAfter)) {
-    writeIndent();
-    *sout_ << root.getComment(commentAfter);
-  }
-}
-
-// static
-bool BuiltStyledStreamWriter::hasCommentForValue(const Value& value) {
-  return value.hasComment(commentBefore) ||
-         value.hasComment(commentAfterOnSameLine) ||
-         value.hasComment(commentAfter);
-}
-
-///////////////
-// StreamWriter
-
-StreamWriter::StreamWriter()
-    : sout_(NULL)
-{
-}
-StreamWriter::~StreamWriter()
-{
-}
-StreamWriter::Factory::~Factory()
-{}
-StreamWriterBuilder::StreamWriterBuilder()
-{
-  setDefaults(&settings_);
-}
-StreamWriterBuilder::~StreamWriterBuilder()
-{}
-StreamWriter* StreamWriterBuilder::newStreamWriter() const
-{
-  std::string indentation = settings_["indentation"].asString();
-  std::string cs_str = settings_["commentStyle"].asString();
-  bool eyc = settings_["enableYAMLCompatibility"].asBool();
-  bool dnp = settings_["dropNullPlaceholders"].asBool();
-  bool usf = settings_["useSpecialFloats"].asBool();
-  unsigned int pre = settings_["precision"].asUInt();
-  CommentStyle::Enum cs = CommentStyle::All;
-  if (cs_str == "All") {
-    cs = CommentStyle::All;
-  } else if (cs_str == "None") {
-    cs = CommentStyle::None;
-  } else {
-    throwRuntimeError("commentStyle must be 'All' or 'None'");
-  }
-  std::string colonSymbol = " : ";
-  if (eyc) {
-    colonSymbol = ": ";
-  } else if (indentation.empty()) {
-    colonSymbol = ":";
-  }
-  std::string nullSymbol = "null";
-  if (dnp) {
-    nullSymbol = "";
-  }
-  if (pre > 17) pre = 17;
-  std::string endingLineFeedSymbol = "";
-  return new BuiltStyledStreamWriter(
-      indentation, cs,
-      colonSymbol, nullSymbol, endingLineFeedSymbol, usf, pre);
-}
-static void getValidWriterKeys(std::set<std::string>* valid_keys)
-{
-  valid_keys->clear();
-  valid_keys->insert("indentation");
-  valid_keys->insert("commentStyle");
-  valid_keys->insert("enableYAMLCompatibility");
-  valid_keys->insert("dropNullPlaceholders");
-  valid_keys->insert("useSpecialFloats");
-  valid_keys->insert("precision");
-}
-bool StreamWriterBuilder::validate(Json::Value* invalid) const
-{
-  Json::Value my_invalid;
-  if (!invalid) invalid = &my_invalid;  // so we do not need to test for NULL
-  Json::Value& inv = *invalid;
-  std::set<std::string> valid_keys;
-  getValidWriterKeys(&valid_keys);
-  Value::Members keys = settings_.getMemberNames();
-  size_t n = keys.size();
-  for (size_t i = 0; i < n; ++i) {
-    std::string const& key = keys[i];
-    if (valid_keys.find(key) == valid_keys.end()) {
-      inv[key] = settings_[key];
-    }
-  }
-  return 0u == inv.size();
-}
-Value& StreamWriterBuilder::operator[](std::string key)
-{
-  return settings_[key];
-}
-// static
-void StreamWriterBuilder::setDefaults(Json::Value* settings)
-{
-  //! [StreamWriterBuilderDefaults]
-  (*settings)["commentStyle"] = "None";
-  (*settings)["indentation"] = "  ";
-  (*settings)["enableYAMLCompatibility"] = false;
-  (*settings)["dropNullPlaceholders"] = false;
-  (*settings)["useSpecialFloats"] = false;
-  (*settings)["precision"] = 11;
-  //! [StreamWriterBuilderDefaults]
-}
-
-std::string writeString(StreamWriter::Factory const& builder, Value const& root) {
-  JSONCPP_OSTRINGSTREAM sout;
-  StreamWriterPtr const writer(builder.newStreamWriter());
-  writer->write(root, &sout);
-  return sout.str();
-}
-
-JSONCPP_OSTREAM& operator<<(JSONCPP_OSTREAM& sout, Value const& root) {
-  StreamWriterBuilder builder;
-  StreamWriterPtr const writer(builder.newStreamWriter());
-  writer->write(root, &sout);
-  return sout;
-}
-
-} // namespace Json
-
-// //////////////////////////////////////////////////////////////////////
-// End of content of file: src/lib_json/json_writer.cpp
-// //////////////////////////////////////////////////////////////////////
-
-
-
-
diff --git a/src/base/ossimCommon.cpp b/src/base/ossimCommon.cpp
index b953f3d..1faabbe 100644
--- a/src/base/ossimCommon.cpp
+++ b/src/base/ossimCommon.cpp
@@ -23,13 +23,13 @@
 #include <ossim/base/ossimPreferences.h>
 #include <ossim/base/ossimString.h>
 #include <ossim/base/ossimTrace.h>
+#include <ossim/base/Thread.h>
 #include <ossim/matrix/newmat.h>
-#include <OpenThreads/Mutex>
-#include <OpenThreads/Thread>
 #include <ctime>
 #include <sstream>
+#include <mutex>
 
-static OpenThreads::Mutex timeMutex;
+static std::mutex timeMutex;
 static ossimTrace traceDebug("ossimCommon:debug");
 
 // stores a floating point nan value
@@ -958,7 +958,6 @@ bool ossim::extractSimpleValues(std::vector<ossimString>& values,
    {
       c = (char)in.get();
       while((c!=')')&&
-            (c!= '\n')&&
             (in.good()))
       {
          if(c!= ',')
@@ -970,6 +969,7 @@ bool ossim::extractSimpleValues(std::vector<ossimString>& values,
             values.push_back(value);
             value = "";
          }
+         ossim::skipws(in);
          c = in.get();
       }
    }
@@ -1192,7 +1192,7 @@ ossim_uint32 ossim::getNumberOfThreads()
    }
    else
    {
-      result = static_cast<ossim_uint32>( OpenThreads::GetNumberOfProcessors() );
+      result = static_cast<ossim_uint32>( ossim::Thread::getNumberOfProcessors() );
    }
    if ( !result )
    {
@@ -1204,8 +1204,7 @@ ossim_uint32 ossim::getNumberOfThreads()
 void ossim::getFormattedTime(
    const std::string& format, bool gmtFlag, std::string& result )
 {
-   timeMutex.lock();
-   
+   std::lock_guard<std::mutex>   lock(timeMutex);
    time_t rawTime;
    time(&rawTime);
    
@@ -1239,16 +1238,14 @@ void ossim::getFormattedTime(
       result.clear();
    }
 
-   timeMutex.unlock();
 }
 
 ossim_int64 ossim::getTime()
 {
+   std::lock_guard<std::mutex>   lock(timeMutex);
    time_t rawTime;
    
-   timeMutex.lock();
    time(&rawTime);
-   timeMutex.unlock();
    
    return (ossim_int64)rawTime;
 }
diff --git a/src/base/ossimDate.cpp b/src/base/ossimDate.cpp
index ed5b5c0..4757cb4 100644
--- a/src/base/ossimDate.cpp
+++ b/src/base/ossimDate.cpp
@@ -14,7 +14,8 @@
 #include <iomanip>
 #include <sstream>
 #include <iostream>
-OpenThreads::Mutex ossimLocalTm::m_mutex;
+
+std::mutex ossimLocalTm::m_mutex;
 
 std::ostream& operator<< (std::ostream& out, const ossimDate& src)
 {
@@ -714,13 +715,13 @@ m_mutex.unlock();
 
 void ossimLocalTm::setTimeNoAdjustmentGivenEpoc(time_t ticks)
 {
-  OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_mutex);
+  std::lock_guard<std::mutex> lock(m_mutex);
    *this = *gmtime(&ticks);
 }
 
 void ossimLocalTm::setTimeGivenEpoc(time_t ticks)
 {
-  OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_mutex);
+  std::lock_guard<std::mutex> lock(m_mutex);
   *this = *localtime(&ticks);
 }
 
diff --git a/src/base/ossimEllipsoid.cpp b/src/base/ossimEllipsoid.cpp
index 13cf8d5..73c95a5 100644
--- a/src/base/ossimEllipsoid.cpp
+++ b/src/base/ossimEllipsoid.cpp
@@ -261,14 +261,19 @@ bool ossimEllipsoid::nearestIntersection( const ossimEcefRay& ray,
       // sort t1 and t2 and take the nearest intersection if they
       // are in front of the ray.
       //***
-      if ( t2 < t1 )
-      {
-         double temp = t1;
-         t1 = t2;
-         t2 = temp;
-      }     
+//      if ( t2 < t1 )
+//      {
+//         double temp = t1;
+//         t1 = t2;
+//         t2 = temp;
+//      }
+//
+//      double tEstimate = ( t1 > 0.0 ) ? t1 : t2;
 
-      double tEstimate = ( t1 > 0.0 ) ? t1 : t2;
+      // OLK: Alternate means to find closest intersection, not necessarily "in front of" origin:
+      double tEstimate = t1;
+      if (fabs(t2) < fabs(t1))
+         tEstimate = t2;
 
       // Get estimated intersection point.
       ossimEcefPoint rayEcef = ray.extend( tEstimate );
diff --git a/src/base/ossimKeywordNames.cpp b/src/base/ossimKeywordNames.cpp
index 86e9d46..af6d212 100644
--- a/src/base/ossimKeywordNames.cpp
+++ b/src/base/ossimKeywordNames.cpp
@@ -73,6 +73,7 @@ const char* ossimKeywordNames::GCS_CODE_KW = "gcs_code";
 const char* ossimKeywordNames::GEOM_FILE_KW = "geom_file";
 const char* ossimKeywordNames::HEMISPHERE_KW = "hemisphere";
 const char* ossimKeywordNames::HORIZONTAL_SIZE_KW = "horizontal_size";
+const char* ossimKeywordNames::HAS_LUT_KW = "has_lut";
 const char* ossimKeywordNames::ID_KW ="id";
 const char* ossimKeywordNames::IMAGE_CE90_KW  = "estimated_image_ce90";
 const char* ossimKeywordNames::IMAGE_FILE_KW = "image_file";
diff --git a/src/base/ossimKeywordlist.cpp b/src/base/ossimKeywordlist.cpp
index 37f6d80..4a343dc 100755
--- a/src/base/ossimKeywordlist.cpp
+++ b/src/base/ossimKeywordlist.cpp
@@ -21,6 +21,10 @@
 #include <list>
 #include <sstream>
 #include <utility>
+#include <cstddef> // nullptr
+
+#include <ossim/base/BlockIStream.h>
+#include <ossim/base/ossimStreamFactoryRegistry.h>
 
 static ossimTrace traceDebug("ossimKeywordlist:debug");
 
@@ -722,20 +726,18 @@ ossimKeywordlist::getMapEntry(const ossimString& key)
 bool ossimKeywordlist::parseFile(const ossimFilename& file,
                                  bool ignoreBinaryChars)
 {
-   if(!file.exists())
-      return false;
-
    bool result = false;
-   std::ifstream is;
-   is.open(file.c_str(), std::ios::in | std::ios::binary);
 
-   if(!is.fail())
+   std::shared_ptr<ossim::ifstream> is = std::make_shared<ossim::ifstream>(file.c_str(), 
+                                                std::ios::in | std::ios::binary);
+   if(is&&is->is_open())
    {
+      std::shared_ptr<ossim::BlockIStream> blockedStream = std::make_shared<ossim::BlockIStream>(is, 4096);
       m_currentlyParsing = file;
-      result = parseStream(is, ignoreBinaryChars);
+      result = parseStream(*is, ignoreBinaryChars);
    }
 
-   is.close();
+   is = nullptr;
    return result;
 }
 
@@ -1361,9 +1363,10 @@ OSSIMDLLEXPORT std::ostream& operator<<(std::ostream& os,
    return os;
 }
 
-
 bool ossimKeywordlist::operator ==(ossimKeywordlist& kwl)const
 {
+   return (m_map == kwl.m_map);
+   /*
    if(this==&kwl) return true;
    std::map<std::string, std::string>::const_iterator iter = m_map.begin();
    
@@ -1379,6 +1382,12 @@ bool ossimKeywordlist::operator ==(ossimKeywordlist& kwl)const
    }
    
    return true;
+   */
+}
+
+bool ossimKeywordlist::operator !=(ossimKeywordlist& kwl)const
+{
+   return (m_map != kwl.m_map);
 }
 
 ossimKeywordlist&  ossimKeywordlist::downcaseKeywords()
diff --git a/src/base/ossimNotify.cpp b/src/base/ossimNotify.cpp
index c5a317a..f83548b 100644
--- a/src/base/ossimNotify.cpp
+++ b/src/base/ossimNotify.cpp
@@ -16,9 +16,7 @@
 #include <cstddef>
 
 #include <ossim/base/ossimNotify.h>
-#include <OpenThreads/Mutex>
-#include <OpenThreads/ScopedLock>
-
+#include <mutex>
 static std::ostream* theOssimFatalStream  = &std::cerr;
 static std::ostream* theOssimWarnStream   = &std::cerr;
 static std::ostream* theOssimInfoStream   = &std::cout;
@@ -26,7 +24,7 @@ static std::ostream* theOssimNoticeStream = &std::cout;
 static std::ostream* theOssimDebugStream  = &std::cout;
 static std::ostream* theOssimAlwaysStream = &std::cout;
 
-static OpenThreads::Mutex theMutex;
+static std::mutex theMutex;
 static ossimNotifyFlags theNotifyFlags     = ossimNotifyFlags_ALL;
 std::stack<ossimNotifyFlags> theNotifyFlagsStack;
 
@@ -66,10 +64,10 @@ public:
 
 protected:
    ossimFilename theLogFilename;
-   OpenThreads::Mutex fileMutex;
+   std::mutex fileMutex;
    virtual int overflow(int c)
       {
-         OpenThreads::ScopedLock<OpenThreads::Mutex> scopedLock(fileMutex);
+         std::lock_guard<std::mutex> scopedLock(fileMutex);
          if(!traits::eq_int_type(c, traits::eof()))
          {
             tempString = tempString + ossimString((char)c);
@@ -80,7 +78,7 @@ protected:
 
    virtual std::streamsize xsputn(const charT * pChar, std::streamsize n)
       {
-         OpenThreads::ScopedLock<OpenThreads::Mutex> scopedLock(fileMutex);
+         std::lock_guard<std::mutex> scopedLock(fileMutex);
          
          tempString = tempString + ossimString(pChar, pChar + n);
 
@@ -89,7 +87,7 @@ protected:
 
    virtual int sync()
       {
-         OpenThreads::ScopedLock<OpenThreads::Mutex> scopedLock(fileMutex);
+         std::lock_guard<std::mutex> scopedLock(fileMutex);
          flushBuffer();
          return 0;
       }
@@ -164,7 +162,7 @@ static ossimLogFileStream theLogFileStream;
 
 void ossimSetDefaultNotifyHandlers()
 {
-   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(theMutex);
+   std::lock_guard<std::mutex> lock(theMutex);
    theOssimFatalStream  = &std::cerr;
    theOssimWarnStream   = &std::cout;
    theOssimInfoStream   = &std::cout;
@@ -176,7 +174,7 @@ void ossimSetDefaultNotifyHandlers()
 void ossimSetNotifyStream(std::ostream* outputStream,
                           ossimNotifyFlags whichLevelsToRedirect)
 {
-   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(theMutex);
+   std::lock_guard<std::mutex> lock(theMutex);
    if(whichLevelsToRedirect&ossimNotifyFlags_FATAL)
    {
       theOssimFatalStream = outputStream;
@@ -201,7 +199,7 @@ void ossimSetNotifyStream(std::ostream* outputStream,
 
 std::ostream* ossimGetNotifyStream(ossimNotifyLevel whichLevel)
 {
-   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(theMutex);
+   std::lock_guard<std::mutex> lock(theMutex);
    std::ostream* notifyStream = &theOssimNullStream;
 
    switch(whichLevel)
@@ -317,7 +315,7 @@ OSSIMDLLEXPORT std::ostream& ossimNotify(ossimNotifyLevel level)
 
 void ossimSetLogFilename(const ossimFilename& filename)
 {
-   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(theMutex);
+   std::lock_guard<std::mutex> lock(theMutex);
    theLogFileStream.setLogFilename(filename);
 }
 
@@ -350,32 +348,32 @@ ossimString ossimErrorV(const char *fmt, va_list args )
 
 void ossimEnableNotify(ossimNotifyFlags flags)
 {
-   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(theMutex);
+   std::lock_guard<std::mutex> lock(theMutex);
    theNotifyFlags = (ossimNotifyFlags)(theNotifyFlags | flags);
 }
 
 void ossimDisableNotify(ossimNotifyFlags flags)
 {
-   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(theMutex);
+   std::lock_guard<std::mutex> lock(theMutex);
    theNotifyFlags = (ossimNotifyFlags)((ossimNotifyFlags_ALL^flags)&
                                        theNotifyFlags);
 }
 
 void ossimSetNotifyFlag(ossimNotifyFlags notifyFlags)
 {
-   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(theMutex);
+   std::lock_guard<std::mutex> lock(theMutex);
    theNotifyFlags = notifyFlags;
 }
 
 void ossimPushNotifyFlags()
 {
-   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(theMutex);
+   std::lock_guard<std::mutex> lock(theMutex);
    theNotifyFlagsStack.push(theNotifyFlags);
 }
 
 void ossimPopNotifyFlags()
 {
-   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(theMutex);
+   std::lock_guard<std::mutex> lock(theMutex);
    if(theNotifyFlagsStack.empty())
    {
       return;
@@ -386,7 +384,7 @@ void ossimPopNotifyFlags()
 
 ossimNotifyFlags ossimGetNotifyFlags()
 {
-   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(theMutex);
+   std::lock_guard<std::mutex> lock(theMutex);
    return theNotifyFlags;
 }
 
@@ -394,7 +392,7 @@ ossimNotifyFlags ossimGetNotifyFlags()
 
 bool ossimIsReportingEnabled()
 {
-   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(theMutex);
+   std::lock_guard<std::mutex> lock(theMutex);
    return  (theNotifyFlags != ossimNotifyFlags_NONE);
 }
 
@@ -402,7 +400,7 @@ bool ossimIsReportingEnabled()
 void ossimNotify(ossimString msg,
                  ossimNotifyLevel notifyLevel)
 {
-   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(theMutex);
+   std::lock_guard<std::mutex> lock(theMutex);
    ossimNotify(notifyLevel) << msg << "\n";
 }
 
@@ -411,7 +409,7 @@ void ossimSetError( const char* /* className */,
                     const char *fmtString, ...)
 {
    // NOTE: This code has an infinite loop in it!!! (drb)
-   //OpenThreads::ScopedLock<OpenThreads::Mutex> lock(theMutex);
+   //std::lock_guard<std::mutex> lock(theMutex);
    theMutex.lock();
    va_list args;
    
diff --git a/src/base/ossimPolyArea2d.cpp b/src/base/ossimPolyArea2d.cpp
index eaaf643..8e5f6da 100644
--- a/src/base/ossimPolyArea2d.cpp
+++ b/src/base/ossimPolyArea2d.cpp
@@ -28,6 +28,7 @@
 #include <cstdlib>
 #include <exception>
 #include <vector>
+#include <mutex>
 
 class MyGeomFactory : public geos::geom::GeometryFactory
 {
@@ -76,10 +77,10 @@ ossimRefPtr<ossimGeometryFactoryWrapper> OssimPolyArea2dPrivate::m_globalFactory
 OssimPolyArea2dPrivate::OssimPolyArea2dPrivate(GeometryPtr geom)
 :m_geometry(geom)
 {
-   static OpenThreads::Mutex globalFactoryMutex;
+   static std::mutex globalFactoryMutex;
    
    {
-      OpenThreads::ScopedLock<OpenThreads::Mutex> lock(globalFactoryMutex);
+      std::lock_guard<std::mutex> lock(globalFactoryMutex);
       if(!m_globalFactory.valid())
       {
          m_globalFactory = new ossimGeometryFactoryWrapper();
diff --git a/src/base/ossimPolygon.cpp b/src/base/ossimPolygon.cpp
index d1b82d3..f5125eb 100644
--- a/src/base/ossimPolygon.cpp
+++ b/src/base/ossimPolygon.cpp
@@ -434,6 +434,19 @@ bool ossimPolygon::isRectWithin(const ossimIrect &rect) const
     }
     return false;
 }
+
+bool ossimPolygon::rectIntersects(const ossimIrect &rect) const
+{
+   if (  isPointWithin(rect.ul()) ||
+         isPointWithin(rect.ur()) ||
+         isPointWithin(rect.ll()) ||
+         isPointWithin(rect.lr()))
+   {
+      return true;
+   }
+   return false;
+}
+
 /**
 * METHOD: isPolyWithin()
 * Returns true if all the vertices of the given polygon fit within.
diff --git a/src/base/ossimPreferences.cpp b/src/base/ossimPreferences.cpp
index ef82f3e..5b898c5 100644
--- a/src/base/ossimPreferences.cpp
+++ b/src/base/ossimPreferences.cpp
@@ -105,12 +105,16 @@ bool ossimPreferences::loadPreferences()
        */
       if (!parsed_ok)
       {
-         ossimNotify(ossimNotifyLevel_WARN)
+        if(traceDebug())
+        {
+          ossimNotify(ossimNotifyLevel_WARN)
             << "WARNING: " << MODULE
             << ", an error was encountered loading the prefererences "
             << "file at \"" << thePrefFilename << "\" as specified by the "
             << "environment variable \"" << PREF_FILE_ENV_VAR_NAME << "\"."
             << "Preferences were not loaded.\n";
+          
+        }
       }
    }
    if (traceExec())
diff --git a/src/base/ossimReferenced.cpp b/src/base/ossimReferenced.cpp
index ad6488f..f45d7c0 100644
--- a/src/base/ossimReferenced.cpp
+++ b/src/base/ossimReferenced.cpp
@@ -5,15 +5,11 @@
 
 ossimReferenced::~ossimReferenced()
 {
-   if(theRefMutex)
-   {
-      delete theRefMutex;
-      theRefMutex = 0;
-   }
-   if (theRefCount>0)
+   int count = referenceCount();
+   if (count>0)
    {
       ossimNotify(ossimNotifyLevel_WARN)<<"Warning: deleting still referenced object "<<this<<std::endl;
-      ossimNotify(ossimNotifyLevel_WARN)<<"         the final reference count was "<<theRefCount
+      ossimNotify(ossimNotifyLevel_WARN)<<"         the final reference count was "<<count
                                         <<", memory corruption possible."<<std::endl;
    }
 }
diff --git a/src/base/ossimStreamFactory.cpp b/src/base/ossimStreamFactory.cpp
index 889a13f..d103d82 100644
--- a/src/base/ossimStreamFactory.cpp
+++ b/src/base/ossimStreamFactory.cpp
@@ -93,7 +93,7 @@ std::shared_ptr<ossim::ostream> ossim::StreamFactory::createOstream(
 
 std::shared_ptr<ossim::iostream> ossim::StreamFactory::createIOstream(
    const std::string& /*connectionString*/,
-   const ossimKeywordlist& options,
+   const ossimKeywordlist& /* options */,
    std::ios_base::openmode /*mode*/) const
 {
    return std::shared_ptr<ossim::iostream>(0);
diff --git a/src/base/ossimStreamFactoryRegistry.cpp b/src/base/ossimStreamFactoryRegistry.cpp
index e8b4a4f..df8b34b 100644
--- a/src/base/ossimStreamFactoryRegistry.cpp
+++ b/src/base/ossimStreamFactoryRegistry.cpp
@@ -12,7 +12,7 @@
 #include <ossim/base/ossimIoStream.h>
 #include <ossim/base/ossimFilename.h>
 #include <ossim/base/ossimPreferences.h>
-#include <ossim/base/ossimBlockIStream.h>
+#include <ossim/base/BlockIStream.h>
 
 #include <fstream>
 #include <algorithm>
@@ -22,10 +22,9 @@
 ossim::StreamFactoryRegistry* ossim::StreamFactoryRegistry::m_instance = 0;
 static const ossimString ISTREAM_BUFFER_KW = "ossim.stream.factory.registry.istream.buffer";
 static ossimTrace traceDebug("ossimStreamFactoryRegistry:debug");
-
+static std::mutex m_instanceMutex;
 ossim::StreamFactoryRegistry::StreamFactoryRegistry()
 {
-   loadPreferences();
 }
 
 
@@ -35,11 +34,23 @@ ossim::StreamFactoryRegistry::~StreamFactoryRegistry()
 
 ossim::StreamFactoryRegistry* ossim::StreamFactoryRegistry::instance()
 {
+   // because of the loadPreferences for this factory and the fact that
+   // create stream could be recursive the lock and unlock are
+   // a little different here.  We will unlock as quickly as we can
+   // After the unlock then call load preferences
+   m_instanceMutex.lock();
    if(!m_instance)
    {
       m_instance = new ossim::StreamFactoryRegistry();
-
+      m_instance->registerFactory(ossim::StreamFactory::instance());
+      m_instanceMutex.unlock();
+      m_instance->loadPreferences();
+   }
+   else
+   {
+      m_instanceMutex.unlock();
    }
+
    return m_instance;
 }
 
@@ -237,7 +248,7 @@ void ossim::StreamFactoryRegistry::registerFactory(ossim::StreamFactoryBase* fac
 
 void ossim::StreamFactoryRegistry::unregisterFactory(StreamFactoryBase* factory)
 {
-   // OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_factoryListMutex);
+   // std::lock_guard<std::mutex> lock(m_factoryListMutex);
    std::vector<ossim::StreamFactoryBase*>::iterator iter = std::find(
       m_factoryList.begin(), m_factoryList.end(), factory);
    if(iter != m_factoryList.end())
diff --git a/src/base/ossimString.cpp b/src/base/ossimString.cpp
index 94c3ddb..6538201 100644
--- a/src/base/ossimString.cpp
+++ b/src/base/ossimString.cpp
@@ -907,7 +907,10 @@ double ossimString::toDouble(const ossimString& aString)
 ossimString ossimString::toString(bool aValue)
 {
    std::ostringstream s;
-   s << aValue;
+   if (aValue)
+      s << "true";
+   else
+      s << "false";
    ossimString result(s.str());
    return result;
 }
diff --git a/src/base/ossimTerm.cpp b/src/base/ossimTerm.cpp
index db3aade..12b2e4d 100644
--- a/src/base/ossimTerm.cpp
+++ b/src/base/ossimTerm.cpp
@@ -165,8 +165,9 @@ ossimTerm* ossimVar::copy() const{
  *
  * @return     A pointer to that contains the derivative of the term.
  */
-ossimTerm* ossimConst::derivative(const ossim_uint32& variable) const{
-	return new ossimConst(0);
+ossimTerm* ossimConst::derivative(const ossim_uint32& /* variable */ ) const
+{
+   return new ossimConst(0);
 }
 
 
@@ -177,4 +178,4 @@ ossimTerm* ossimConst::derivative(const ossim_uint32& variable) const{
  */
 ossimTerm* ossimConst::copy() const{
 	return new ossimConst(val);
-}
\ No newline at end of file
+}
diff --git a/src/elevation/ossimDtedElevationDatabase.cpp b/src/elevation/ossimDtedElevationDatabase.cpp
index 22c5182..9bac5b3 100644
--- a/src/elevation/ossimDtedElevationDatabase.cpp
+++ b/src/elevation/ossimDtedElevationDatabase.cpp
@@ -7,10 +7,8 @@
 #include <sstream>
 #include <iomanip>
 #include <cstdlib> /* for abs(int) */
-#include <OpenThreads/Thread> //### TODO: for debug, remove
 
 static ossimTrace traceDebug("ossimDtedElevationDatabase:debug");
-static OpenThreads::Mutex d_mutex; // for debug
 RTTI_DEF1(ossimDtedElevationDatabase, "ossimDtedElevationDatabase", ossimElevationCellDatabase);
 
 ossimDtedElevationDatabase::ossimDtedElevationDatabase()
@@ -45,9 +43,8 @@ double ossimDtedElevationDatabase::getHeightAboveMSL(const ossimGpt& gpt)
 {
    if(!isSourceEnabled())
       return ossim::nan();
-
+   std::lock_guard<std::mutex> lock(m_mutex);
    double result = ossim::nan();
-   m_mutex.lock();
    if(m_lastHandler.valid() && m_lastHandler->pointHasCoverage(gpt))
    {
       result = m_lastHandler->getHeightAboveMSL(gpt);
@@ -59,15 +56,6 @@ double ossimDtedElevationDatabase::getHeightAboveMSL(const ossimGpt& gpt)
          result = m_lastHandler->getHeightAboveMSL(gpt);
    }
 
-#if 0
-   d_mutex.lock();
-   cout << "THREAD ID: "<<OpenThreads::Thread::CurrentThread()->getThreadId()<<"  "
-         <<"ossimDtedElevationDatabase @ "<<(unsigned long)this<<"  m_lastHandler @ "
-         <<(unsigned long)m_lastHandler.get()<<endl; //### TODO: for debug, remove
-   d_mutex.unlock();
-#endif
-
-   m_mutex.unlock();
    return result;
 }
 
@@ -108,9 +96,9 @@ bool ossimDtedElevationDatabase::openDtedDirectory(const ossimFilename& dir)
       if ( m_extension.size() == 0 )
       {
          //---
-         // This sets extension by doing a directory scan and is now depricated.
+         // This sets extension by doing a directory scan for files with "dt*".
          // Use "extension" key in preferences to avoid this.  Example:
-         // elevation_manager.elevation_source0.extension: dt2
+         // elevation_manager.elevation_source0.extension: dt2.
          //---
          result = inititializeExtension( dir );
          if ( !result && traceDebug() )
@@ -348,6 +336,11 @@ bool ossimDtedElevationDatabase::inititializeExtension( const ossimFilename& dir
                   d2.getFirst(f, ossimDirectory::OSSIM_DIR_FILES);
                   do
                   {
+                     // The DTED directory may be polluted with cell statistics files and other
+                     // non-DEM items. Skip if not of the expected extension (OLK 10/2017):
+                     if (f.ext().match("[dD][tT][0-9]").empty())
+                        continue;
+
                      ossimRefPtr<ossimDtedHandler> dtedHandler = new ossimDtedHandler();
                      if(dtedHandler->open(f, false))
                      {
diff --git a/src/elevation/ossimDtedHandler.cpp b/src/elevation/ossimDtedHandler.cpp
index 139aabd..ebae8f8 100644
--- a/src/elevation/ossimDtedHandler.cpp
+++ b/src/elevation/ossimDtedHandler.cpp
@@ -351,7 +351,7 @@ double ossimDtedHandler::getHeightAboveMSL(const ossimGpt& gpt, bool readFromFil
 void ossimDtedHandler::readPostsFromFile( DtedHeight &postData, int offset)
 {
 
-  OpenThreads::ScopedLock <OpenThreads::Mutex> lock( m_fileStrMutex );
+  std::lock_guard<std::mutex> lock( m_fileStrMutex );
   ossim_sint16 ss;
   ossim_uint16 us;
   int postCount = 0;
diff --git a/src/elevation/ossimElevManager.cpp b/src/elevation/ossimElevManager.cpp
index f24ef14..e3f1d33 100644
--- a/src/elevation/ossimElevManager.cpp
+++ b/src/elevation/ossimElevManager.cpp
@@ -570,7 +570,7 @@ void ossimElevManager::setRoundRobinMaxSize(ossim_uint32 new_size)
 
 inline ossimElevManager::ElevationDatabaseListType& ossimElevManager::getNextElevDbList() const
 {
-   OpenThreads::ScopedLock<OpenThreads::Mutex> lock (m_mutex);
+   std::lock_guard<std::mutex> lock (m_mutex);
 
    // Quickly grab the DB to be used by this thread and increment DB index to be used by next thread
    // May need to grow the list round robin as it is dynamically set as needed):
diff --git a/src/elevation/ossimElevationCellDatabase.cpp b/src/elevation/ossimElevationCellDatabase.cpp
index 53c0ba8..607612f 100644
--- a/src/elevation/ossimElevationCellDatabase.cpp
+++ b/src/elevation/ossimElevationCellDatabase.cpp
@@ -144,7 +144,7 @@ ossimRefPtr<ossimElevCellHandler> ossimElevationCellDatabase::getOrCreateCellHan
   ossim_uint64 id = createId(gpt);
   
   {
-    OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_cacheMapMutex);
+    std::lock_guard<std::mutex> lock(m_cacheMapMutex);
     CellMap::iterator iter = m_cacheMap.find(id);
     if(iter != m_cacheMap.end())
     {
@@ -158,7 +158,7 @@ ossimRefPtr<ossimElevCellHandler> ossimElevationCellDatabase::getOrCreateCellHan
   result = createCell(gpt);
   
   {
-    OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_cacheMapMutex);
+    std::lock_guard<std::mutex> lock(m_cacheMapMutex);
     if(result.valid())
     {
       m_cacheMap.insert(std::make_pair(id, new CellInfo(id, result.get())));
diff --git a/src/elevation/ossimGeneralRasterElevHandler.cpp b/src/elevation/ossimGeneralRasterElevHandler.cpp
index 1a5bf6f..4f311d4 100644
--- a/src/elevation/ossimGeneralRasterElevHandler.cpp
+++ b/src/elevation/ossimGeneralRasterElevHandler.cpp
@@ -12,7 +12,6 @@
 #include <ossim/base/ossimKeywordlist.h>
 #include <ossim/base/ossimDpt.h>
 #include <ossim/base/ossimGpt.h>
-#include <OpenThreads/ScopedLock>
 
 RTTI_DEF1(ossimGeneralRasterElevHandler, "ossimGeneralRasterElevHandler", ossimElevCellHandler);
 
@@ -206,7 +205,7 @@ double ossimGeneralRasterElevHandler::getPostValue(const ossimIpt& /* gridPt */)
 bool ossimGeneralRasterElevHandler::isOpen()const
 {
    if(!m_memoryMap.empty()) return true;
-   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_inputStreamMutex);
+   std::lock_guard<std::mutex> lock(m_inputStreamMutex);
 
    //---
    // Change to use flag as is_open is non-const on some old compilers.
@@ -489,7 +488,7 @@ double ossimGeneralRasterElevHandler::getHeightAboveMSLFileTemplate(
    std::streampos offset = y0*bytesPerLine + x0*sizeof(T);
    
    {
-      OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_inputStreamMutex);
+      std::lock_guard<std::mutex> lock(m_inputStreamMutex);
       if(m_inputStream.fail())
       {
          m_inputStream.clear();
diff --git a/src/elevation/ossimImageElevationDatabase.cpp b/src/elevation/ossimImageElevationDatabase.cpp
index a7b5626..6a3665d 100644
--- a/src/elevation/ossimImageElevationDatabase.cpp
+++ b/src/elevation/ossimImageElevationDatabase.cpp
@@ -259,7 +259,7 @@ ossimRefPtr<ossimElevCellHandler> ossimImageElevationDatabase::getOrCreateCellHa
 
       if(result.valid())
       {
-         OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_cacheMapMutex);
+         std::lock_guard<std::mutex> lock(m_cacheMapMutex);
 
          //---
          // Add the cell to map.
diff --git a/src/elevation/ossimImageElevationHandler.cpp b/src/elevation/ossimImageElevationHandler.cpp
index c6bbd77..b87223a 100644
--- a/src/elevation/ossimImageElevationHandler.cpp
+++ b/src/elevation/ossimImageElevationHandler.cpp
@@ -21,7 +21,6 @@
 #include <ossim/base/ossimGpt.h>
 #include <ossim/base/ossimTrace.h>
 #include <ossim/imaging/ossimImageHandlerRegistry.h>
-#include <OpenThreads/ScopedLock>
 
 #include <iostream> // tmp drb
 using namespace std;
@@ -214,7 +213,7 @@ ossimImageData* ossimImageElevationHandler::getTile(ossim_uint32 x, ossim_uint32
    ossimRefPtr<ossimImageData> data = 0;
 
    // Search for this tile in the cache:
-   OpenThreads::ScopedWriteLock lock (m_mutex);
+   std::lock_guard<std::mutex> lock(m_mutex);
    vector<TileCacheEntry>::iterator iter = m_tileCache.begin();
    while ((iter != m_tileCache.end()) && (iter->id != tile_id))
       ++iter;
diff --git a/src/elevation/ossimSrtmHandler.cpp b/src/elevation/ossimSrtmHandler.cpp
index 98f5c61..f29286c 100644
--- a/src/elevation/ossimSrtmHandler.cpp
+++ b/src/elevation/ossimSrtmHandler.cpp
@@ -138,7 +138,7 @@ double ossimSrtmHandler::getHeightAboveMSLFileTemplate(T /* dummy */, const ossi
    std::streampos offset = y0 * m_srtmRecordSizeInBytes + x0 * sizeof(T);
 
    {
-      OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_fileStrMutex);
+      std::lock_guard<std::mutex> lock(m_fileStrMutex);
 
       // lets a seek cur
       // 
@@ -406,7 +406,7 @@ bool ossimSrtmHandler::isOpen()const
 {
    if(!m_memoryMap.empty()) return true;
    
-   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_fileStrMutex);
+   std::lock_guard<std::mutex> lock(m_fileStrMutex);
    return m_streamOpen;
    // return (m_fileStr.is_open());
 }
diff --git a/src/imaging/ossimAppFixedTileCache.cpp b/src/imaging/ossimAppFixedTileCache.cpp
index 6423b2f..86bfa90 100644
--- a/src/imaging/ossimAppFixedTileCache.cpp
+++ b/src/imaging/ossimAppFixedTileCache.cpp
@@ -17,7 +17,6 @@
 #include <ossim/base/ossimPreferences.h>
 #include <ossim/base/ossimCommon.h>
 #include <ossim/base/ossimTrace.h>
-#include <OpenThreads/ScopedLock>
 
 ossimAppFixedTileCache* ossimAppFixedTileCache::theInstance = 0;
 ossimAppFixedTileCache::ossimAppFixedCacheId ossimAppFixedTileCache::theUniqueAppIdCounter = 0;
@@ -119,7 +118,7 @@ ossimAppFixedTileCache *ossimAppFixedTileCache::instance(ossim_uint32  maxSize)
 
 void ossimAppFixedTileCache::setMaxCacheSize(ossim_uint32 cacheSize)
 {
-   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(theMutex);
+   std::lock_guard<std::mutex> lock(theMutex);
    theMaxGlobalCacheSize = cacheSize;
    theMaxCacheSize = cacheSize;
    //   theMaxCacheSize      = (ossim_uint32)(theMaxGlobalCacheSize*.2);
@@ -127,7 +126,7 @@ void ossimAppFixedTileCache::setMaxCacheSize(ossim_uint32 cacheSize)
 
 void ossimAppFixedTileCache::flush()
 {
-   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(theMutex);
+   std::lock_guard<std::mutex> lock(theMutex);
    std::map<ossimAppFixedCacheId, ossimFixedTileCache*>::iterator currentIter = theAppCacheMap.begin();
    
    while(currentIter != theAppCacheMap.end())
@@ -140,7 +139,7 @@ void ossimAppFixedTileCache::flush()
 
 void ossimAppFixedTileCache::flush(ossimAppFixedCacheId cacheId)
 {
-   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(theMutex);
+   std::lock_guard<std::mutex> lock(theMutex);
    ossimFixedTileCache* cache = getCache(cacheId);
    {
       if(cache)
@@ -153,7 +152,7 @@ void ossimAppFixedTileCache::flush(ossimAppFixedCacheId cacheId)
 
 void ossimAppFixedTileCache::deleteCache(ossimAppFixedCacheId cacheId)
 {
-   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(theMutex);
+   std::lock_guard<std::mutex> lock(theMutex);
    ossimRefPtr<ossimFixedTileCache> cache = getCache(cacheId);
    {
       std::map<ossimAppFixedCacheId, ossimFixedTileCache*>::iterator iter = theAppCacheMap.find(cacheId);
@@ -170,7 +169,7 @@ void ossimAppFixedTileCache::deleteCache(ossimAppFixedCacheId cacheId)
 ossimAppFixedTileCache::ossimAppFixedCacheId ossimAppFixedTileCache::newTileCache(const ossimIrect& tileBoundaryRect,
                                                                                   const ossimIpt& tileSize)
 {
-   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(theMutex);
+   std::lock_guard<std::mutex> lock(theMutex);
    ossimAppFixedCacheId result = -1; 
    ossimFixedTileCache* newCache = new ossimFixedTileCache;
    if(tileSize.x == 0 ||
@@ -193,7 +192,7 @@ ossimAppFixedTileCache::ossimAppFixedCacheId ossimAppFixedTileCache::newTileCach
 
 ossimAppFixedTileCache::ossimAppFixedCacheId ossimAppFixedTileCache::newTileCache()
 {
-   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(theMutex);
+   std::lock_guard<std::mutex> lock(theMutex);
    ossimAppFixedCacheId result = -1;
    ossimFixedTileCache* newCache = new ossimFixedTileCache;
    
@@ -210,7 +209,7 @@ ossimAppFixedTileCache::ossimAppFixedCacheId ossimAppFixedTileCache::newTileCach
 void ossimAppFixedTileCache::setRect(ossimAppFixedCacheId cacheId,
                                      const ossimIrect& boundaryTileRect)
 {
-   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(theMutex);
+   std::lock_guard<std::mutex> lock(theMutex);
    ossimFixedTileCache* cache = getCache(cacheId);
    if(cache)
    {
@@ -226,7 +225,7 @@ void ossimAppFixedTileCache::setRect(ossimAppFixedCacheId cacheId,
 void ossimAppFixedTileCache::setTileSize(ossimAppFixedCacheId cacheId,
                                          const ossimIpt& tileSize)
 {
-   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(theMutex);
+   std::lock_guard<std::mutex> lock(theMutex);
    ossimFixedTileCache* cache = getCache(cacheId);
    if(cache)
    {
@@ -241,7 +240,7 @@ ossimRefPtr<ossimImageData> ossimAppFixedTileCache::getTile(
    ossimAppFixedCacheId cacheId,
    const ossimIpt& origin)
 {
-   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(theMutex);
+   std::lock_guard<std::mutex> lock(theMutex);
    ossimRefPtr<ossimImageData> result = 0;
    ossimFixedTileCache* cache = getCache(cacheId);
    if(cache)
@@ -258,7 +257,7 @@ ossimRefPtr<ossimImageData> ossimAppFixedTileCache::addTile(
                                                             ossimRefPtr<ossimImageData> data,
                                                             bool duplicateData)
 {
-   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(theMutex);
+   std::lock_guard<std::mutex> lock(theMutex);
    ossimRefPtr<ossimImageData> result = 0;
    ossimFixedTileCache *aCache = this->getCache(cacheId);
    if(!aCache)
@@ -295,7 +294,7 @@ ossimRefPtr<ossimImageData> ossimAppFixedTileCache::addTile(
 
 void ossimAppFixedTileCache::deleteAll()
 {
-   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(theMutex);
+   std::lock_guard<std::mutex> lock(theMutex);
    theCurrentCacheSize = 0;
    theAppCacheMap.clear();
 }
@@ -304,7 +303,7 @@ ossimRefPtr<ossimImageData> ossimAppFixedTileCache::removeTile(
    ossimAppFixedCacheId cacheId,
    const ossimIpt& origin)
 {
-   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(theMutex);
+   std::lock_guard<std::mutex> lock(theMutex);
    ossimRefPtr<ossimImageData> result = 0;
    
    ossimFixedTileCache* cache = getCache(cacheId);
@@ -321,7 +320,7 @@ ossimRefPtr<ossimImageData> ossimAppFixedTileCache::removeTile(
 void ossimAppFixedTileCache::deleteTile(ossimAppFixedCacheId cacheId,
                                         const ossimIpt& origin)
 {
-   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(theMutex);
+   std::lock_guard<std::mutex> lock(theMutex);
    ossimFixedTileCache* cache = getCache(cacheId);
    if(cache)
    {
@@ -420,7 +419,7 @@ void ossimAppFixedTileCache::shrinkCacheSize(ossimFixedTileCache* cache,
 
 const ossimIpt& ossimAppFixedTileCache::getTileSize(ossimAppFixedCacheId cacheId)
 {
-   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(theMutex);
+   std::lock_guard<std::mutex> lock(theMutex);
    ossimFixedTileCache* cache = getCache(cacheId);
    if(cache)
    {
diff --git a/src/imaging/ossimBandSelector.cpp b/src/imaging/ossimBandSelector.cpp
index 8fd4538..0fc7137 100644
--- a/src/imaging/ossimBandSelector.cpp
+++ b/src/imaging/ossimBandSelector.cpp
@@ -123,6 +123,7 @@ void ossimBandSelector::setOutputBandList( const vector<ossim_uint32>& outputBan
    if ( outputBandList.size() )
    {
       m_outputBandList = outputBandList;  // Assign the new list.
+      m_passThroughFlag = false; // Assume no pass thru first
       if ( !disablePassThru )
       {
          bool setBands = false;
@@ -460,7 +461,8 @@ void ossimBandSelector::checkPassThrough()
    m_passThroughFlag = ((theInputConnection == 0)||!outputBandsWithinInputRange());
    
    // check if marked with improper bands
-   if(m_passThroughFlag) return;
+   if(m_passThroughFlag)
+      return;
    
    if(theInputConnection)
    {
@@ -469,8 +471,7 @@ void ossimBandSelector::checkPassThrough()
 
       if ( inputList.size() == m_outputBandList.size() )
       {
-         const std::vector<ossim_uint32>::size_type SIZE =
-            m_outputBandList.size();
+         const std::vector<ossim_uint32>::size_type SIZE = m_outputBandList.size();
       
          std::vector<ossim_uint32>::size_type i = 0;
          while (i < SIZE)
@@ -491,9 +492,8 @@ void ossimBandSelector::checkPassThrough()
    {
       if(traceDebug())
       {
-         ossimNotify(ossimNotifyLevel_WARN)
-         << "ossimBandSelector::isOrderedCorrectly() ERROR:"
-         << "Method called prior to initialization!\n";
+         ossimNotify(ossimNotifyLevel_WARN) << "ossimBandSelector::isOrderedCorrectly() ERROR: "
+               "Method called prior to initialization!\n";
       }
    }
 
diff --git a/src/imaging/ossimCacheTileSource.cpp b/src/imaging/ossimCacheTileSource.cpp
index e64c1f0..e29dc02 100644
--- a/src/imaging/ossimCacheTileSource.cpp
+++ b/src/imaging/ossimCacheTileSource.cpp
@@ -83,7 +83,7 @@ ossimRefPtr<ossimImageData> ossimCacheTileSource::getTile(
 {
    if(traceDebug())
    {
-      std::cout << "CACHE TILE START: " << tileRect << std::endl;
+      ossimNotify(ossimNotifyLevel_DEBUG) << "CACHE TILE START: " << tileRect << std::endl;
    }
    ossimRefPtr<ossimImageData> result = 0;
    
@@ -118,7 +118,7 @@ ossimRefPtr<ossimImageData> ossimCacheTileSource::getTile(
    } // End:  if ( theInputConnection )
    if(traceDebug())
    {
-     std::cout << "CACHE TILE END: " << tileRect << std::endl;
+     ossimNotify(ossimNotifyLevel_DEBUG) << "CACHE TILE END: " << tileRect << std::endl;
    }
 
    return result;
diff --git a/src/imaging/ossimCodecBase.cpp b/src/imaging/ossimCodecBase.cpp
index ccc2e1d..22f4db1 100644
--- a/src/imaging/ossimCodecBase.cpp
+++ b/src/imaging/ossimCodecBase.cpp
@@ -1,3 +1 @@
 #include <ossim/imaging/ossimCodecBase.h>
-
-RTTI_DEF2(ossimCodecBase, "ossimCodecBase", ossimObject, ossimPropertyInterface);
\ No newline at end of file
diff --git a/src/imaging/ossimFixedTileCache.cpp b/src/imaging/ossimFixedTileCache.cpp
index 24e3bb5..dd30633 100644
--- a/src/imaging/ossimFixedTileCache.cpp
+++ b/src/imaging/ossimFixedTileCache.cpp
@@ -43,7 +43,7 @@ ossimFixedTileCache::~ossimFixedTileCache()
 void ossimFixedTileCache::setRect(const ossimIrect& rect)
 {
    {
-      OpenThreads::ScopedLock<OpenThreads::Mutex> lock(theMutex);
+      std::lock_guard<std::mutex> lock(theMutex);
       ossim::defaultTileSize(theTileSize);
       theTileBoundaryRect      = rect;
       theTileBoundaryRect.stretchToTileBoundary(theTileSize);
@@ -59,7 +59,7 @@ void ossimFixedTileCache::setRect(const ossimIrect& rect,
                                   const ossimIpt& tileSize)
 {
    {
-      OpenThreads::ScopedLock<OpenThreads::Mutex> lock(theMutex);
+      std::lock_guard<std::mutex> lock(theMutex);
       theTileBoundaryRect      = rect;
       theTileSize              = tileSize;
       theTileBoundaryRect.stretchToTileBoundary(theTileSize);
@@ -74,7 +74,7 @@ void ossimFixedTileCache::setRect(const ossimIrect& rect,
 
 void ossimFixedTileCache::keepTilesWithinRect(const ossimIrect& rect)
 {
-   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(theMutex);
+   std::lock_guard<std::mutex> lock(theMutex);
    std::map<ossim_int32, ossimFixedTileCacheInfo>::iterator tileIter = theTileMap.begin();
 
    while(tileIter != theTileMap.end())
@@ -94,7 +94,7 @@ void ossimFixedTileCache::keepTilesWithinRect(const ossimIrect& rect)
 ossimRefPtr<ossimImageData> ossimFixedTileCache::addTile(ossimRefPtr<ossimImageData> imageData,
                                                          bool duplicateData)
 {
-   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(theMutex);
+   std::lock_guard<std::mutex> lock(theMutex);
    ossimRefPtr<ossimImageData> result = NULL;
    if(!imageData.valid())
    {
@@ -139,7 +139,7 @@ ossimRefPtr<ossimImageData> ossimFixedTileCache::addTile(ossimRefPtr<ossimImageD
 
 ossimRefPtr<ossimImageData> ossimFixedTileCache::getTile(ossim_int32 id)
 {
-   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(theMutex);
+   std::lock_guard<std::mutex> lock(theMutex);
    ossimRefPtr<ossimImageData> result = NULL;
 
    std::map<ossim_int32, ossimFixedTileCacheInfo>::iterator tileIter =
@@ -155,7 +155,7 @@ ossimRefPtr<ossimImageData> ossimFixedTileCache::getTile(ossim_int32 id)
 
 ossimIpt ossimFixedTileCache::getTileOrigin(ossim_int32 tileId)
 {
-   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(theMutex);
+   std::lock_guard<std::mutex> lock(theMutex);
    ossimIpt result;
    result.makeNan();
 
@@ -212,7 +212,7 @@ void ossimFixedTileCache::deleteTile(ossim_int32 tileId)
 
 ossimRefPtr<ossimImageData> ossimFixedTileCache::removeTile(ossim_int32 tileId)
 {
-   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(theMutex);
+   std::lock_guard<std::mutex> lock(theMutex);
    ossimRefPtr<ossimImageData> result = NULL;
    
    std::map<ossim_int32, ossimFixedTileCacheInfo>::iterator tileIter =
@@ -234,7 +234,7 @@ ossimRefPtr<ossimImageData> ossimFixedTileCache::removeTile(ossim_int32 tileId)
 
 void ossimFixedTileCache::flush()
 {
-   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(theMutex);
+   std::lock_guard<std::mutex> lock(theMutex);
    std::map<ossim_int32, ossimFixedTileCacheInfo>::iterator tileIter =
       theTileMap.begin();
 
@@ -253,7 +253,7 @@ void ossimFixedTileCache::flush()
 
 void ossimFixedTileCache::deleteTile()
 {
-   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(theMutex);
+   std::lock_guard<std::mutex> lock(theMutex);
    if(theUseLruFlag)
    {
       if(theLruQueue.begin() != theLruQueue.end())
@@ -265,7 +265,7 @@ void ossimFixedTileCache::deleteTile()
 
 ossimRefPtr<ossimImageData> ossimFixedTileCache::removeTile()
 {
-   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(theMutex);
+   std::lock_guard<std::mutex> lock(theMutex);
    if(theUseLruFlag)
    {
       if(theLruQueue.begin() != theLruQueue.end())
diff --git a/src/imaging/ossimGeneralRasterInfo.cpp b/src/imaging/ossimGeneralRasterInfo.cpp
index 57f68bd..8e29f1e 100644
--- a/src/imaging/ossimGeneralRasterInfo.cpp
+++ b/src/imaging/ossimGeneralRasterInfo.cpp
@@ -20,7 +20,7 @@
 #include <ossim/base/ossimScalarTypeLut.h>
 #include <ossim/base/ossimString.h>
 #include <ossim/base/ossimTrace.h>
-#include <ossim/imaging/ossimImageMetaData.h>
+#include <ossim/support_data/ossimImageMetaData.h>
 #include <ossim/support_data/ossimEnviHeader.h>
 #include <ossim/support_data/ossimFgdcXmlDoc.h>
 
diff --git a/src/imaging/ossimImageDataFactory.cpp b/src/imaging/ossimImageDataFactory.cpp
index f1e2773..e3abb9a 100644
--- a/src/imaging/ossimImageDataFactory.cpp
+++ b/src/imaging/ossimImageDataFactory.cpp
@@ -30,7 +30,7 @@
 static ossimTrace traceDebug("ossimImageDataFactory:debug");
 
 ossimImageDataFactory* ossimImageDataFactory::theInstance = 0;
-OpenThreads::Mutex ossimImageDataFactory::theInstanceMutex;
+std::mutex ossimImageDataFactory::theInstanceMutex;
 ossimImageDataFactory::ossimImageDataFactory() 
 {
    theInstance = 0;
diff --git a/src/imaging/ossimImageHandler.cpp b/src/imaging/ossimImageHandler.cpp
index d117b39..aed5b1c 100755
--- a/src/imaging/ossimImageHandler.cpp
+++ b/src/imaging/ossimImageHandler.cpp
@@ -267,13 +267,51 @@ bool ossimImageHandler::loadState(const ossimKeywordlist& kwl,
 bool ossimImageHandler::initVertices(const char* file)
 {
    static const char MODULE[] = "ossimImageHandler::initVertices";
+   bool loadFromFileFlag = true;
+   std::shared_ptr<ossimKeywordlist> kwl;
+   if(m_state)
+   {
+      bool validVerticesFlag = false;
+      if(m_state->getValidVertices())
+      {
+         loadFromFileFlag = false;
+         kwl = m_state->getValidVertices();
+         if(kwl)
+         {
+            ossimString connectionString = kwl->find("connection_string");
+            if(connectionString != file)
+            {
+               loadFromFileFlag = true;
+            }
+            else if(kwl->getSize()<=0)
+            {
+               return false;
+            }
+         }
+      }
+      else
+      {
+         loadFromFileFlag = true;
+      }
+   }
+   if(!kwl) kwl = std::make_shared<ossimKeywordlist>();
 
-   ossimFilename f = file;
-   if (!f.exists()) return false;
+   if(loadFromFileFlag)
+   {
+      kwl = std::make_shared<ossimKeywordlist>();
+      std::shared_ptr<ossim::istream> instream = ossim::StreamFactoryRegistry::instance()->createIstream(file);
+      kwl->add("connection_string", file, true);
+      if (!instream)
+      {
+         if(m_state) m_state->setValidVertices(kwl);
+         return false; 
+      } 
 
-   ossimKeywordlist kwl(file);
+      kwl->parseStream(*instream);
+      if(m_state) m_state->setValidVertices(kwl);
+   }
    
-   if (kwl.getErrorStatus() != ossimErrorCodes::OSSIM_OK)
+   if (kwl->getErrorStatus() != ossimErrorCodes::OSSIM_OK)
    {
       if (traceDebug())
       {
@@ -286,52 +324,29 @@ bool ossimImageHandler::initVertices(const char* file)
 
    // Clean out any old vertices...
    theValidImageVertices.clear();
-
-   ossim_uint32 number_of_points = kwl.numberOf("point", "x");
-
-   for (ossim_uint32 i=0; i<number_of_points; ++i)
+   std::vector<ossimString> indexedPrefixes;
+   kwl->getSortedList(indexedPrefixes, "point");
+   ossim_uint32 number_of_points = indexedPrefixes.size();
+   for (ossim_uint32 i=0; i<number_of_points; i++)
    {
       ossimIpt pt;
       const char* lookup;
-      ossimString p = "point";
-      p += ossimString::toString(i);
-      
-      ossimString px = p + ".x";
-      lookup = kwl.find(px.c_str());
+      lookup = kwl->find(indexedPrefixes[i], ".x");
       if (lookup)
       {
          pt.x = atoi(lookup);
+         lookup = kwl->find(indexedPrefixes[i], ".y");
+         if (lookup)
+            pt.y = atoi(lookup);
       }
-      else
+
+      if (!lookup)
       {
          if (traceDebug())
-         {
-            CLOG << " ERROR:"
-                 << "\nlookup failed for:  " << px.c_str()
-                 << "\nReturning..."
-                 << std::endl;
-         }
+            CLOG << " ERROR: lookup failed for: " << indexedPrefixes[i] << std::endl;
          return false;
       }
          
-      ossimString py = p + ".y";
-      lookup = kwl.find(py.c_str());
-      if (lookup)
-      {
-         pt.y = atoi(lookup);
-      }
-      else
-      {
-         if (traceDebug())
-         {
-            CLOG << " ERROR:"
-                 << "\nLookup failed for:  " << py.c_str()
-                 << "\nReturning..."
-                 << std::endl;
-         }
-         return false;
-      }
-
       theValidImageVertices.push_back(pt);
    }
 
@@ -339,7 +354,7 @@ bool ossimImageHandler::initVertices(const char* file)
    if (traceDebug())
    {
       CLOG << " DEBUG:"
-           << "\nVertices file:  " << f
+           << "\nVertices file:  " << file
            << "\nValid image vertices:"
            << std::endl;
       for (ossim_uint32 i=0; i<theValidImageVertices.size(); ++i)
@@ -709,7 +724,6 @@ ossimRefPtr<ossimImageGeometry> ossimImageHandler::getImageGeometry()
 ossimRefPtr<ossimImageGeometry> ossimImageHandler::getExternalImageGeometry() const
 {
    ossimRefPtr<ossimImageGeometry> geom = 0;
-
    // No geometry object has been set up yet. Check for external geometry file.
    // Try "foo.geom" if image is "foo.tif":
    ossimFilename filename;
@@ -721,7 +735,8 @@ ossimRefPtr<ossimImageGeometry> ossimImageHandler::getExternalImageGeometry() co
       filename = getFilenameWithThisExtension(ossimString(".geom"), true);
    }
 
-#if 0 /* getgetFilenameWithThisExt... methods tack on sup dir if set. drb */
+#if 0 
+/* getgetFilenameWithThisExt... methods tack on sup dir if set. drb */
    if(!filename.exists())
    {
       // Try supplementary data directory for remote geometry:
@@ -828,7 +843,6 @@ bool ossimImageHandler::hasOverviews() const
 bool ossimImageHandler::openOverview(const ossimFilename& overview_file)
 {
    bool result = false;
-   
    closeOverview();
 
    if (overview_file != theImageFile) // Make sure we don't open ourselves.
@@ -842,7 +856,6 @@ bool ossimImageHandler::openOverview(const ossimFilename& overview_file)
 
       // Try to open:
       theOverview = ossimImageHandlerRegistry::instance()->openOverview( overview_file );
-
       if (theOverview.valid())
       {
          result = true;
@@ -872,7 +885,10 @@ bool ossimImageHandler::openOverview(const ossimFilename& overview_file)
             theOverview->setMaxPixelValue(band, getMaxPixelValue(band));
             theOverview->setNullPixelValue(band, getNullPixelValue(band));
          }
-
+         if(m_state)
+         { 
+            m_state->setOverviewState(theOverview->getState());
+         }
          if (traceDebug())
          {
             ossimNotify(ossimNotifyLevel_DEBUG)
@@ -891,6 +907,14 @@ bool ossimImageHandler::openOverview(const ossimFilename& overview_file)
          event.setObjectList(theOverview.get());
          fireEvent(event);
       }
+      else
+      {
+         if(m_state)
+         {
+            // create a null state to save the fact that we did not find any overviews
+            m_state->setOverviewState(std::make_shared<ossim::ImageHandlerState>());
+         }
+      }
    }
    
    return result;
@@ -907,7 +931,72 @@ bool ossimImageHandler::openOverview()
    bool result = false;
    
    closeOverview();
-   
+
+   if(m_state)
+   {
+      // check if we have an overview state
+      std::shared_ptr<ossim::ImageHandlerState> overviewState = m_state->getOverviewState();
+      if(overviewState)
+      {
+         // check to see if the overvies state was cached 
+         // to mark has checked but no overview
+         if(overviewState->getConnectionString().empty())
+         {
+            return false;
+         }
+         ossim_uint32 overviewStartingResLevel = getNumberOfDecimationLevels();
+         theOverview = ossimImageHandlerRegistry::instance()->open( overviewState );
+         if(theOverview)
+         {
+            result = true;
+
+            
+            //---
+            // Set the owner in case the overview reader needs to get something
+            // from the it like min/max/null.
+            //---
+            theOverview->changeOwner(this);
+            
+            // Set the starting res level of the overview.
+            theOverview->setStartingResLevel(overviewStartingResLevel);
+            
+            // Capture the file name.
+            theOverviewFile = overviewState->getConnectionString();
+
+            //---
+            // Some overview handlers cannot store what the null is.  Like dted
+            // null is -32767 not default -32768 so this allows passing this to the
+            // overview reader provided it overrides setMin/Max/NullPixel value
+            // methods. (drb)
+            //---
+            const ossim_uint32 BANDS = getNumberOfOutputBands();
+            for (ossim_uint32 band = 0; band < BANDS; ++band)
+            {
+               theOverview->setMinPixelValue(band, getMinPixelValue(band));
+               theOverview->setMaxPixelValue(band, getMaxPixelValue(band));
+               theOverview->setNullPixelValue(band, getNullPixelValue(band));
+            }
+            if (traceDebug())
+            {
+               ossimNotify(ossimNotifyLevel_DEBUG)
+                  << "overview starting res level: " << overviewStartingResLevel
+                  << "\noverview levels: "
+                  << theOverview->getNumberOfDecimationLevels()
+                  << "\nlevels: " << getNumberOfDecimationLevels()
+                  << endl;
+            }
+            
+            //---
+            // This is not really a container event; however, using for now.
+            //---
+            ossimContainerEvent event(this,
+                                      OSSIM_EVENT_ADD_OBJECT_ID);
+            event.setObjectList(theOverview.get());
+            fireEvent(event);
+            return result;
+         }
+      } 
+   }
    // 1) ESH 03/2009 -- Use the overview file set e.g. using a .spec file.
    ossimFilename overviewFilename = getOverviewFile();
 
@@ -1021,7 +1110,7 @@ bool ossimImageHandler::writeValidImageVertices(const std::vector<ossimIpt>& ver
                      "x",
                      theValidImageVertices[i].x,
                      true);
-	 tempKwl.add(prefix.c_str(),
+	      tempKwl.add(prefix.c_str(),
                      "y",
                      theValidImageVertices[i].y,
                      true);
@@ -1098,6 +1187,21 @@ bool ossimImageHandler::open(const ossimFilename& imageFile,
    return result;
 }
 
+bool ossimImageHandler::open(std::shared_ptr<ossim::ImageHandlerState> state)
+{
+   bool result = false;
+   if(isOpen())
+   {
+      close();
+   }
+   setFilename(state->getConnectionString());
+   setState(state);
+   result = open();
+
+   return result;
+}
+
+
 bool ossimImageHandler::isValidRLevel(ossim_uint32 resLevel) const
 {
    bool result = false;
@@ -1161,6 +1265,7 @@ void ossimImageHandler::close()
    theGeometry = 0;
    theValidImageVertices.clear();
    theDecimationFactors.clear();
+   setState(0);
 }
 
 bool ossimImageHandler::isBandSelector() const
@@ -1266,48 +1371,43 @@ bool ossimImageHandler::isImageTiled() const
 
 void ossimImageHandler::loadMetaData()
 {
-   ossimFilename filename = getFilenameWithThisExtension(ossimString(".omd"), false);
-   theMetaData.clear();
 
-   std::shared_ptr<ossim::istream> instream = ossim::StreamFactoryRegistry::instance()->createIstream(filename.c_str());
-
-   if(!instream)
+   if(m_state&&m_state->getMetaData())
    {
-      filename = getFilenameWithThisExtension(ossimString(".omd"), true);
-      instream = ossim::StreamFactoryRegistry::instance()->createIstream(filename.c_str());
-   }
-
-   if(instream)
-   {
-     ossimKeywordlist kwl;
-     
-     kwl.parseStream(*instream);
-     
-     theMetaData.loadState(kwl);
+      theMetaData = *m_state->getMetaData();
    }
    else
    {
-     theMetaData.setScalarType(getOutputScalarType());
-   }
-/*
-  ossimFilename filename = getFilenameWithThisExtension(ossimString(".omd"), false);
-  if ( filename.exists() == false )
-  {
-     filename = getFilenameWithThisExtension(ossimString(".omd"), true);
-  }
-  if(filename.exists())
-  {
-     ossimKeywordlist kwl;
-     
-     kwl.addFile(filename.c_str());
-     
-     theMetaData.loadState(kwl);
-  }
-  else
-  {
-     theMetaData.setScalarType(getOutputScalarType());
-  }
-  */
+      ossimFilename filename = getFilenameWithThisExtension(ossimString(".omd"), false);
+      theMetaData.clear();
+
+      std::shared_ptr<ossim::istream> instream = ossim::StreamFactoryRegistry::instance()->createIstream(filename.c_str());
+
+      if(!instream)
+      {
+         filename = getFilenameWithThisExtension(ossimString(".omd"), true);
+         instream = ossim::StreamFactoryRegistry::instance()->createIstream(filename.c_str());
+      }
+
+      if(instream)
+      {
+        ossimKeywordlist kwl;
+        
+        kwl.parseStream(*instream);
+        
+        theMetaData.loadState(kwl);
+      }
+      else
+      {
+        theMetaData.setScalarType(getOutputScalarType());
+      }
+      if(m_state)
+      {
+         m_state->setMetaData(std::make_shared<ossimImageMetaData>(theMetaData));         
+      }
+
+   }
+
 }
 
 double ossimImageHandler::getMinPixelValue(ossim_uint32 band)const
@@ -1361,7 +1461,7 @@ ossim_uint32 ossimImageHandler::getCurrentEntry()const
    return 0;
 }
 
-bool ossimImageHandler::setCurrentEntry(ossim_uint32 /* entryIdx */)
+bool ossimImageHandler::setCurrentEntry(ossim_uint32  entryIdx )
 {
    return true;
 }
@@ -1416,12 +1516,20 @@ void ossimImageHandler::getEntryName( ossim_uint32 entryIdx, std::string& name )
 
 void ossimImageHandler::completeOpen()
 {
+   if(traceDebug())
+   {
+      ossimNotify(ossimNotifyLevel_DEBUG) << "ossimImageHandler::completeOpen(): Entered........" << std::endl;
+   }
    loadMetaData();
    if ( theOpenOverviewFlag )
    {
       openOverview();
    }
    establishDecimationFactors();
+   if(traceDebug())
+   {
+      ossimNotify(ossimNotifyLevel_DEBUG) << "ossimImageHandler::completeOpen(): Leaving......." << std::endl;
+   }
    openValidVertices();
 }
 
diff --git a/src/imaging/ossimImageHandlerFactory.cpp b/src/imaging/ossimImageHandlerFactory.cpp
index 02f3a15..b4f58c8 100644
--- a/src/imaging/ossimImageHandlerFactory.cpp
+++ b/src/imaging/ossimImageHandlerFactory.cpp
@@ -455,6 +455,30 @@ ossimImageHandler* ossimImageHandlerFactory::open(const ossimKeywordlist& kwl,
    return result.release();
 }
 
+ossimRefPtr<ossimImageHandler> ossimImageHandlerFactory::open(std::shared_ptr<ossim::ImageHandlerState> state)const
+{
+   ossimRefPtr<ossimImageHandler> result = 0;
+   if(state)
+   {
+      ossimRefPtr<ossimObject> obj = createObject(state->getImageHandlerType());
+      if(obj)
+      {
+         result = dynamic_cast<ossimImageHandler*>(obj.get());
+         if(result)
+         {
+            if(!result->open(state))
+            {
+               result = 0;
+            }
+         }
+         obj = 0;
+      }
+      
+   }
+
+   return result; 
+}
+
 ossimRefPtr<ossimImageHandler> ossimImageHandlerFactory::openOverview(
    const ossimFilename& file ) const
 {
diff --git a/src/imaging/ossimImageHandlerFactoryBase.cpp b/src/imaging/ossimImageHandlerFactoryBase.cpp
index 25ff652..b84f750 100644
--- a/src/imaging/ossimImageHandlerFactoryBase.cpp
+++ b/src/imaging/ossimImageHandlerFactoryBase.cpp
@@ -45,6 +45,11 @@ ossimRefPtr<ossimImageHandler> ossimImageHandlerFactoryBase::open(
    return ossimRefPtr<ossimImageHandler>(0);
 }
 
+ossimRefPtr<ossimImageHandler> ossimImageHandlerFactoryBase::open(std::shared_ptr<ossim::ImageHandlerState> state)const
+{
+   return ossimRefPtr<ossimImageHandler>(0);   
+}
+
 ossimRefPtr<ossimImageHandler> ossimImageHandlerFactoryBase::openOverview(
    std::shared_ptr<ossim::istream>& /* str */,
    const ossimString& /* connectionString */ ) const
diff --git a/src/imaging/ossimImageHandlerRegistry.cpp b/src/imaging/ossimImageHandlerRegistry.cpp
index 774ebf0..1f0a3b9 100644
--- a/src/imaging/ossimImageHandlerRegistry.cpp
+++ b/src/imaging/ossimImageHandlerRegistry.cpp
@@ -13,6 +13,8 @@
 
 #include <ossim/imaging/ossimImageHandlerRegistry.h>
 #include <ossim/base/ossimFilename.h>
+#include <ossim/base/ossimTrace.h>
+#include <ossim/base/ossimPreferences.h>
 #include <ossim/base/ossimObjectFactoryRegistry.h>
 #include <ossim/base/ossimStreamFactoryRegistry.h>
 #include <ossim/base/ossimString.h>
@@ -22,6 +24,9 @@
 #include <ossim/imaging/ossimImageHandlerFactoryBase.h>
 #include <algorithm>
 
+static ossimTrace traceDebug("ossimImageHandlerRegistry:debug");
+
+
 RTTI_DEF1(ossimImageHandlerRegistry, "ossimImageHandlerRegistry", ossimObjectFactory);
 
 //ossimImageHandlerRegistry* ossimImageHandlerRegistry::theInstance = 0;
@@ -30,6 +35,7 @@ ossimImageHandlerRegistry::ossimImageHandlerRegistry()
 {
    ossimObjectFactoryRegistry::instance()->registerFactory(this);
    registerFactory(ossimImageHandlerFactory::instance());
+   initializeStateCache();
 }
 
 ossimImageHandlerRegistry* ossimImageHandlerRegistry::instance()
@@ -141,9 +147,33 @@ void ossimImageHandlerRegistry::getSupportedExtensions(
    
 }
 
+
+std::shared_ptr<ossim::ImageHandlerState> ossimImageHandlerRegistry::getState(const ossimString& connectionString, 
+                                                                              ossim_uint32 entry)const
+{
+   return getState(connectionString + "_e" + ossimString::toString(entry));
+}
+
+std::shared_ptr<ossim::ImageHandlerState> ossimImageHandlerRegistry::getState(const ossimString& id)const
+{
+   std::shared_ptr<ossim::ImageHandlerState> result;
+
+   if(m_stateCache)
+   {
+      result = m_stateCache->getItem(id);
+   }
+
+   return result;
+}
+
+
 ossimRefPtr<ossimImageHandler> ossimImageHandlerRegistry::openConnection(
    const ossimString& connectionString, bool openOverview )const
 {
+   if(traceDebug())
+   {
+      ossimNotify(ossimNotifyLevel_DEBUG)<< "ossimImageHandlerRegistry::openConnection: entered.........." << std::endl;
+   }
    ossimRefPtr<ossimImageHandler> result(0);
 
    std::string myConnectionString = connectionString.downcase().string();
@@ -157,7 +187,18 @@ ossimRefPtr<ossimImageHandler> ossimImageHandlerRegistry::openConnection(
    {
       myConnectionString = connectionString.string();
    }
-   
+ 
+   // add entry 0
+   std::shared_ptr<ossim::ImageHandlerState> state = getState(myConnectionString, 0);
+   if(state)
+   {
+      if(traceDebug())
+      {
+         ossimNotify(ossimNotifyLevel_DEBUG)<< "ossimImageHandlerRegistry::openConnection: leaving with open(state).........." << std::endl;;
+      }
+      return open(state);
+   }  
+
    std::shared_ptr<ossim::istream> str = ossim::StreamFactoryRegistry::instance()->
       createIstream( myConnectionString, std::ios_base::in|std::ios_base::binary);
 
@@ -166,27 +207,60 @@ ossimRefPtr<ossimImageHandler> ossimImageHandlerRegistry::openConnection(
       result = open( str, myConnectionString, openOverview );
    }
 
-   if ( result.valid() == false )
+   if ( !result.valid() )
    {
       ossimFilename f = myConnectionString;
       if ( f.exists() )
       {
-         result = this->open( f, true, openOverview );
+         result = open( f, true, openOverview );
       }
    }
+
+   if(result)
+   {
+      addToStateCache(result.get());
+   }
+   if(traceDebug())
+   {
+      ossimNotify(ossimNotifyLevel_DEBUG)<< "ossimImageHandlerRegistry::openConnection: leaving.........." << std::endl;
+   }
    
    return result;
 }
 
-ossimImageHandler* ossimImageHandlerRegistry::open(const ossimFilename& fileName,
+ossimImageHandler* ossimImageHandlerRegistry::open(const ossimFilename& filename,
                                                    bool trySuffixFirst,
                                                    bool openOverview)const
 {
+   if(traceDebug())
+   {
+      ossimNotify(ossimNotifyLevel_DEBUG)<< "ossimImageHandlerRegistry::open(file, trySuffix,openOverview): entered.........." << std::endl;
+   }
+   std::shared_ptr<ossim::ImageHandlerState> state = getState(filename, 0);
+
+   if(state)
+   {
+      ossimRefPtr<ossimImageHandler> h = open(state);
+      if(h)
+      {
+         if(traceDebug())
+         {
+            ossimNotify(ossimNotifyLevel_DEBUG)<< "ossimImageHandlerRegistry::open(file, trySuffix,openOverview): returning with state open.........." << std::endl;;
+         }
+         return h.release();
+      }
+   }
+
    if(trySuffixFirst)
    {
-      ossimRefPtr<ossimImageHandler> h = openBySuffix(fileName, openOverview);
+      ossimRefPtr<ossimImageHandler> h = openBySuffix(filename, openOverview);
       if(h.valid())
       {
+         addToStateCache(h.get());
+         if(traceDebug())
+         {
+            ossimNotify(ossimNotifyLevel_DEBUG)<< "ossimImageHandlerRegistry::open(file, trySuffix,openOverview): leaving.........." << std::endl;
+         }
          return h.release();
       }
    }
@@ -197,10 +271,18 @@ ossimImageHandler* ossimImageHandlerRegistry::open(const ossimFilename& fileName
    vector<ossimImageHandlerFactoryBase*>::const_iterator factory = m_factoryList.begin();
    while((factory != m_factoryList.end()) && !result)
    {
-      result = (*factory)->open(fileName, openOverview);
+      result = (*factory)->open(filename, openOverview);
       ++factory;
    }
-   
+ 
+   if(result)
+   {
+      addToStateCache(result);
+   }  
+   if(traceDebug())
+   {
+      ossimNotify(ossimNotifyLevel_DEBUG)<< "ossimImageHandlerRegistry::open(file, trySuffix,openOverview): leaving.........." << std::endl;
+   }
    return result;
 }
 
@@ -216,6 +298,11 @@ ossimImageHandler* ossimImageHandlerRegistry::open(const ossimKeywordlist& kwl,
       result = (*factory)->open(kwl, prefix);
       ++factory;
    }
+
+   if(result)
+   {
+      addToStateCache(result);
+   }  
    
    return result;
 }
@@ -225,7 +312,26 @@ ossimRefPtr<ossimImageHandler> ossimImageHandlerRegistry::open(
    const std::string& connectionString,
    bool openOverview ) const
 {
+   if(traceDebug())
+   {
+      ossimNotify(ossimNotifyLevel_DEBUG)<< "ossimImageHandlerRegistry::open(stream,connectionString,openOverview): entered.........." << std::endl;
+   }
    ossimRefPtr<ossimImageHandler> result = 0;
+   std::shared_ptr<ossim::ImageHandlerState> state = getState(connectionString, 0);
+   
+   if(state)
+   {
+      result = open(state);
+      if(result)
+      {
+         if(traceDebug())
+         {
+            ossimNotify(ossimNotifyLevel_DEBUG)<< "ossimImageHandlerRegistry::open(stream,connectionString,openOverview): leaving with state open..........Valid? " 
+                                               << result.valid() <<std::endl;
+         }
+         return result;
+      }
+   }
    if ( str )
    {
       vector<ossimImageHandlerFactoryBase*>::const_iterator factory = m_factoryList.begin();
@@ -239,6 +345,39 @@ ossimRefPtr<ossimImageHandler> ossimImageHandlerRegistry::open(
          ++factory;
       }
    }
+   if(result)
+   {
+      addToStateCache(result.get());
+   }  
+   if(traceDebug())
+   {
+      ossimNotify(ossimNotifyLevel_DEBUG)<< "ossimImageHandlerRegistry::open(stream,connectionString,openOverview): leaving..........Valid? " 
+                                         << result.valid()<<std::endl;
+   }
+   return result; 
+}
+
+ossimRefPtr<ossimImageHandler> ossimImageHandlerRegistry::open(std::shared_ptr<ossim::ImageHandlerState> state)const
+{
+   ossimRefPtr<ossimImageHandler> result = 0;
+   vector<ossimImageHandlerFactoryBase*>::const_iterator factory = m_factoryList.begin();
+   if(traceDebug())
+   {
+      ossimNotify(ossimNotifyLevel_DEBUG)<< "ossimImageHandlerRegistry::open(state): Entered......." << std::endl;
+   }
+   while( (!result)&&(factory != m_factoryList.end()) )
+   {
+      result = (*factory)->open( state );
+      if ( result )
+      {
+         break;
+      }
+      ++factory;
+   }
+   if(traceDebug())
+   {
+      ossimNotify(ossimNotifyLevel_DEBUG)<< "ossimImageHandlerRegistry::open(state): Leaving.......valid?" << result.valid()<<std::endl;
+   }
    return result; 
 }
 
@@ -267,38 +406,64 @@ ossimRefPtr<ossimImageHandler> ossimImageHandlerRegistry::openOverview(
 {
    ossimRefPtr<ossimImageHandler> result = 0;
 
-   // See if we can open via the stream interface:
-   std::shared_ptr<ossim::istream> str = ossim::StreamFactoryRegistry::instance()->
-      createIstream( file, std::ios_base::in|std::ios_base::binary);
-   
-   if ( str )
+   if(traceDebug())
    {
-      std::vector<ossimImageHandlerFactoryBase*>::const_iterator factory = m_factoryList.begin();
-      while( factory != m_factoryList.end() )
+      ossimNotify(ossimNotifyLevel_DEBUG)<< "ossimImageHandlerRegistry::openOverview: Entered......." << std::endl;
+   }
+
+   std::shared_ptr<ossim::ImageHandlerState> state = getState(file, 0);
+
+   if(state)
+   {
+      result = open(state);
+
+   }
+
+   if(!result)
+   {
+      // See if we can open via the stream interface:
+      std::shared_ptr<ossim::istream> str = ossim::StreamFactoryRegistry::instance()->
+         createIstream( file, std::ios_base::in|std::ios_base::binary);
+      
+      if ( str )
       {
-         result = (*factory)->openOverview( str, file );
-         if ( result.valid() )
+         std::vector<ossimImageHandlerFactoryBase*>::const_iterator factory = m_factoryList.begin();
+         while( factory != m_factoryList.end() )
          {
-            break;
+            result = (*factory)->openOverview( str, file );
+            if ( result.valid() )
+            {
+               break;
+            }
+            ++factory;
          }
-         ++factory;
-      }
 
-      str = 0;
-   }
+         str = 0;
+      }
 
-   if ( (result.valid() == false) && file.exists() )
-   {  
-      vector<ossimImageHandlerFactoryBase*>::const_iterator factory = m_factoryList.begin();
-      while( factory != m_factoryList.end() )
-      {
-         result = (*factory)->openOverview( file );
-         if ( result.valid() )
+      if ( (result.valid() == false) && file.exists() )
+      {  
+         vector<ossimImageHandlerFactoryBase*>::const_iterator factory = m_factoryList.begin();
+         while( factory != m_factoryList.end() )
          {
-            break;
+            result = (*factory)->openOverview( file );
+            if ( result.valid() )
+            {
+               break;
+            }
+            ++factory;
          }
-         ++factory;
       }
+
+      if(result)
+      {
+         addToStateCache(result.get());
+      }
+   }
+   if(traceDebug())
+   {
+      ossimNotify(ossimNotifyLevel_DEBUG)<< "ossimImageHandlerRegistry::openOverview: Leaving.......Valid? " 
+                                         << result.valid() << std::endl;
    }
    return result;
 }
@@ -378,6 +543,62 @@ ossimImageHandlerRegistry::ossimImageHandlerRegistry(const ossimImageHandlerRegi
    :  ossimObjectFactory()
 {}
 
+void ossimImageHandlerRegistry::initializeStateCache()const
+{
+   m_stateCache = 0;
+   ossimString enabledString = ossimPreferences::instance()->findPreference("ossim.imaging.handler.registry.state_cache.enabled");
+   ossimString minSizeString = ossimPreferences::instance()->findPreference("ossim.imaging.handler.registry.state_cache.min_size");
+   ossimString maxSizeString = ossimPreferences::instance()->findPreference("ossim.imaging.handler.registry.state_cache.max_size");
+
+   ossim_uint32 maxSize = 0;
+   ossim_uint32 minSize = 0;
+
+   if(!enabledString.empty())
+   {
+      if(enabledString.toBool())
+      {
+         m_stateCache = std::make_shared<ossim::ItemCache<ossim::ImageHandlerState> >();
+         if(!maxSizeString.empty())
+         {
+            maxSize = maxSizeString.toUInt32();
+         }
+         if(!minSizeString.empty())
+         {
+            minSize = minSizeString.toUInt32();
+         }
+         else if(maxSize)
+         {
+            minSize = ossim::round<ossim_uint32, ossim_float32>(maxSize*.8);
+         }
+
+         if(minSize < maxSize)
+         {
+            m_stateCache->setMinAndMaxItemsToCache(minSize, maxSize);
+         }
+      }
+
+   }
+}
+
+void ossimImageHandlerRegistry::addToStateCache(ossimImageHandler* handler)const
+{
+   if(handler)
+   {
+      std::shared_ptr<ossim::ImageHandlerState> state = handler->getState();
+      if(state&&m_stateCache)
+      {
+         ossimString id = handler->getFilename()+"_e"+ossimString::toString(state->getCurrentEntry());
+         if(traceDebug())
+         {
+            ossimNotify(ossimNotifyLevel_DEBUG)<< "ossimImageHandlerRegistry::addToStateCache: " << id << std::endl;
+         }
+         m_stateCache->addItem(id, state);
+      }
+   }
+}
+
+
+
 const ossimImageHandlerRegistry&
 ossimImageHandlerRegistry::operator=(const ossimImageHandlerRegistry& rhs)
 { return rhs; }
diff --git a/src/imaging/ossimImageRenderer.cpp b/src/imaging/ossimImageRenderer.cpp
index 7a388b4..92e1fc4 100644
--- a/src/imaging/ossimImageRenderer.cpp
+++ b/src/imaging/ossimImageRenderer.cpp
@@ -277,90 +277,92 @@ void ossimImageRenderer::ossimRendererSubRectInfo::splitAll(std::vector<ossimRen
 
 void ossimImageRenderer::ossimRendererSubRectInfo::splitView(std::vector<ossimRendererSubRectInfo>& result)const
 {
-  ossim_uint16 splitFlags = getSplitFlags();
-  // just do horizontal split for test
-
-  ossimIrect vrect(m_Vul,
-                  m_Vur,
-                  m_Vlr,
-                  m_Vll);
-  ossim_int32 w  = vrect.width();
-  ossim_int32 h  = vrect.height();
-  ossim_int32 w2 = w>>1;
-  ossim_int32 h2 = h>>1;
-  if(!splitFlags)
-  {
-    return;
-  }
-  else if((w2 <2)&&(h2<2))
-  {
-    if(splitFlags)
-    {
-      ossimRendererSubRectInfo rect(m_transform.get(),m_Vul, 
-                              m_Vul, 
-                              m_Vul, 
-                              m_Vul);
-      rect.m_viewBounds = m_viewBounds;
-      rect.transformViewToImage();
-
-      if(rect.imageHasNans())
+   ossim_uint16 splitFlags = getSplitFlags();
+   if(!splitFlags)
+   {
+      return;
+   } 
+  
+   // just do horizontal split for test
+   ossimIrect vrect(m_Vul,
+                    m_Vur,
+                    m_Vlr,
+                    m_Vll);
+   ossim_int32 w  = vrect.width();
+   ossim_int32 h  = vrect.height();
+   ossim_int32 w2 = w>>1;
+   ossim_int32 h2 = h>>1;
+   
+   if((w2 <2)&&(h2<2))
+   {
+      if(splitFlags)
       {
-        if(rect.m_viewBounds->intersects(rect.getViewRect()))
-        {
-          result.push_back(rect);
-        }
+         ossimRendererSubRectInfo rect(m_transform.get(),m_Vul, 
+                                       m_Vul, 
+                                       m_Vul, 
+                                       m_Vul);
+         rect.m_viewBounds = m_viewBounds;
+         rect.transformViewToImage();
+
+         if(rect.imageHasNans())
+         {
+            if(rect.m_viewBounds->intersects(rect.getViewRect()))
+            {
+               result.push_back(rect);
+            }
+         }
+         // if(rect.imageIsNan())
+         // {
+         //   if(rect.m_viewBounds->intersects(rect.getViewRect()))
+         //   {
+         //     result.push_back(rect);
+         //   }
+         // }
+         // else
+         // {
+         //   result.push_back(rect);
+         // }
       }
-      // if(rect.imageIsNan())
-      // {
-      //   if(rect.m_viewBounds->intersects(rect.getViewRect()))
-      //   {
-      //     result.push_back(rect);
-      //   }
-      // }
-      // else
-      // {
-      //   result.push_back(rect);
-      // }
-    }
-  }
-  // horizontal split if only the upper left and lower left 
-  // vertices need splitting 
-  else if((splitFlags==(UPPER_LEFT_SPLIT_FLAG|LOWER_LEFT_SPLIT_FLAG))||
-          (splitFlags==(UPPER_RIGHT_SPLIT_FLAG|LOWER_RIGHT_SPLIT_FLAG)))
-  {
-   // std::cout << "Horizontal Split\n" << std::endl;    
-    if(w > 1)
-    {
-      splitHorizontal(result);
-    }
-  }  
-  // check vertical only split
-  else if((splitFlags==(UPPER_LEFT_SPLIT_FLAG|UPPER_RIGHT_SPLIT_FLAG))||
-          (splitFlags==(LOWER_RIGHT_SPLIT_FLAG|LOWER_LEFT_SPLIT_FLAG)))
-  {
-    //std::cout << "Vertical Split\n" << std::endl;
+   }
+   // horizontal split if only the upper left and lower left 
+   // vertices need splitting 
+   else if((splitFlags==(UPPER_LEFT_SPLIT_FLAG|LOWER_LEFT_SPLIT_FLAG))||
+           (splitFlags==(UPPER_RIGHT_SPLIT_FLAG|LOWER_RIGHT_SPLIT_FLAG)))
+   {
+      // std::cout << "Horizontal Split\n" << std::endl;    
+      if(w > 1)
+      {
+         splitHorizontal(result);
+      }
+   }  
+   // check vertical only split
+   else if((splitFlags==(UPPER_LEFT_SPLIT_FLAG|UPPER_RIGHT_SPLIT_FLAG))||
+           (splitFlags==(LOWER_RIGHT_SPLIT_FLAG|LOWER_LEFT_SPLIT_FLAG)))
+   {
+      //std::cout << "Vertical Split\n" << std::endl;
 
-    if(h>1)
-    {
-      splitVertical(result);
-    }
-  }
-  else//if((w>1)&&(h>1)&&(splitFlags))
-  {
-    if((w<2)&&(h>1))
-    {
-      splitVertical(result);
-    }
-    else if((w>1)&&(h<2))
-    {
-      splitHorizontal(result);
-    }
-    else
-    {
-      splitAll(result);
-    }
-  }
+      if(h>1)
+      {
+         splitVertical(result);
+      }
+   }
+   else//if((w>1)&&(h>1)&&(splitFlags))
+   {
+      if((w<2)&&(h>1))
+      {
+         splitVertical(result);
+      }
+      else if((w>1)&&(h<2))
+      {
+         splitHorizontal(result);
+      }
+      else
+      {
+         splitAll(result);
+      }
+   }
 }
+
 void ossimImageRenderer::ossimRendererSubRectInfo::transformImageToView()
 {
    ossimDpt vul;
@@ -391,87 +393,97 @@ bool ossimImageRenderer::ossimRendererSubRectInfo::tooBig()const
 
 ossim_uint16 ossimImageRenderer::ossimRendererSubRectInfo::getSplitFlags()const
 {
-  ossim_uint16 result = SPLIT_NONE;
-  ossimDrect vRect = getViewRect();
+   ossim_uint16 result = SPLIT_NONE;
+   ossimDrect vRect = getViewRect();
 
-  if(imageHasNans())
-  {
-    if(m_viewBounds->intersects(getViewRect()))
-    {
-      result = SPLIT_ALL;
-    }
-    else
-    {
+   //---
+   // Don't allow splits beyond 8x8 pixel. ossim2dBilinearTransform was core dumping with
+   // very small rectangles in canBilinearInterpolate(...) method.
+   // DRB 05 Dec. 2017
+   //---
+   if ( vRect.width() < 8 && vRect.height() < 8 )
+   {
       return result;
-    }
-  }
-  /*
-  if(result != SPLIT_ALL)
-  {
-    if(m_ulRoundTripError.hasNans()&&m_urRoundTripError.hasNans()&&
-        m_lrRoundTripError.hasNans()&&m_llRoundTripError.hasNans())
-    {
-      if(m_viewBounds->intersects(getViewRect()))
+   }
+  
+   if(imageHasNans())
+   {
+      if(m_viewBounds->intersects(vRect))
       {
-        result = SPLIT_ALL;
+         result = SPLIT_ALL;
       }
-      return result;
-    }
-    else if(tooBig())
-    {
-      result = SPLIT_ALL;
-    }
-  }
+      else
+      {
+         return result;
+      }
+   }
+   /*
+     if(result != SPLIT_ALL)
+     {
+     if(m_ulRoundTripError.hasNans()&&m_urRoundTripError.hasNans()&&
+     m_lrRoundTripError.hasNans()&&m_llRoundTripError.hasNans())
+     {
+     if(m_viewBounds->intersects(getViewRect()))
+     {
+     result = SPLIT_ALL;
+     }
+     return result;
+     }
+     else if(tooBig())
+     {
+     result = SPLIT_ALL;
+     }
+     }
 
-  if(result != SPLIT_ALL)
-  {
-    if(m_ulRoundTripError.hasNans()) result |= UPPER_LEFT_SPLIT_FLAG;
-    if(m_urRoundTripError.hasNans()) result |= UPPER_RIGHT_SPLIT_FLAG;
-    if(m_lrRoundTripError.hasNans()) result |= LOWER_RIGHT_SPLIT_FLAG;
-    if(m_llRoundTripError.hasNans()) result |= LOWER_LEFT_SPLIT_FLAG;
-  }
-*/
-  if(result != SPLIT_ALL)
-  {
-    ossim_float64 bias = m_ImageToViewScale.length();
-    if(bias < 1.0) bias = 1.0/bias;
-    bias = std::sqrt(bias);
-
-    if(bias < 1) bias = 1.0;
-
-     // if((m_ulRoundTripError.length() > bias)||
-     //    (m_urRoundTripError.length() > bias)||
-     //    (m_lrRoundTripError.length() > bias)||
-     //    (m_llRoundTripError.length() > bias))
-     // {
-       // std::cout << "________________\n";
-
-       // std::cout << "Bias:  " << bias << "\n"
-       //           << "View:  " << getViewRect() << "\n"
-       //           << "UL:    " << m_ulRoundTripError.length() << "\n"
-       //           << "UR:   " << m_urRoundTripError.length() << "\n"
-       //           << "LR:   " << m_lrRoundTripError.length() << "\n"
-       //           << "LL:   " << m_llRoundTripError.length() << "\n";
+     if(result != SPLIT_ALL)
+     {
+     if(m_ulRoundTripError.hasNans()) result |= UPPER_LEFT_SPLIT_FLAG;
+     if(m_urRoundTripError.hasNans()) result |= UPPER_RIGHT_SPLIT_FLAG;
+     if(m_lrRoundTripError.hasNans()) result |= LOWER_RIGHT_SPLIT_FLAG;
+     if(m_llRoundTripError.hasNans()) result |= LOWER_LEFT_SPLIT_FLAG;
+     }
+   */
+   if(result != SPLIT_ALL)
+   {
+      ossim_float64 bias = m_ImageToViewScale.length();
+      if(bias < 1.0) bias = 1.0/bias;
+      bias = std::sqrt(bias);
+
+      if(bias < 1) bias = 1.0;
+
+      // if((m_ulRoundTripError.length() > bias)||
+      //    (m_urRoundTripError.length() > bias)||
+      //    (m_lrRoundTripError.length() > bias)||
+      //    (m_llRoundTripError.length() > bias))
+      // {
+      // std::cout << "________________\n";
+
+      // std::cout << "Bias:  " << bias << "\n"
+      //           << "View:  " << getViewRect() << "\n"
+      //           << "UL:    " << m_ulRoundTripError.length() << "\n"
+      //           << "UR:   " << m_urRoundTripError.length() << "\n"
+      //           << "LR:   " << m_lrRoundTripError.length() << "\n"
+      //           << "LL:   " << m_llRoundTripError.length() << "\n";
 //     }
-   // if(m_ulRoundTripError.length() > sensitivityScale) result |= UPPER_LEFT_SPLIT_FLAG;
-   // if(m_urRoundTripError.length() > sensitivityScale) result |= UPPER_RIGHT_SPLIT_FLAG;
-   // if(m_lrRoundTripError.length() > sensitivityScale) result |= LOWER_RIGHT_SPLIT_FLAG;
-   // if(m_llRoundTripError.length() > sensitivityScale) result |= LOWER_LEFT_SPLIT_FLAG;
-       // std::cout << result << " == " << SPLIT_ALL << "\n";
+      // if(m_ulRoundTripError.length() > sensitivityScale) result |= UPPER_LEFT_SPLIT_FLAG;
+      // if(m_urRoundTripError.length() > sensitivityScale) result |= UPPER_RIGHT_SPLIT_FLAG;
+      // if(m_lrRoundTripError.length() > sensitivityScale) result |= LOWER_RIGHT_SPLIT_FLAG;
+      // if(m_llRoundTripError.length() > sensitivityScale) result |= LOWER_LEFT_SPLIT_FLAG;
+      // std::cout << result << " == " << SPLIT_ALL << "\n";
 
-    if((result!=SPLIT_ALL)&&!canBilinearInterpolate(bias))
-    {
-      // std::cout << "TESTING BILINEAR!!!!\n";
-      result = SPLIT_ALL;
+      if((result!=SPLIT_ALL)&&!canBilinearInterpolate(bias))
+      {
+         // std::cout << "TESTING BILINEAR!!!!\n";
+         result = SPLIT_ALL;
 
-    }
-    else
-    {
-      // std::cout << "CAN BILINEAR!!!!\n";
-    }
-  }
+      }
+      else
+      {
+         // std::cout << "CAN BILINEAR!!!!\n";
+      }
+   }
 
-  return result;
+   return result;
 }
 
 void ossimImageRenderer::ossimRendererSubRectInfo::transformViewToImage()
@@ -796,14 +808,12 @@ bool ossimImageRenderer::ossimRendererSubRectInfo::canBilinearInterpolate(double
     
     // get the model centers for the mid upper left right bottom
     m_transform->viewToImage(vCenter, testCenter);
-
     if(testCenter.hasNans())
     {
        return false;
     }
-
     m_transform->viewToImage(vUpper, testUpper);
-    if(testCenter.hasNans())
+    if(testUpper.hasNans())
     {
        return false;
     }
diff --git a/src/imaging/ossimJpegCodec.cpp b/src/imaging/ossimJpegCodec.cpp
index edf1f47..79568ba 100644
--- a/src/imaging/ossimJpegCodec.cpp
+++ b/src/imaging/ossimJpegCodec.cpp
@@ -1,13 +1,12 @@
-//----------------------------------------------------------------------------
+//---
 //
-// License:  LGPL
+// License: MIT
 // 
-// See LICENSE.txt file in the top level directory for more details.
-//
 // Description: class declaration for base codec(encoder/decoder).
 // 
-//----------------------------------------------------------------------------
+//---
 // $Id$
+
 #include <ossim/imaging/ossimJpegCodec.h>
 
 // we need to get rid of the jpedlib include in this header
@@ -22,8 +21,6 @@
 #include <csetjmp>     /** for jmp_buf */
 #include <jpeglib.h>   /** for jpeg stuff */
 
-RTTI_DEF1(ossimJpegCodec, "ossimJpegCodec", ossimCodecBase);
-
 /** @brief Extended error handler struct. */
 struct ossimJpegErrorMgr
 {
@@ -46,7 +43,8 @@ void ossimJpegErrorExit (jpeg_common_struct* cinfo)
 }
 
 ossimJpegCodec::ossimJpegCodec()
-:m_quality(100)
+   :m_quality(100),
+    m_ext("jpg")
 {
 }
 
@@ -56,7 +54,12 @@ ossimJpegCodec::~ossimJpegCodec()
 
 ossimString ossimJpegCodec::getCodecType()const
 {
-	return ossimString("jpeg");
+   return ossimString("jpeg");
+}
+
+const std::string& ossimJpegCodec::getExtension() const
+{
+   return m_ext; // "jpg"
 }
 
 bool ossimJpegCodec::encode( const ossimRefPtr<ossimImageData>& in,
@@ -491,13 +494,13 @@ void ossimJpegCodec::setProperty(ossimRefPtr<ossimProperty> property)
 ossimRefPtr<ossimProperty> ossimJpegCodec::getProperty(const ossimString& name)const
 {
    ossimRefPtr<ossimProperty> result;
-
+   
    if(name == ossimKeywordNames::QUALITY_KW)
    {
       result = new ossimNumericProperty(ossimKeywordNames::QUALITY_KW,
-                           ossimString::toString(m_quality),
-                           0,
-                           100);
+                                        ossimString::toString(m_quality),
+                                        0,
+                                        100);
    }
    else
    {
@@ -505,6 +508,7 @@ ossimRefPtr<ossimProperty> ossimJpegCodec::getProperty(const ossimString& name)c
    }
    return result;
 }
+
 void ossimJpegCodec::getPropertyNames(std::vector<ossimString>& propertyNames)const
 {
    ossimCodecBase::getPropertyNames(propertyNames);
@@ -513,20 +517,19 @@ void ossimJpegCodec::getPropertyNames(std::vector<ossimString>& propertyNames)co
 
 bool ossimJpegCodec::loadState(const ossimKeywordlist& kwl, const char* prefix)
 {
-	const char* quality = kwl.find(prefix, ossimKeywordNames::QUALITY_KW);
-
-	if(quality)
-	{
-		m_quality = ossimString(quality).toUInt32();
-	}
-
-	return ossimCodecBase::loadState(kwl, prefix);
+   const char* quality = kwl.find(prefix, ossimKeywordNames::QUALITY_KW);
+   
+   if(quality)
+   {
+      m_quality = ossimString(quality).toUInt32();
+   }
+   
+   return ossimCodecBase::loadState(kwl, prefix);
 }
 
 bool ossimJpegCodec::saveState(ossimKeywordlist& kwl, const char* prefix)const
 {
-	kwl.add(prefix, ossimKeywordNames::QUALITY_KW, m_quality);
-
-	return ossimCodecBase::saveState(kwl, prefix);
+   kwl.add(prefix, ossimKeywordNames::QUALITY_KW, m_quality);
+   
+   return ossimCodecBase::saveState(kwl, prefix);
 }
-
diff --git a/src/imaging/ossimNitfTileSource.cpp b/src/imaging/ossimNitfTileSource.cpp
index 1646b0b..6c91985 100644
--- a/src/imaging/ossimNitfTileSource.cpp
+++ b/src/imaging/ossimNitfTileSource.cpp
@@ -263,23 +263,29 @@ bool ossimNitfTileSource::open( std::shared_ptr<ossim::istream>& str,
          if(hdr->isValid())
          {
             if( !hdr->isCompressed() )
-            {
-               // Skip entries tagged NODISPLAY, e.g. cloud mask entries.
-               if (hdr->getRepresentation() != "NODISPLY")
                {
+               // GP:  I will remove the NODISPLY check for if there is 
+               //      any kind of data OSSIM should allow it through.  
+               //      filterting for this data should be at a higher level.
+               //      SICD data is labeled as NODISPLY but we need to process
+               //      it in order for it to be used in other algorithms
+
+               // Skip entries tagged NODISPLAY, e.g. cloud mask entries.
+               // if (hdr->getRepresentation() != "NODISPLY")
+               // {
                   theEntryList.push_back(i);
                   theNitfImageHeader.push_back(hdr);
-               }
-               else 
-               {
-                  ossimString cat = hdr->getCategory().trim().downcase();
-                  // this is an NGA Highr Resoluion Digital Terrain Model NITF format
-                  if(cat == "dtem")
-                  {
-                     theEntryList.push_back(i);
-                     theNitfImageHeader.push_back(hdr);
-                  }
-               }
+               // }
+               // else 
+               // {
+               //    ossimString cat = hdr->getCategory().trim().downcase();
+               //    // this is an NGA Highr Resoluion Digital Terrain Model NITF format
+               //    if(cat == "dtem")
+               //    {
+               //       theEntryList.push_back(i);
+               //       theNitfImageHeader.push_back(hdr);
+               //    }
+               // }
 
             }
             else if ( canUncompress(hdr.get()) )
@@ -290,6 +296,7 @@ bool ossimNitfTileSource::open( std::shared_ptr<ossim::istream>& str,
             }
             else
             {
+               //std::cout << "COMPRESSION CODE: "<< hdr->getCompressionCode() << "\n";
                if(traceDebug())
                {
                   ossimNotify(ossimNotifyLevel_DEBUG)
@@ -297,11 +304,14 @@ bool ossimNitfTileSource::open( std::shared_ptr<ossim::istream>& str,
                      <<" has an unsupported compression code = "
                      << hdr->getCompressionCode() << std::endl;
                }
+               theNitfImageHeader.clear();
+               theEntryList.clear();
+               // break out
+               break;
             }
          }   
          
       } // End: image header loop
-
       // Reset the number of images in case we skipped some, e.g. tagged "NODISPLAY"
       if ( theNitfImageHeader.size() )
       {
@@ -346,7 +356,6 @@ bool ossimNitfTileSource::open( std::shared_ptr<ossim::istream>& str,
       ossimNotify(ossimNotifyLevel_DEBUG)
          << MODULE << " exit status: " << (result?"true":"false") << "\n";
    }
-   
    return result;
 }
 
@@ -445,22 +454,28 @@ bool ossimNitfTileSource::parseFile()
       {
          if( !hdr->isCompressed() )
          {
+            // GP:  I will remove the NODISPLYU check for if there is 
+            //      any kind of data OSSIM should allow it through.  
+            //      filterting for this data should be at a higher level.
+            //      SICD data is labeled as NODISPLY but we need to process
+            //      it in order for it to be used in other algorithms
+            //
             // Skip entries tagged NODISPLAY, e.g. cloud mask entries.
-            if (hdr->getRepresentation() != "NODISPLY")
-            {
+            // if (hdr->getRepresentation() != "NODISPLY")
+            // {
                theEntryList.push_back(i);
                theNitfImageHeader.push_back(hdr);
-            }
-            else 
-            {
-               ossimString cat = hdr->getCategory().trim().downcase();
-               // this is an NGA Highr Resoluion Digital Terrain Model NITF format
-               if(cat == "dtem")
-               {
-                  theEntryList.push_back(i);
-                  theNitfImageHeader.push_back(hdr);
-               }
-            }
+            // }
+            // else 
+            // {
+            //    ossimString cat = hdr->getCategory().trim().downcase();
+            //    // this is an NGA Highr Resoluion Digital Terrain Model NITF format
+            //    if(cat == "dtem")
+            //    {
+            //       theEntryList.push_back(i);
+            //       theNitfImageHeader.push_back(hdr);
+            //    }
+            // }
 
          }
          else if ( canUncompress(hdr.get()) )
@@ -471,6 +486,8 @@ bool ossimNitfTileSource::parseFile()
          }
          else
          {
+            theEntryList.clear();
+            theNitfImageHeader.clear();
             if(traceDebug())
             {
                ossimNotify(ossimNotifyLevel_DEBUG)
@@ -478,7 +495,7 @@ bool ossimNitfTileSource::parseFile()
                   <<" has an unsupported compression code = "
                   << hdr->getCompressionCode() << std::endl;
             }
-            return false;
+            break;
          }
       }
       else
@@ -2343,12 +2360,21 @@ ossimScalarType ossimNitfTileSource::getOutputScalarType() const
 ossim_uint32 ossimNitfTileSource::getTileWidth() const
 {
    ossim_uint32 result = 0;
+   bool needDefault = false;
    if(!theCacheSize.hasNans()&& theCacheSize.x > 0)
    {
       result = theCacheSize.x;
+      if(result >= getBoundingRect().width())
+      {
+         needDefault = true;
+      }
    }
    else
    {
+      needDefault = true;
+   }
+   if(needDefault)
+   {
       ossimIpt tileSize;
       ossim::defaultTileSize(tileSize);
       result = static_cast<ossim_uint32>(tileSize.x);
@@ -2359,12 +2385,21 @@ ossim_uint32 ossimNitfTileSource::getTileWidth() const
 ossim_uint32 ossimNitfTileSource::getTileHeight() const
 {
    ossim_uint32 result = 0;
+   bool needDefault = false;
    if(!theCacheSize.hasNans()&& theCacheSize.y > 0)
    {
       result = theCacheSize.y;
+      if(result >= getBoundingRect().height())
+      {
+         needDefault = true;
+      }
    }
    else
    {
+      needDefault = true;
+   }
+   if(needDefault)
+   {
       ossimIpt tileSize;
       ossim::defaultTileSize(tileSize);
       result = static_cast<ossim_uint32>(tileSize.y);
@@ -2520,21 +2555,28 @@ bool ossimNitfTileSource::isVqCompressed(const ossimString& compressionCode)cons
 ossim_uint32 ossimNitfTileSource::getImageTileWidth() const
 {
    const ossimNitfImageHeader* hdr = getCurrentImageHeader();
+   ossim_uint32 tileSize = 0;
    if (!hdr)
    {
-      return 0;
+      return tileSize;
    }
-   return hdr->getNumberOfPixelsPerBlockHoriz();
+   tileSize = hdr->getNumberOfPixelsPerBlockHoriz();
+
+   if(tileSize >= getBoundingRect().width()) tileSize = 0;
+   return tileSize;
 }
 
 ossim_uint32 ossimNitfTileSource::getImageTileHeight() const
 {
    const ossimNitfImageHeader* hdr = getCurrentImageHeader();
+   ossim_uint32 tileSize = 0;
    if (!hdr)
    {
-      return 0;
+      return tileSize;
    }
-   return hdr->getNumberOfPixelsPerBlockVert();
+   tileSize = hdr->getNumberOfPixelsPerBlockVert();
+   if(tileSize >= getBoundingRect().height()) tileSize = 0;
+   return tileSize;
 }
 
 ossimString ossimNitfTileSource::getShortName()const
diff --git a/src/imaging/ossimNitfWriterBase.cpp b/src/imaging/ossimNitfWriterBase.cpp
index e6dc9e9..9bc1904 100644
--- a/src/imaging/ossimNitfWriterBase.cpp
+++ b/src/imaging/ossimNitfWriterBase.cpp
@@ -1,16 +1,9 @@
-//----------------------------------------------------------------------------
+//**************************************************************************************************
 //
-// License:  LGPL
-// 
-// See LICENSE.txt file in the top level directory for more details.
+//     OSSIM Open Source Geospatial Data Processing Library
+//     See top level LICENSE.txt file for license information
 //
-// Author:  David Burken
-//
-// Description: OSSIM Kakadu based nitf writer.
-//
-//----------------------------------------------------------------------------
-// $Id: ossimNitfWriterBase.cpp 2981 2011-10-10 21:14:02Z david.burken $
-
+//**************************************************************************************************
 #include <ossim/imaging/ossimNitfWriterBase.h>
 #include <ossim/base/ossimBooleanProperty.h>
 #include <ossim/base/ossimFilename.h>
diff --git a/src/imaging/ossimNullPixelFlip.cpp b/src/imaging/ossimNullPixelFlip.cpp
index 15ff009..3f968ac 100644
--- a/src/imaging/ossimNullPixelFlip.cpp
+++ b/src/imaging/ossimNullPixelFlip.cpp
@@ -14,9 +14,10 @@
 #include <ossim/imaging/ossimImageData.h>
 
 RTTI_DEF1(ossimNullPixelFlip, "ossimNullPixelFlip", ossimImageSourceFilter);
-ossimNullPixelFlip::ossimNullPixelFlip()
-:m_clipMode(ClipMode_BOUNDING_RECT),
-m_replacementType(ReplacementType_MINPIX)
+ossimNullPixelFlip::ossimNullPixelFlip(ClipMode clipMode, 
+                                       ReplacementType replacementType)
+:m_clipMode(clipMode),
+m_replacementType(replacementType)
 {
 }
 
diff --git a/src/imaging/ossimOverviewSequencer.cpp b/src/imaging/ossimOverviewSequencer.cpp
index 6a54e24..168f9fd 100644
--- a/src/imaging/ossimOverviewSequencer.cpp
+++ b/src/imaging/ossimOverviewSequencer.cpp
@@ -18,7 +18,7 @@
 #include <ossim/imaging/ossimImageData.h>
 #include <ossim/imaging/ossimImageDataFactory.h>
 #include <ossim/imaging/ossimImageHandler.h>
-#include <ossim/imaging/ossimImageMetaData.h>
+#include <ossim/support_data/ossimImageMetaData.h>
 #include <ossim/parallel/ossimMpi.h>
 
 
diff --git a/src/imaging/ossimPixelFlipper.cpp b/src/imaging/ossimPixelFlipper.cpp
index f651d79..46d738a 100644
--- a/src/imaging/ossimPixelFlipper.cpp
+++ b/src/imaging/ossimPixelFlipper.cpp
@@ -19,7 +19,6 @@
 #include <ossim/base/ossimNumericProperty.h>
 #include <ossim/base/ossimKeywordNames.h>
 #include <ossim/imaging/ossimImageData.h>
-#include <OpenThreads/ScopedLock>
 #include <cstdlib>
 
 RTTI_DEF1(ossimPixelFlipper, "ossimPixelFlipper", ossimImageSourceFilter)
@@ -89,7 +88,7 @@ ossimRefPtr<ossimImageData> ossimPixelFlipper::getTile(
    if (!inputTile->getBuf()) return inputTile;
    
    // Lock for the length of this method.
-	OpenThreads::ScopedLock<OpenThreads::Mutex> scopeLock(theMutex);
+	std::lock_guard<std::recursive_mutex> scopeLock(theMutex);
    
    // Call the appropriate load method.
    switch (inputTile->getScalarType())
@@ -569,7 +568,7 @@ void ossimPixelFlipper::allocateClipTileBuffer(ossimRefPtr<ossimImageData> input
 
 void ossimPixelFlipper::initialize()
 {
-	OpenThreads::ScopedLock<OpenThreads::Mutex> scopeLock(theMutex);
+	std::lock_guard<std::recursive_mutex> scopeLock(theMutex);
    ossimImageSourceFilter::initialize();
    theValidVertices.clear();
    theBoundingRects.clear();
@@ -783,7 +782,7 @@ void ossimPixelFlipper::setTargetValue(ossim_float64 target_value)
    // won't affect the output null, min and max ranges.  This will fix a
    // tiled nitf with max of 2047(11bit) with edge tile fill values of 2048.
    //---
-   OpenThreads::ScopedLock<OpenThreads::Mutex> scopeLock(theMutex);
+   std::lock_guard<std::recursive_mutex> scopeLock(theMutex);
 
    theTargetValueLo = target_value;
    theTargetValueHi = target_value; 
@@ -796,7 +795,7 @@ void ossimPixelFlipper::setTargetRange(ossim_float64 target_min, ossim_float64 t
    // won't affect the output null, min and max ranges.  This will fix a
    // tiled nitf with max of 2047(11bit) with edge tile fill values of 2048.
    //---
-   OpenThreads::ScopedLock<OpenThreads::Mutex> scopeLock(theMutex);
+   std::lock_guard<std::recursive_mutex> scopeLock(theMutex);
 
    theTargetValueLo = target_min;
    theTargetValueHi = target_max; 
@@ -804,7 +803,7 @@ void ossimPixelFlipper::setTargetRange(ossim_float64 target_min, ossim_float64 t
 
 void ossimPixelFlipper::setReplacementValue(ossim_float64 replacement_value)
 {
-	OpenThreads::ScopedLock<OpenThreads::Mutex> scopeLock(theMutex);
+	std::lock_guard<std::recursive_mutex> scopeLock(theMutex);
 
    // Range check to ensure within null, min and max of output radiometry.
    if (inRange(replacement_value))
@@ -815,7 +814,7 @@ void ossimPixelFlipper::setReplacementValue(ossim_float64 replacement_value)
 
 void ossimPixelFlipper::setClampValue(ossim_float64 clamp_value, bool clamp_max_value)
 {
-   OpenThreads::ScopedLock<OpenThreads::Mutex> scopeLock(theMutex);
+   std::lock_guard<std::recursive_mutex> scopeLock(theMutex);
 
    if (inRange(clamp_value))
    {
@@ -844,13 +843,13 @@ void ossimPixelFlipper::setClampValues(ossim_float64 clamp_value_lo, ossim_float
 
 void ossimPixelFlipper::setReplacementMode(ossimPixelFlipper::ReplacementMode mode)
 {
-	OpenThreads::ScopedLock<OpenThreads::Mutex> scopeLock(theMutex);
+	std::lock_guard<std::recursive_mutex> scopeLock(theMutex);
    theReplacementMode = mode;
 }
 
 bool ossimPixelFlipper::setReplacementMode(const ossimString& modeString)
 {
-	OpenThreads::ScopedLock<OpenThreads::Mutex> scopeLock(theMutex);
+	std::lock_guard<std::recursive_mutex> scopeLock(theMutex);
 
    ossimString mode = modeString;
    mode.upcase();
@@ -887,7 +886,7 @@ bool ossimPixelFlipper::setReplacementMode(const ossimString& modeString)
 
 void ossimPixelFlipper::setClipMode(ossimPixelFlipper::ClipMode mode)
 {
-	OpenThreads::ScopedLock<OpenThreads::Mutex> scopeLock(theMutex);
+	std::lock_guard<std::recursive_mutex> scopeLock(theMutex);
    theClipMode = mode;
 }
 
@@ -986,7 +985,7 @@ ossimRefPtr<ossimProperty> ossimPixelFlipper::getProperty(
    const ossimString& name)const
 {
    // Lock for the length of this method.
-	OpenThreads::ScopedLock<OpenThreads::Mutex> scopeLock(theMutex);
+	std::lock_guard<std::recursive_mutex> scopeLock(theMutex);
 
    if (name == PF_TARGET_VALUE_KW)
    {
diff --git a/src/imaging/ossimSingleImageChain.cpp b/src/imaging/ossimSingleImageChain.cpp
index 5c840f1..261ddff 100644
--- a/src/imaging/ossimSingleImageChain.cpp
+++ b/src/imaging/ossimSingleImageChain.cpp
@@ -31,6 +31,7 @@ ossimSingleImageChain::ossimSingleImageChain()
    m_resamplerCache(0),
    m_resampler(0),
    m_chainCache(0),
+   m_addNullPixelFlipFlag(false),
    m_addHistogramFlag(false),
    m_addResamplerCacheFlag(false),
    m_addChainCacheFlag(false),
@@ -43,7 +44,8 @@ ossimSingleImageChain::ossimSingleImageChain()
 {
 }
 
-ossimSingleImageChain::ossimSingleImageChain(bool addHistogramFlag,
+ossimSingleImageChain::ossimSingleImageChain(bool addNullPixelFlipFlag,
+                                             bool addHistogramFlag,
                                              bool addResamplerCacheFlag,
                                              bool addChainCacheFlag,
                                              bool remapToEightBitFlag,
@@ -63,6 +65,7 @@ ossimSingleImageChain::ossimSingleImageChain(bool addHistogramFlag,
    m_resamplerCache(0),
    m_resampler(0),
    m_chainCache(0),
+   m_addNullPixelFlipFlag(addNullPixelFlipFlag),
    m_addHistogramFlag(addHistogramFlag),
    m_addResamplerCacheFlag(addResamplerCacheFlag),
    m_addChainCacheFlag(addChainCacheFlag),
@@ -78,6 +81,7 @@ ossimSingleImageChain::ossimSingleImageChain(bool addHistogramFlag,
 ossimSingleImageChain::~ossimSingleImageChain()
 {
    m_handler            = 0;
+   m_nullPixelFlip      = 0;
    m_bandSelector       = 0;
    m_histogramRemapper  = 0;
    m_brightnessContrast = 0;
@@ -100,6 +104,7 @@ void ossimSingleImageChain::reset()
 
    m_handler                = 0;
    m_bandSelector           = 0;
+   m_nullPixelFlip          = 0;
    m_histogramRemapper      = 0;
    m_brightnessContrast     = 0;
    m_sharpen                = 0;
@@ -110,6 +115,7 @@ void ossimSingleImageChain::reset()
    m_chainCache             = 0;
 
    m_addHistogramFlag       = false;
+   m_addNullPixelFlipFlag   = false;
    m_addResamplerCacheFlag  = false;
    m_addChainCacheFlag      = false;
    m_remapToEightBitFlag    = false;
@@ -175,7 +181,6 @@ void ossimSingleImageChain::createRenderedChain()
    {
       addBandSelector();
    }
-   
    // histogram:
    if ( m_addHistogramFlag )
    {
@@ -212,6 +217,13 @@ void ossimSingleImageChain::createRenderedChain()
       }
    }
 
+   // cheaper operation to put the flip after the remapper
+   //
+   if(m_addNullPixelFlipFlag)
+   {
+      addNullPixelFlip();
+   }
+
    // resampler cache
    if ( m_addResamplerCacheFlag )
    {
@@ -316,6 +328,10 @@ void ossimSingleImageChain::createRenderedChain(const ossimSrcRecord& src)
       addBandSelector(src);
    }
    
+   if(m_addNullPixelFlipFlag)
+   {
+      addNullPixelFlip();
+   }
    // histogram
    if ( m_addHistogramFlag || src.getHistogramOp().size() )
    {
@@ -513,6 +529,23 @@ void ossimSingleImageChain::addBandSelector(const ossimSrcRecord& src)
    }
 }
 
+void ossimSingleImageChain::addNullPixelFlip()
+{
+   if(!m_nullPixelFlip)
+   {
+      m_nullPixelFlip = new ossimNullPixelFlip();
+      addFirst(m_nullPixelFlip.get());
+   }
+}
+void ossimSingleImageChain::addNullPixelFlip(const ossimSrcRecord& src)
+{
+   if(!m_nullPixelFlip)
+   {
+      m_nullPixelFlip = new ossimNullPixelFlip();
+      addFirst(m_nullPixelFlip.get());
+   }
+}
+
 void ossimSingleImageChain::addHistogramRemapper()
 {
    if (!m_histogramRemapper)
@@ -732,6 +765,12 @@ ossimRefPtr<const ossimBandSelector> ossimSingleImageChain::getBandSelector() co
    return ossimRefPtr<const ossimBandSelector>( m_bandSelector.get() );
 }
 
+ossimRefPtr<const ossimNullPixelFlip> ossimSingleImageChain::getNullPixelFlip() const
+{
+   return ossimRefPtr<const ossimNullPixelFlip>( m_nullPixelFlip.get() );
+}
+
+
 ossimRefPtr<ossimBandSelector> ossimSingleImageChain::getBandSelector()
 {
    return m_bandSelector;
@@ -809,6 +848,17 @@ ossimRefPtr<ossimCacheTileSource> ossimSingleImageChain::getChainCache()
    return m_chainCache;
 }
 
+
+void ossimSingleImageChain::setAddNullPixelFlipFlag(bool flag)
+{
+   m_addNullPixelFlipFlag = true;
+}
+
+bool ossimSingleImageChain::getNullPixelFlipFlag() const
+{
+   return m_addNullPixelFlipFlag;
+}
+
 void ossimSingleImageChain::setAddHistogramFlag(bool flag)
 {
    m_addHistogramFlag = flag;
diff --git a/src/imaging/ossimTiffTileSource.cpp b/src/imaging/ossimTiffTileSource.cpp
index c28836d..b0c1d52 100644
--- a/src/imaging/ossimTiffTileSource.cpp
+++ b/src/imaging/ossimTiffTileSource.cpp
@@ -37,6 +37,7 @@
 #include <geo_normalize.h>
 #include <cstdlib> /* for abs(int) */
 #include <ossim/base/ossimStreamFactoryRegistry.h>
+#include <ossim/support_data/TiffHandlerState.h>
 
 RTTI_DEF1(ossimTiffTileSource, "ossimTiffTileSource", ossimImageHandler)
 
@@ -60,142 +61,6 @@ static ossimTrace traceDebug("ossimTiffTileSource:debug");
 //---
 #define OSSIM_BUFFER_SCAN_LINE_READS 1
 
-class TiffStreamAdaptor
-{
-public:
-   TiffStreamAdaptor(ossimTiffTileSource* tiffTileSource)
-      :m_tiffTileSource(tiffTileSource)
-   {
-      m_tiffStream = ossim::StreamFactoryRegistry::instance()->createIstream(m_tiffTileSource->getFilename());
-   }
-
-   TiffStreamAdaptor(ossimTiffTileSource* tiffTileSource, 
-                     std::shared_ptr<ossim::istream>& tiffStream)
-      :m_tiffTileSource(tiffTileSource),
-       m_tiffStream(tiffStream)
-   {
-
-   }
-   
-   ~TiffStreamAdaptor()
-   {
-      close();
-   }
-   ossimFilename getFilename()const
-   {
-      if(m_tiffTileSource)
-      {
-         return m_tiffTileSource->getFilename();
-      }
-
-      return "";
-   }
-   void close()
-   {
-      m_tiffStream.reset();
-      m_tiffTileSource = 0;
-   }
-   ossimTiffTileSource* m_tiffTileSource;
-   std::shared_ptr<ossim::istream> m_tiffStream;
-};
-
-tsize_t tiff_Read(thandle_t st,tdata_t buffer,tsize_t size)
-{
-   TiffStreamAdaptor* streamAdaptor = (TiffStreamAdaptor*)st;
-   tsize_t result = -1;
-   if(streamAdaptor->m_tiffStream)
-   {
-      streamAdaptor->m_tiffStream->read((char*)buffer, size);
-
-      result = streamAdaptor->m_tiffStream->gcount();
-   }
-
-   return result;
-};
-
-tsize_t tiff_Write(thandle_t st,tdata_t buffer,tsize_t size)
-{
-   return -1;
-};
-
-int tiff_Close(thandle_t st)
-{
-   TiffStreamAdaptor* streamAdaptor = (TiffStreamAdaptor*)st;
-
-   streamAdaptor->close();
-   
-   return 0;
-};
-
-toff_t tiff_Seek(thandle_t st,toff_t pos, int whence)
-{
-   TiffStreamAdaptor* streamAdaptor = (TiffStreamAdaptor*)st;
-   toff_t result = -1;
-   std::ios_base::seekdir seekDir = std::ios::beg;
-
-   // Because we are adapting, on each seek we need to clear our previous error so 
-   // we can continue on.  Do not want the stream to stay in a failed state.
-   //
-   streamAdaptor->m_tiffStream->clear();
-   
-// std::cout << "SIZE OF POS =============== " << sizeof(toff_t) << std::endl;
-// std::cout << "tiff_Seek POS =============== " << pos << std::endl;
-   //std::cout<< "CALLING THE tiff_Seek!!!!!!!!!!!!!!\n" << std::endl;
-   if (!streamAdaptor->m_tiffStream)
-   {
-    return result;      
-   }
-   switch(whence)
-   {
-      case 0: // SEEK_SET
-      {
-       seekDir = std::ios::beg;
-       break;
-      }
-      case 1: // SEEK_CUR
-      {
-         seekDir = std::ios::cur;
-         break;
-      }
-      case 2: // SEEK_END
-      {
-        seekDir = std::ios::end;
-         break;
-      }
-   }
-       // std::cout << "tiff_Seek RESULT === " << result << "\n";
-
-   streamAdaptor->m_tiffStream->seekg(pos, seekDir);
-   return streamAdaptor->m_tiffStream->tellg();
-};
-
-toff_t tiff_Size(thandle_t st)
-{
-   toff_t result = -1;
-   //std::cout<< "CALLING THE tiff_Size!!!!!!!!!!!!!!\n" << std::endl;
-   TiffStreamAdaptor* streamAdaptor = (TiffStreamAdaptor*)st;
-    if (streamAdaptor->m_tiffStream)
-    {
-      ossim_int64 currentOffset = streamAdaptor->m_tiffStream->tellg();
-      streamAdaptor->m_tiffStream->seekg(0, std::ios::end);
-      result = streamAdaptor->m_tiffStream->tellg();
-      streamAdaptor->m_tiffStream->seekg(currentOffset);
-    }
-    // std::cout << "tiff_Size RESULT =========== " << result << "\n";
-   return result;
-};
-
-int tiff_Map(thandle_t, tdata_t*, toff_t*)
-{
-   std::cout << "tiff_Map\n";
-    return 0;
-};
-
-void tiff_Unmap(thandle_t, tdata_t, toff_t)
-{
-   std::cout << "tiff_Unmap\n";
-    return;
-};
 
 //*******************************************************************
 // Public Constructor:
@@ -489,7 +354,7 @@ bool ossimTiffTileSource::loadState(const ossimKeywordlist& kwl,
 }
 
 bool ossimTiffTileSource::open(const ossimFilename& image_file)
-{
+{   
    if (theTiffPtr)
    {
      close();
@@ -500,8 +365,6 @@ bool ossimTiffTileSource::open(const ossimFilename& image_file)
 
 void ossimTiffTileSource::close()
 {
-   // std::cout << "ossimTiffTileSource::close()\n";
-
    if(theTiffPtr)
    {
       XTIFFClose(theTiffPtr);
@@ -539,16 +402,11 @@ bool ossimTiffTileSource::open( std::shared_ptr<ossim::istream>& str,
       close();
    }
 
-   // std::cout << "NOW DOING THE STREAM OPEN!!!!!!!!!!!!!!!!" << (ossim_int64)this 
-   //           << " for file:" 
-   //           << connectionString << "\n";
-   
    // Check for empty file name.
    if ( connectionString.empty() )
    {
       return false;
    }
-
    theImageFile = ossimFilename(connectionString);
    theImageDirectoryList.clear();
 
@@ -557,14 +415,18 @@ bool ossimTiffTileSource::open( std::shared_ptr<ossim::istream>& str,
    //---
    //theTiffPtr = XTIFFOpen(theImageFile.c_str(), "rm");
    //m_streamAdaptor = std::make_shared<TiffStreamAdaptor>(this);
-   m_streamAdaptor = std::make_shared<TiffStreamAdaptor>(this, str);
+   m_streamAdaptor = std::make_shared<ossim::TiffIStreamAdaptor>(str,
+                                                                 connectionString);
 
    theTiffPtr = XTIFFClientOpen(connectionString.c_str(), "rm", 
                                 (thandle_t)m_streamAdaptor.get(),
-                                tiff_Read, tiff_Write, tiff_Seek, tiff_Close, tiff_Size,
-                                tiff_Map, tiff_Unmap);
-
-// std::cout << "TIFF PTR ????????????" << theTiffPtr << std::endl;
+                                ossim::TiffIStreamAdaptor::tiffRead, 
+                                ossim::TiffIStreamAdaptor::tiffWrite, 
+                                ossim::TiffIStreamAdaptor::tiffSeek, 
+                                ossim::TiffIStreamAdaptor::tiffClose, 
+                                ossim::TiffIStreamAdaptor::tiffSize,
+                                ossim::TiffIStreamAdaptor::tiffMap, 
+                                ossim::TiffIStreamAdaptor::tiffUnmap);
    if (!theTiffPtr)
    {
       if (traceDebug())
@@ -575,16 +437,49 @@ bool ossimTiffTileSource::open( std::shared_ptr<ossim::istream>& str,
       }
       return false;
    }
+   std::shared_ptr<ossim::TiffHandlerState> state = getStateAs<ossim::TiffHandlerState>();
+   if(!state)
+   {
+      state = std::make_shared<ossim::TiffHandlerState>();
+      setState(state); 
+      state->loadDefaults(theTiffPtr);
+      state->setImageHandlerType(getClassName());
+   }
+   state->setConnectionString(connectionString);
+   
+   // Current dir.
+   theCurrentDirectory = TIFFCurrentDirectory(theTiffPtr);
+   ossimString tempValue;
+   // Get the number of directories.
+   if(state->getValue(tempValue, "number_of_directories"))
+   {
+      theNumberOfDirectories = tempValue.toUInt32();
+   }
+   else
+   {
+      if (traceDebug())
+      {
+         ossimNotify(ossimNotifyLevel_WARN)
+            << MODULE << " ERROR:\n"
+            << "Unable to get the number of directories\n";
+      }
+      return false;      
+   }
 
    theCompressionType = COMPRESSION_NONE;
+
    //***
    // Get the general tiff info.
    //***
-   if(!TIFFGetField(theTiffPtr, TIFFTAG_COMPRESSION, &theCompressionType))
+
+   if(!state->getValue(tempValue, theCurrentDirectory, "tifftag.compression"))
    {
-      theCompressionType = COMPRESSION_NONE;
+     theCompressionType = COMPRESSION_NONE; 
+   }
+   else
+   {
+      theCompressionType = tempValue.toInt32();
    }
-
    //***
    // See if the first directory is of FILETYPE_REDUCEDIMAGE; if not,
    // the first level is considered to be full resolution data.
@@ -592,15 +487,8 @@ bool ossimTiffTileSource::open( std::shared_ptr<ossim::istream>& str,
    // resolution.
    //***
    theImageDirectoryList.push_back(0);
-   ossim_uint32 sub_file_type;
-   if ( !TIFFGetField( theTiffPtr,
-                       TIFFTAG_SUBFILETYPE ,
-                       &sub_file_type ) )
-   {
-      sub_file_type = 0;
-   }
 
-   if (sub_file_type == FILETYPE_REDUCEDIMAGE)
+   if (state->isReduced(theCurrentDirectory))
    {
       theR0isFullRes = false;
    }
@@ -609,25 +497,31 @@ bool ossimTiffTileSource::open( std::shared_ptr<ossim::istream>& str,
       theR0isFullRes = true;
    }
    
-   if( !TIFFGetField(theTiffPtr, TIFFTAG_BITSPERSAMPLE, &(theBitsPerSample)) )
+   if(!state->getValue(tempValue, theCurrentDirectory, "tifftag.bits_per_sample"))
    {
       theBitsPerSample = 8;
    }
-
-   if( !TIFFGetField(theTiffPtr,
-                     TIFFTAG_SAMPLESPERPIXEL,
-                     &theSamplesPerPixel ) )
+   else
+   {
+      theBitsPerSample = tempValue.toUInt16();
+   }
+   if(!state->getValue(tempValue, theCurrentDirectory, "tifftag.samples_per_pixel"))
    {
       theSamplesPerPixel = 1;
    }
+   else
+   {
+      theSamplesPerPixel = tempValue.toUInt16();
+   }
    
-   if ( !TIFFGetField( theTiffPtr,
-                       TIFFTAG_SAMPLEFORMAT,
-                       &theSampleFormatUnit ) )
+   if(!state->getValue(tempValue, theCurrentDirectory, "tifftag.sample_format"))
    {
       theSampleFormatUnit = 0;
    }
-
+   else
+   {
+      theSampleFormatUnit = tempValue.toUInt16();;
+   }
    if ( theSampleFormatUnit == SAMPLEFORMAT_COMPLEXINT )
    {
       //---
@@ -637,45 +531,21 @@ bool ossimTiffTileSource::open( std::shared_ptr<ossim::istream>& str,
       theSamplesPerPixel = 2;
    }
 
-   if ( !TIFFGetField( theTiffPtr,
-                       TIFFTAG_SMAXSAMPLEVALUE,
-                       &theMaxSampleValue ) )
+   if(!state->getValue(tempValue, theCurrentDirectory, "tifftag.max_sample_value"))
    {
-      uint16 maxValue = 0;
-      if(!TIFFGetField( theTiffPtr,
-                        TIFFTAG_MAXSAMPLEVALUE,
-                        &maxValue))
-      {
-         //---
-         // This will be reset in validateMinMax method.  Can't set right now because we
-         // don't know the scalar type yet.
-         //---
-         theMaxSampleValue = ossim::nan();
-      }
-      else
-      {
-         theMaxSampleValue = maxValue;
-      }
+      theMaxSampleValue = ossim::nan();
    }
-   if ( !TIFFGetField( theTiffPtr,
-                       TIFFTAG_SMINSAMPLEVALUE,
-                       &theMinSampleValue ) )
+   else
    {
-      uint16 minValue = 0;
-      if(!TIFFGetField( theTiffPtr,
-                        TIFFTAG_MINSAMPLEVALUE,
-                        &minValue))
-      {
-         //---
-         // This will be reset in validateMinMax method.  Can't set right now because we
-         // don't know the scalar type yet.
-         //--- 
-         theMinSampleValue = ossim::nan();
-      }
-      else
-      {
-         theMinSampleValue = minValue;
-      }
+      theMaxSampleValue = tempValue.toFloat32();
+   }
+   if(!state->getValue(tempValue, theCurrentDirectory, "tifftag.min_sample_value"))
+   {
+      theMinSampleValue = ossim::nan();
+   }
+   else
+   {
+      theMinSampleValue = tempValue.toFloat32();
    }
 
    if (traceDebug())
@@ -686,12 +556,6 @@ bool ossimTiffTileSource::open( std::shared_ptr<ossim::istream>& str,
            << endl;
    }
 
-   // Get the number of directories.
-   theNumberOfDirectories = TIFFNumberOfDirectories(theTiffPtr);
-
-   // Current dir.
-   theCurrentDirectory = TIFFCurrentDirectory(theTiffPtr);
-
    theImageWidth.resize(theNumberOfDirectories);
    theImageLength.resize(theNumberOfDirectories);
    theReadMethod.resize(theNumberOfDirectories);
@@ -703,43 +567,39 @@ bool ossimTiffTileSource::open( std::shared_ptr<ossim::istream>& str,
 
    for (ossim_uint32 dir=0; dir<theNumberOfDirectories; ++dir)
    {
-      if (setTiffDirectory(dir) == false)
-      {
-         return false;
-      }
+      // if (setTiffDirectory(dir) == false)
+      // {
+      //    return false;
+      // }
 
       // Note: Need lines, samples before acceptAsRrdsLayer check.
       
       // lines:
-      if ( !TIFFGetField( theTiffPtr,
-                          TIFFTAG_IMAGELENGTH,
-                          &theImageLength[dir] ) )
+      if(!state->getValue(tempValue, dir, "tifftag.image_length"))
       {
          theErrorStatus = ossimErrorCodes::OSSIM_ERROR;
          ossimNotify(ossimNotifyLevel_WARN)
             << MODULE << " Cannot determine image length."
             << endl;
       }
-
+      else
+      {
+         theImageLength[dir] = tempValue.toUInt32();
+      }
       // samples:
-      if ( !TIFFGetField( theTiffPtr,
-                          TIFFTAG_IMAGEWIDTH,
-                          &theImageWidth[dir] ) )
+      if(!state->getValue(tempValue, dir, "tifftag.image_width"))
       {
          theErrorStatus = ossimErrorCodes::OSSIM_ERROR;
          ossimNotify(ossimNotifyLevel_WARN)
             << MODULE << " Cannot determine image width."
             << endl;
       }
-      
-      if ( !TIFFGetField( theTiffPtr,
-                         TIFFTAG_SUBFILETYPE ,
-                         &sub_file_type ) )
+      else
       {
-         sub_file_type = 0;
-      }
+         theImageWidth[dir] = tempValue.toUInt32();
+      }      
 
-      if (sub_file_type == FILETYPE_REDUCEDIMAGE)
+      if (state->isReduced(dir))
       {
          //---
          // Check for a thumbnail image.  If present don't use as it will mess with
@@ -764,23 +624,27 @@ bool ossimTiffTileSource::open( std::shared_ptr<ossim::istream>& str,
          }
       }
       
-      if( !TIFFGetField( theTiffPtr, TIFFTAG_PLANARCONFIG,
-                         &(thePlanarConfig[dir]) ) )
+      if(!state->getValue(tempValue, dir, "tifftag.planar_config"))
       {
          thePlanarConfig[dir] = PLANARCONFIG_CONTIG;
       }
+      else
+      {
+         thePlanarConfig[dir] = tempValue.toUInt16();
+      }
       
-      if( !TIFFGetField( theTiffPtr, TIFFTAG_PHOTOMETRIC,
-                         &(thePhotometric[dir]) ) )
+      if(!state->getValue(tempValue, dir, "tifftag.photometric"))
       {
          thePhotometric[dir] = PHOTOMETRIC_MINISBLACK;
       }
+      else
+      {
+         thePhotometric[dir] = tempValue.toUInt16();
+      }
       theLut = 0;
-      // Check for palette.
-      uint16* red;
-      uint16* green;
-      uint16* blue;
-      if(TIFFGetField(theTiffPtr, TIFFTAG_COLORMAP, &red, &green, &blue))
+      if(state->exists(dir, "tifftag.colormap.red")&&
+         state->exists(dir, "tifftag.colormap.green")&&
+         state->exists(dir, "tifftag.colormap.blue"))
       {
          if(theApplyColorPaletteFlag)
          {
@@ -789,23 +653,29 @@ bool ossimTiffTileSource::open( std::shared_ptr<ossim::istream>& str,
          }
          populateLut();
       }
+      theRowsPerStrip[dir] = 0;
+      theImageTileWidth[dir] = 0;
+      theImageTileLength[dir] = 0;
 
-      if( TIFFIsTiled(theTiffPtr))
+      if(state->isTiled(dir))
       {
-         theRowsPerStrip[dir] = 0;
-         if ( !TIFFGetField( theTiffPtr,
-                             TIFFTAG_TILEWIDTH,
-                             &theImageTileWidth[dir] ) )
+         if(state->getValue(tempValue, dir, "tifftag.tile_width"))
+         {
+            theImageTileWidth[dir] = tempValue.toUInt32();
+         }
+         else
          {
             theErrorStatus = ossimErrorCodes::OSSIM_ERROR;
             ossimNotify(ossimNotifyLevel_WARN)
                << "ossimTiffTileSource::getTiffTileWidth ERROR:"
                << "\nCannot determine tile width." << endl;
-            theImageTileWidth[dir] = 0;
+
          }
-         if ( !TIFFGetField( theTiffPtr,
-                             TIFFTAG_TILELENGTH,
-                             &theImageTileLength[dir] ) )
+         if(state->getValue(tempValue, dir, "tifftag.tile_length"))
+         {
+            theImageTileLength[dir] = tempValue.toUInt32();
+         }
+         else
          {
             theErrorStatus = ossimErrorCodes::OSSIM_ERROR;   
             ossimNotify(ossimNotifyLevel_WARN)
@@ -816,18 +686,14 @@ bool ossimTiffTileSource::open( std::shared_ptr<ossim::istream>& str,
       }
       else
       {
-         // Strip tiff:
-         theImageTileWidth[dir]  = 0;
-         theImageTileLength[dir] = 0;
-         if( !TIFFGetField( theTiffPtr, TIFFTAG_ROWSPERSTRIP,
-                            &(theRowsPerStrip[dir]) ) )
+         if(state->getValue(tempValue, dir, "tifftag.rows_per_strip"))
+         {
+            theRowsPerStrip[dir] = tempValue.toUInt32();
+         }
+         else
          {
             theRowsPerStrip[dir] = 1;
          }
-         
-         theImageTileWidth[dir]  = theImageWidth[dir];
-         theImageTileLength[dir] = theRowsPerStrip[dir];
-
          //---
          // Let's default the tile size to something efficient.
          //
@@ -853,7 +719,6 @@ bool ossimTiffTileSource::open( std::shared_ptr<ossim::istream>& str,
             theImageTileLength[dir] = 64;
          }
       }
-      
    } // End of "for (ossim_uint32 dir=0; dir<theNumberOfDirectories; dir++)"
    
    // Reset the directory back to "0".
@@ -998,24 +863,17 @@ bool ossimTiffTileSource::open( std::shared_ptr<ossim::istream>& str,
    validateMinMaxNull();
    
    setReadMethod();
-   
-   // std::cout << "DOING GTIFF ALLOCATE\n";
-   // Establish raster pixel alignment type:
-   GTIF* gtif = GTIFNew(theTiffPtr);
-   // std::cout << "ALLOCATED!!!!!\n";
-   ossim_uint16 raster_type;
-   if (GTIFKeyGet(gtif, GTRasterTypeGeoKey, &raster_type, 0, 1) && (raster_type == 1))
-   {
+  
+  ossim_uint16 rasterType = state->getRasterType(theCurrentDirectory);
+
+  if(rasterType == 1)
+  {
       thePixelType = OSSIM_PIXEL_IS_AREA;
-   }
-   else
-   {
+  }
+  else
+  {
       thePixelType = OSSIM_PIXEL_IS_POINT;
-   }
-
-   GTIFFree(gtif);
-// std::cout << "DOING COMPLETE OPEN!!!!!!!!!!!!\n";
-   // Let base-class finish the rest:
+  }
    completeOpen();
 
    if ( isBandSelector() && theOutputBandList.size() && ( isIdentityBandList( theOutputBandList ) == false ) )
@@ -1034,7 +892,6 @@ bool ossimTiffTileSource::open( std::shared_ptr<ossim::istream>& str,
       ossimNotify(ossimNotifyLevel_DEBUG) << MODULE << " Debug:";
       print(ossimNotify(ossimNotifyLevel_DEBUG));
    }
- // std::cout << "DONE DOING COMPLETE OPEN!!!!!!!!!!!!\n";
   
    // Finished...
    return true;
@@ -1640,7 +1497,6 @@ bool ossimTiffTileSource::loadFromRgbaU8Strip(const ossimIrect& tile_rect,
    ossim_uint32 output_tile_offset = (clip_rect.ul().y - tile_rect.ul().y) *
                                 OUTPUT_TILE_WIDTH + clip_rect.ul().x -
                                 tile_rect.ul().x;
-
 #if 0 /* Please keep for debug: */
    CLOG << "DEBUG:"
         << "\nsamples:         " << theSamplesPerPixel
@@ -1735,9 +1591,21 @@ bool ossimTiffTileSource::loadFromRgbaU8Strip(const ossimIrect& tile_rect,
                  sample<=clip_rect.lr().x;
                  sample++)
             {
-               d[0][i] = OSSIM_TIFF_UNPACK_R4(*s);
-               d[1][i] = OSSIM_TIFF_UNPACK_G4(*s);
-               d[2][i] = OSSIM_TIFF_UNPACK_B4(*s);
+               //We had a single band strip image that is coming into this method
+               // Will add a sanity check on the samples per pixel.  If it's == 1 for now
+               // we will assign the value and if it has atleast the 3 samples then we will 
+               // extract as usual.
+               //
+               if(theSamplesPerPixel >=3)
+               {
+                  d[0][i] = OSSIM_TIFF_UNPACK_R4(*s);
+                  d[1][i] = OSSIM_TIFF_UNPACK_G4(*s);
+                  d[2][i] = OSSIM_TIFF_UNPACK_B4(*s);                  
+               }
+               else if(theSamplesPerPixel == 1)
+               {
+                  d[0][i] = *s;
+               }
                ++i;
                ++s;
             }
@@ -2346,92 +2214,89 @@ ossim_float64 ossimTiffTileSource::getNullPixelValue(ossim_uint32 band)const
 bool ossimTiffTileSource::isColorMapped() const
 {
    bool result = false;
-   if ( isOpen() )
+   
+   std::shared_ptr<const ossim::TiffHandlerState> state = getStateAs<ossim::TiffHandlerState>();
+   if(state)
    {
-      uint16* red;
-      uint16* green;
-      uint16* blue;
-      
-      result = static_cast<bool>(TIFFGetField(theTiffPtr,
-                                              TIFFTAG_COLORMAP,
-                                              &red, &green, &blue));
+      result = state->exists(TIFFCurrentDirectory(theTiffPtr),
+                             "tifftag.colormap.red");
    }
+
    return result;
 }
 
 void ossimTiffTileSource::setReadMethod()
 {
-   for (ossim_uint32 dir=0; dir<theNumberOfDirectories; ++dir)
+   std::shared_ptr<ossim::TiffHandlerState> state = getStateAs<ossim::TiffHandlerState>();
+
+   if(state)
    {
-      if (setTiffDirectory(dir) == false)
-      {
-         return;
-      }
-      
-      //---
-      // Establish how this tiff directory will be read.
-      //---
-      if (TIFFIsTiled(theTiffPtr)) 
-      {
-         if ( ( thePhotometric[dir] == PHOTOMETRIC_YCBCR ||
-                thePhotometric[dir] == PHOTOMETRIC_PALETTE ) &&
-              (theSamplesPerPixel <= 3) &&
-              (theBitsPerSample   <= 8 ))
-         {
-            theReadMethod[dir] = READ_RGBA_U8_TILE;
-         }
-         else
-         {
-            theReadMethod[dir] = READ_TILE;
-         }
-      }
-      else // Not tiled...
-      {
-         if ( (thePhotometric[dir] == PHOTOMETRIC_PALETTE ||
-               thePhotometric[dir] == PHOTOMETRIC_YCBCR ) &&
-              theSamplesPerPixel <= 3 &&
-              theBitsPerSample   <= 8 )
-         {
-            theReadMethod[dir] = READ_RGBA_U8_STRIP;
-         }
-         else if (( theBitsPerSample == 16 ) &&
-                  ( theRowsPerStrip[dir] > 1 ) &&
-                  (( thePlanarConfig[dir] == PLANARCONFIG_SEPARATE ) ||
-                    ((thePlanarConfig[dir] == PLANARCONFIG_CONTIG) && (theSamplesPerPixel==1))))
-         {
-            // Buffer a strip of bands.
-            theReadMethod[dir] = READ_U16_STRIP;
-         }
-         else if (theSamplesPerPixel <= 3 && theBitsPerSample == 1)
-         {
-            //---
-            // Note:  One bit data expands to zeroes and 255's so run it through
-            //        a specialized method to flip zeroes to one's since zeroes
-            //        are usually reserved for null value.
-            //---
-            theReadMethod[dir] = READ_RGBA_U8A_STRIP;
-         }
-         else if((theCompressionType == COMPRESSION_NONE)||
-                 (theRowsPerStrip[dir]==1))
-         {
-            theReadMethod[dir] = READ_SCAN_LINE;
-         }
-         else if((theCompressionType!=COMPRESSION_NONE)&&
-                 (theSamplesPerPixel <= 4) &&
-                 (theBitsPerSample   <= 8) )
+      for (ossim_uint32 dir=0; dir<theNumberOfDirectories; ++dir)
+      {         
+         //---
+         // Establish how this tiff directory will be read.
+         //---
+         if (state->isTiled(dir)) 
          {
-            theReadMethod[dir] = READ_RGBA_U8_STRIP;
+            if ( ( thePhotometric[dir] == PHOTOMETRIC_YCBCR ||
+                   thePhotometric[dir] == PHOTOMETRIC_PALETTE ) &&
+                 (theSamplesPerPixel <= 3) &&
+                 (theBitsPerSample   <= 8 ))
+            {
+               theReadMethod[dir] = READ_RGBA_U8_TILE;
+            }
+            else
+            {
+               theReadMethod[dir] = READ_TILE;
+            }
          }
-         else
+         else // Not tiled...
          {
-            theReadMethod[dir] = UNKNOWN;
+            if ( (thePhotometric[dir] == PHOTOMETRIC_PALETTE ||
+                  thePhotometric[dir] == PHOTOMETRIC_YCBCR ) &&
+                 theSamplesPerPixel <= 3 &&
+                 theBitsPerSample   <= 8 )
+            {
+               theReadMethod[dir] = READ_RGBA_U8_STRIP;
+            }
+            else if (( theBitsPerSample == 16 ) &&
+                     ( theRowsPerStrip[dir] > 1 ) &&
+                     (( thePlanarConfig[dir] == PLANARCONFIG_SEPARATE ) ||
+                       ((thePlanarConfig[dir] == PLANARCONFIG_CONTIG) && (theSamplesPerPixel==1))))
+            {
+               // Buffer a strip of bands.
+               theReadMethod[dir] = READ_U16_STRIP;
+            }
+            else if (theSamplesPerPixel <= 3 && theBitsPerSample == 1)
+            {
+               //---
+               // Note:  One bit data expands to zeroes and 255's so run it through
+               //        a specialized method to flip zeroes to one's since zeroes
+               //        are usually reserved for null value.
+               //---
+               theReadMethod[dir] = READ_RGBA_U8A_STRIP;
+            }
+            else if((theCompressionType == COMPRESSION_NONE)||
+                    (theRowsPerStrip[dir]==1))
+            {
+               theReadMethod[dir] = READ_SCAN_LINE;
+            }
+            else if((theCompressionType!=COMPRESSION_NONE)&&
+                    (theSamplesPerPixel <= 4) &&
+                    (theBitsPerSample   <= 8) )
+            {
+               theReadMethod[dir] = READ_RGBA_U8_STRIP;
+            }
+            else
+            {
+               theReadMethod[dir] = UNKNOWN;
+            }
          }
-      }
-      
-   } // End of loop through directories.
-
+         
+      } // End of loop through directories.
+   }
    // Reset the directory back to "0".
-   setTiffDirectory(0);
+//   setTiffDirectory(0);
 }
 
 void ossimTiffTileSource::setProperty(ossimRefPtr<ossimProperty> property)
@@ -2512,38 +2377,58 @@ bool ossimTiffTileSource::setTiffDirectory(ossim_uint16 directory)
 
 void ossimTiffTileSource::populateLut()
 {
-   ossim_uint16* r;
-   ossim_uint16* g;
-   ossim_uint16* b;
-   if(TIFFGetField(theTiffPtr, TIFFTAG_COLORMAP, &r, &g, &b))
-   {
-      ossim_uint32 numEntries = 256;
-      ossimScalarType scalarType = OSSIM_UINT8;
-      if(theBitsPerSample == 16)
-      {
-         numEntries = 65536;
-         scalarType = OSSIM_UINT16;
-      }
-      theLut = new ossimNBandLutDataObject(numEntries,
-                                           3,
-                                           scalarType,
-                                           0);
-      ossim_uint32 entryIdx = 0;
-      for(entryIdx = 0; entryIdx < numEntries; ++entryIdx)
-      {
-         if(scalarType == OSSIM_UINT8)
-         {
-            (*theLut)[entryIdx][0] = (ossimNBandLutDataObject::LUT_ENTRY_TYPE)(((*r)/65535.0)*255.0);
-            (*theLut)[entryIdx][1] = (ossimNBandLutDataObject::LUT_ENTRY_TYPE)(((*g)/65535.0)*255.0);
-            (*theLut)[entryIdx][2] = (ossimNBandLutDataObject::LUT_ENTRY_TYPE)(((*b)/65535.0)*255.0);
-         }
-         else
+   std:shared_ptr<ossim::TiffHandlerState> state = getStateAs<ossim::TiffHandlerState>();
+   ossimString red;
+   ossimString green;
+   ossimString blue;
+   ossim_uint32 currentDir = TIFFCurrentDirectory(theTiffPtr);
+   if(state->getValue(red, currentDir, "tifftag.colormap.red")&&
+      state->getValue(green, currentDir, "tifftag.colormap.green")&&
+      state->getValue(blue, currentDir, "tifftag.colormap.blue"))
+   {
+      std::vector<ossim_uint16> redValues;
+      std::vector<ossim_uint16> greenValues;
+      std::vector<ossim_uint16> blueValues;
+      if(ossim::toSimpleVector(redValues, red)&&
+         ossim::toSimpleVector(greenValues, green)&&
+         ossim::toSimpleVector(blueValues, blue))
+      {
+         if(((redValues.size()==greenValues.size())&&(redValues.size()==blueValues.size()))&&
+            (redValues.size()==256||redValues.size()==65536))
+
          {
-            (*theLut)[entryIdx][0] = (ossimNBandLutDataObject::LUT_ENTRY_TYPE)(*r);
-            (*theLut)[entryIdx][1] = (ossimNBandLutDataObject::LUT_ENTRY_TYPE)(*g);
-            (*theLut)[entryIdx][2] = (ossimNBandLutDataObject::LUT_ENTRY_TYPE)(*b);
+            ossim_uint16* r = &redValues.front();
+            ossim_uint16* g = &greenValues.front();
+            ossim_uint16* b = &blueValues.front();
+            ossim_uint32 numEntries = redValues.size();
+            ossimScalarType scalarType = OSSIM_UINT8;
+            if(theBitsPerSample == 16)
+            {
+               scalarType = OSSIM_UINT16;
+            }
+            theLut = new ossimNBandLutDataObject(numEntries,
+                                                 3,
+                                                 scalarType,
+                                                 0);
+            ossim_uint32 entryIdx = 0;
+            for(entryIdx = 0; entryIdx < numEntries; ++entryIdx)
+            {
+               if(scalarType == OSSIM_UINT8)
+               {
+                  (*theLut)[entryIdx][0] = (ossimNBandLutDataObject::LUT_ENTRY_TYPE)(((*r)/65535.0)*255.0);
+                  (*theLut)[entryIdx][1] = (ossimNBandLutDataObject::LUT_ENTRY_TYPE)(((*g)/65535.0)*255.0);
+                  (*theLut)[entryIdx][2] = (ossimNBandLutDataObject::LUT_ENTRY_TYPE)(((*b)/65535.0)*255.0);
+               }
+               else
+               {
+                  (*theLut)[entryIdx][0] = (ossimNBandLutDataObject::LUT_ENTRY_TYPE)(*r);
+                  (*theLut)[entryIdx][1] = (ossimNBandLutDataObject::LUT_ENTRY_TYPE)(*g);
+                  (*theLut)[entryIdx][2] = (ossimNBandLutDataObject::LUT_ENTRY_TYPE)(*b);
+               }
+               ++r;++g;++b;
+            }
+
          }
-         ++r;++g;++b;
       }
    }
 }
@@ -2670,84 +2555,6 @@ void ossimTiffTileSource::validateMinMaxNull()
    }
 }
 
-#if 0
-ossimImageGeometry* ossimTiffTileSource::getImageGeometry()
-{
-   //---
-   // Call base class getImageGeometry which will check for external geometry
-   // or an already set geometry.
-   //---
-   ossimImageGeometry* result = ossimImageHandler::getImageGeometry();
-
-   if (result)
-   {
-      //---
-      // TODO: Add transform from tags.
-      //---
-
-      
-      // if ( !result->getTransform() )
-      // {
-      //    if ( transform.valid() )
-      //    {
-      //       result->setTransform( transform.get() );
-      //    }
-      // }
-      //else
-      //{
-      //   ossimImageGeometryRegistry::instance()->createTransform(this);
-      //}
-      
-      if ( !result->getProjection() )
-      {
-         // Get the projection from the tags.
-         
-         ossimRefPtr<ossimProjection> proj = 0;
-
-         if (theTiffPtr)
-         {
-            ossimGeoTiff geotiff;
-
-            //---
-            // Note: must pass false to readTags so it doesn't close our
-            // tiff pointer.
-            //---
-            geotiff.readTags(theTiffPtr, getCurrentEntry(), false);
-            ossimKeywordlist kwl;
-            if(geotiff.addImageGeometry(kwl))
-            {
-               proj = ossimProjectionFactoryRegistry::instance()->
-                  createProjection(kwl);
-            }
-            
-            if ( proj.valid() )
-            {
-               result->setProjection( proj.get() );
-            }
-            //else
-            //{
-            // ossimImageGeometryRegistry::instance()->createProjection(this);
-            //}
-         }
-      }
-      
-   } // matches: if (result)
-
-   if (traceDebug())
-   {
-      ossimNotify(ossimNotifyLevel_DEBUG)
-         << "ossimTiffTileSource::createImageGeometry DEBUG:\n";
-
-      if (result)
-      {
-         result->print(ossimNotify(ossimNotifyLevel_DEBUG)) << "\n";
-      }
-   }
-
-   return result;
-}
-#endif
-
 bool ossimTiffTileSource::isPowerOfTwoDecimation(ossim_uint32 level) const
 {
    // Check size of this level against last level to see if it's half the previous.
@@ -2832,7 +2639,6 @@ bool ossimTiffTileSource::allocateBuffer()
       } 
       case READ_U16_STRIP:
       {
-//         std::cout << "DOING READ_U16_STRIP\n";
          // Encountered case where it was multiple rows per strip, yet PLANARCONFIG_CONTIG. The
          // case was in fact single band so planar config is irrelevant. (OLK July 2015)
          
@@ -2841,11 +2647,6 @@ bool ossimTiffTileSource::allocateBuffer()
          // so all bands has to be populated for the buffer. (GCP Sept 2015)
          buffer_size = theImageWidth[0]*theRowsPerStrip[theCurrentDirectory]*theBytesPerPixel*
                        theSamplesPerPixel;
-//         std::cout << "ROWS PER STRIP: " << theRowsPerStrip[theCurrentDirectory] << "\n"
-//                   << "ImageWidth:     " << theImageWidth[0] << "\n"
-//                   << "BytesPerPixel:  " << theBytesPerPixel << "\n";
-//         std::cout << thePlanarConfig[theCurrentDirectory] << " ==== " << PLANARCONFIG_CONTIG << "\n";
-
          // I commented this out for this is core dumping for one of the tiff images. (GCP Sept 2015)
         // if (thePlanarConfig[theCurrentDirectory] == PLANARCONFIG_CONTIG)
           //  buffer_size *= theSamplesPerPixel;
diff --git a/src/init/ossimInit.cpp b/src/init/ossimInit.cpp
index 0a3fd0b..7c16968 100644
--- a/src/init/ossimInit.cpp
+++ b/src/init/ossimInit.cpp
@@ -34,17 +34,20 @@
 #include <ossim/base/ossimNotify.h>
 #include <ossim/base/ossimObjectFactoryRegistry.h>
 #include <ossim/base/ossimPreferences.h>
-#include <ossim/base/ossimStreamFactory.h>
 #include <ossim/base/ossimStreamFactoryRegistry.h>
 #include <ossim/base/ossimTrace.h>
 #include <ossim/base/ossimTraceManager.h>
 #include <ossim/base/ossimGeoidEgm96.h>
 #include <ossim/base/ossim2dTo2dTransformRegistry.h>
 
+
 #include <ossim/elevation/ossimElevManager.h>
 
 #include <ossim/font/ossimFontFactoryRegistry.h>
 
+#include <ossim/support_data/ImageHandlerStateRegistry.h>
+#include <ossim/support_data/ImageHandlerStateFactory.h>
+
 #include <ossim/imaging/ossimCodecFactoryRegistry.h>
 #include <ossim/imaging/ossimImageSourceFactoryRegistry.h>
 #include <ossim/imaging/ossimImageGeometryRegistry.h>
@@ -61,7 +64,7 @@
 #include <ossim/projection/ossimProjectionViewControllerFactory.h>
 
 #include <algorithm>
-
+#include <mutex>
 
 static ossimTrace traceExec = ossimTrace("ossimInit:exec");
 static ossimTrace traceDebug = ossimTrace("ossimInit:debug");
@@ -85,8 +88,8 @@ ossimInit::ossimInit()
 
 ossimInit* ossimInit::instance()
 {
-   static OpenThreads::Mutex m;
-   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m);
+   static std::mutex m;
+   std::lock_guard<std::mutex> lock(m);
    if (!theInstance)
    {
       theInstance = new ossimInit();
@@ -115,8 +118,8 @@ void ossimInit::addOptions(ossimArgumentParser& parser)
  *****************************************************************************/
 void ossimInit::initialize(int& argc, char** argv)
 {
-   static OpenThreads::Mutex m;
-   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m);
+   static std::mutex m;
+   std::lock_guard<std::mutex> lock(m);
    if( !theInitializedFlag )
    {
       ossimArgumentParser argumentParser(&argc, argv);
@@ -126,8 +129,8 @@ void ossimInit::initialize(int& argc, char** argv)
 
 void ossimInit::initialize(ossimArgumentParser& parser)
 {
-   static OpenThreads::Mutex m;
-   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m);
+   static std::mutex m;
+   std::lock_guard<std::mutex> lock(m);
    if(theInitializedFlag)
    {
       if (traceDebug())
@@ -207,8 +210,8 @@ void ossimInit::initialize()
    delete [] argv[0];
 
 #if 0   
-    static OpenThreads::Mutex m;
-   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m);
+    static std::mutex m;
+   std::lock_guard<std::mutex> lock(m);
    if(theInitializedFlag)
    {
       if (traceDebug())
@@ -522,8 +525,8 @@ void ossimInit::removeOption(int& argc,
 
 void ossimInit::initializeDefaultFactories()
 {
-   ossim::StreamFactoryRegistry::instance()->registerFactory(ossim::StreamFactory::instance());
-
+   ossim::StreamFactoryRegistry::instance();
+   ossim::ImageHandlerStateRegistry::instance()->registerFactory(ossim::ImageHandlerStateFactory::instance());
    ossimObjectFactoryRegistry::instance()->registerFactory(ossimImageSourceFactoryRegistry::instance());
 
    //---
diff --git a/src/ossimConfig.h.in b/src/ossimConfig.h.in
index 1bd86c9..8a424bd 100644
--- a/src/ossimConfig.h.in
+++ b/src/ossimConfig.h.in
@@ -20,4 +20,7 @@
 /* Enable cvs id strings for use with "ident" application. */
 #define OSSIM_ID_ENABLED @OSSIM_ID_ENABLED@
 
+/* Enable cvs id strings for use with "ident" application. */
+#define OSSIM_HAS_JSONCPP @OSSIM_HAS_JSONCPP@
+
 #endif /* End of "#ifndef ossimConfig_HEADER" */
diff --git a/src/parallel/ossimImageHandlerMtAdaptor.cpp b/src/parallel/ossimImageHandlerMtAdaptor.cpp
index 8a10e66..daed3a0 100644
--- a/src/parallel/ossimImageHandlerMtAdaptor.cpp
+++ b/src/parallel/ossimImageHandlerMtAdaptor.cpp
@@ -158,7 +158,7 @@ ossimRefPtr<ossimImageData>
       return NULL;
 
    // The sole purpose of the adapter is this mutex lock around the actual handler getTile:
-   //OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_mutex);
+   //std::lock_guard<std::mutex> lock(m_mutex);
 
    ossimRefPtr<ossimImageData> tile = new ossimImageData();
    ossimRefPtr<ossimImageData> temp_tile = 0;
@@ -169,7 +169,7 @@ ossimRefPtr<ossimImageData>
    {
      std::cout << "WAIT LOCK: " << tile_rect << std::endl;
    }
-   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_mutex);
+   std::lock_guard<std::mutex> lock(m_mutex);
 
    if (traceDebug())
    {
@@ -214,7 +214,7 @@ bool ossimImageHandlerMtAdaptor::getTile(ossimImageData* tile, ossim_uint32 rLev
       return false;
 
    // The sole purpose of the adapter is this mutex lock around the actual handler getTile:
-   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_mutex);
+   std::lock_guard<std::mutex> lock(m_mutex);
 
    // This is effectively a copy of ossimImageSource::getTile(ossimImageData*). It is reimplemented 
    // here to save two additional function calls:
diff --git a/src/parallel/ossimJob.cpp b/src/parallel/ossimJob.cpp
index f1da80d..c934b81 100644
--- a/src/parallel/ossimJob.cpp
+++ b/src/parallel/ossimJob.cpp
@@ -1,7 +1,20 @@
 #include <ossim/parallel/ossimJob.h>
 
+
+void ossimJob::start()
+{
+   setState(ossimJob_RUNNING);
+   run();
+   if(!(state() & ossimJob_CANCEL))
+   {
+      setState(ossimJob_FINISHED);
+   }
+}
+
 void ossimJob::setState(int value, bool on)
 {
+   std::shared_ptr<ossimJob> thisShared = getSharedFromThis();
+
    // we will need to make sure that the state flags are set properly
    // so if you turn on running then you can't have finished or ready turned onturned on
    // but can stil have cancel turned on
@@ -18,43 +31,41 @@ void ossimJob::setState(int value, bool on)
 
    int oldState     = 0;
    int currentState = 0;
-   ossimRefPtr<ossimJobCallback> callback;
+   std::shared_ptr<ossimJobCallback> callback;
 
    bool stateChangedFlag = false;
    {
-      OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_jobMutex);
+      std::lock_guard<std::mutex> lock(m_jobMutex);
       
       stateChangedFlag = newState != m_state;
       oldState = m_state;
       m_state = static_cast<State>(newState);
       currentState = m_state;
-      callback = m_callback.get();
+      callback = m_callback;
    }
    
-   if(stateChangedFlag&&callback.valid())
+   if(stateChangedFlag&&callback)
    {
-      if(callback.valid())
+      if(!(oldState&ossimJob_READY)&&
+         (currentState&ossimJob_READY))
       {
-         if(!(oldState&ossimJob_READY)&&
-            (currentState&ossimJob_READY))
-         {
-            callback->ready(this);
-         }
-         else if(!(oldState&ossimJob_RUNNING)&&
-                 (currentState&ossimJob_RUNNING))
-         {
-            callback->started(this);
-         }
-         else if(!(oldState&ossimJob_CANCEL)&&
-                 (currentState&ossimJob_CANCEL))
-         {
-            callback->canceled(this);
-         }
-         else if(!(oldState&ossimJob_FINISHED)&&
-                 (currentState&ossimJob_FINISHED))
-         {
-            callback->finished(this);
-         }
+         callback->ready(thisShared);
+      }
+      else if(!(oldState&ossimJob_RUNNING)&&
+              (currentState&ossimJob_RUNNING))
+      {
+         callback->started(thisShared);
+      }
+      else if(!(oldState&ossimJob_CANCEL)&&
+              (currentState&ossimJob_CANCEL))
+      {
+         callback->canceled(thisShared);
+      }
+      else if(!(oldState&ossimJob_FINISHED)&&
+              (currentState&ossimJob_FINISHED))
+      {
+         callback->finished(thisShared);
       }
    }
 }
+
diff --git a/src/parallel/ossimJobMultiThreadQueue.cpp b/src/parallel/ossimJobMultiThreadQueue.cpp
index b392bfd..2ca9fb7 100644
--- a/src/parallel/ossimJobMultiThreadQueue.cpp
+++ b/src/parallel/ossimJobMultiThreadQueue.cpp
@@ -1,33 +1,42 @@
 #include <ossim/parallel/ossimJobMultiThreadQueue.h>
 
-ossimJobMultiThreadQueue::ossimJobMultiThreadQueue(ossimJobQueue* q, ossim_uint32 nThreads)
-:m_jobQueue(q?q:new ossimJobQueue())
+ossimJobMultiThreadQueue::ossimJobMultiThreadQueue(std::shared_ptr<ossimJobQueue> q, 
+                                                   ossim_uint32 nThreads)
+:m_jobQueue(q?q:std::make_shared<ossimJobQueue>())
 {
    setNumberOfThreads(nThreads);
 }
-ossimJobQueue* ossimJobMultiThreadQueue::getJobQueue()
+
+ossimJobMultiThreadQueue::~ossimJobMultiThreadQueue()
+{
+   cancel();
+   waitForCompletion();
+   m_threadQueueList.clear();
+}
+
+std::shared_ptr<ossimJobQueue> ossimJobMultiThreadQueue::getJobQueue()
 {
-   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_mutex);
-   return m_jobQueue.get();
+   std::lock_guard<std::mutex> lock(m_mutex);
+   return m_jobQueue;
 }
-const ossimJobQueue* ossimJobMultiThreadQueue::getJobQueue()const
+const std::shared_ptr<ossimJobQueue> ossimJobMultiThreadQueue::getJobQueue()const
 {
-   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_mutex);
-   return m_jobQueue.get();
+   std::lock_guard<std::mutex> lock(m_mutex);
+   return m_jobQueue;
 }
-void ossimJobMultiThreadQueue::setQueue(ossimJobQueue* q)
+void ossimJobMultiThreadQueue::setJobQueue(std::shared_ptr<ossimJobQueue> q)
 {
-   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_mutex);
+   std::lock_guard<std::mutex> lock(m_mutex);
    ossim_uint32 idx = 0;
    m_jobQueue = q;
    for(idx = 0; idx < m_threadQueueList.size(); ++idx)
    {
-      m_threadQueueList[idx]->setJobQueue(m_jobQueue.get());
+      m_threadQueueList[idx]->setJobQueue(m_jobQueue);
    }
 }
 void ossimJobMultiThreadQueue::setNumberOfThreads(ossim_uint32 nThreads)
 {
-   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_mutex);
+   std::lock_guard<std::mutex> lock(m_mutex);
    ossim_uint32 idx = 0;
    ossim_uint32 queueSize = m_threadQueueList.size();
    
@@ -35,8 +44,8 @@ void ossimJobMultiThreadQueue::setNumberOfThreads(ossim_uint32 nThreads)
    {
       for(idx = queueSize; idx < nThreads;++idx)
       {
-         ossimRefPtr<ossimJobThreadQueue> threadQueue = new ossimJobThreadQueue();
-         threadQueue->setJobQueue(m_jobQueue.get());
+         std::shared_ptr<ossimJobThreadQueue> threadQueue = std::make_shared<ossimJobThreadQueue>();
+         threadQueue->setJobQueue(m_jobQueue);
          m_threadQueueList.push_back(threadQueue);
       }
    }
@@ -53,14 +62,14 @@ void ossimJobMultiThreadQueue::setNumberOfThreads(ossim_uint32 nThreads)
 
 ossim_uint32 ossimJobMultiThreadQueue::getNumberOfThreads() const
 {
-   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_mutex);
+   std::lock_guard<std::mutex> lock(m_mutex);
    return static_cast<ossim_uint32>( m_threadQueueList.size() );
 }
 
 ossim_uint32 ossimJobMultiThreadQueue::numberOfBusyThreads()const
 {
    ossim_uint32 result = 0;
-   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_mutex);
+   std::lock_guard<std::mutex> lock(m_mutex);
    ossim_uint32 idx = 0;
    ossim_uint32 queueSize = m_threadQueueList.size();
    for(idx = 0; idx < queueSize;++idx)
@@ -72,7 +81,7 @@ ossim_uint32 ossimJobMultiThreadQueue::numberOfBusyThreads()const
 
 bool ossimJobMultiThreadQueue::areAllThreadsBusy()const
 {
-   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_mutex);
+   std::lock_guard<std::mutex> lock(m_mutex);
    ossim_uint32 idx = 0;
    ossim_uint32 queueSize = m_threadQueueList.size();
    for(idx = 0; idx < queueSize;++idx)
@@ -87,7 +96,7 @@ bool ossimJobMultiThreadQueue::hasJobsToProcess()const
 {
    bool result = false;
    {
-      OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_mutex);
+      std::lock_guard<std::mutex> lock(m_mutex);
       ossim_uint32 queueSize = m_threadQueueList.size();
       ossim_uint32 idx = 0;
       for(idx = 0; ((idx<queueSize)&&!result);++idx)
@@ -99,3 +108,19 @@ bool ossimJobMultiThreadQueue::hasJobsToProcess()const
    return result;
 }
 
+void ossimJobMultiThreadQueue::cancel()
+{
+   for(auto thread:m_threadQueueList)
+   {
+      thread->cancel();
+   }
+}
+
+void ossimJobMultiThreadQueue::waitForCompletion()
+{
+   for(auto thread:m_threadQueueList)
+   {
+      thread->waitForCompletion();
+   }
+}
+
diff --git a/src/parallel/ossimJobQueue.cpp b/src/parallel/ossimJobQueue.cpp
index ffb780b..e7bda97 100644
--- a/src/parallel/ossimJobQueue.cpp
+++ b/src/parallel/ossimJobQueue.cpp
@@ -2,17 +2,17 @@
 
 #include <algorithm> /* for std::find */
 
-
 ossimJobQueue::ossimJobQueue()
 {
 }
 
-void ossimJobQueue::add(ossimJob* job, bool guaranteeUniqueFlag)
+void ossimJobQueue::add(std::shared_ptr<ossimJob> job, 
+                        bool guaranteeUniqueFlag)
 {
-   ossimRefPtr<Callback> cb;
+   std::shared_ptr<Callback> cb;
    {
       {
-         OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_jobQueueMutex);
+         std::lock_guard<std::mutex> lock(m_jobQueueMutex);
          
          if(guaranteeUniqueFlag)
          {
@@ -22,95 +22,95 @@ void ossimJobQueue::add(ossimJob* job, bool guaranteeUniqueFlag)
                return;
             }
          }
-         cb = m_callback.get();
+         cb = m_callback;
       }
-      if(cb.valid()) cb->adding(this, job);
+      if(cb) cb->adding(getSharedFromThis(), job);
       
       job->ready();
       m_jobQueueMutex.lock();
       m_jobQueue.push_back(job);
       m_jobQueueMutex.unlock();
    }
-   if(cb.valid())
+   if(cb)
    {
-      cb->added(this, job);
+      cb->added(getSharedFromThis(), job);
    }
    m_block.set(true);
 }
 
-ossimRefPtr<ossimJob> ossimJobQueue::removeByName(const ossimString& name)
+std::shared_ptr<ossimJob> ossimJobQueue::removeByName(const ossimString& name)
 {
-   ossimRefPtr<ossimJob> result;
-   ossimRefPtr<Callback> cb;
+   std::shared_ptr<ossimJob> result;
+   std::shared_ptr<Callback> cb;
    if(name.empty()) return result;
    {
-      OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_jobQueueMutex);
+      std::lock_guard<std::mutex> lock(m_jobQueueMutex);
       ossimJob::List::iterator iter = findByName(name);
       if(iter!=m_jobQueue.end())
       {
          result = *iter;
          m_jobQueue.erase(iter);
       }
-      cb = m_callback.get();
+      cb = m_callback;
    }      
    m_block.set(!m_jobQueue.empty());
    
-   if(cb.valid()&&result.valid())
+   if(cb&&result)
    {
-      cb->removed(this, result.get());
+      cb->removed(getSharedFromThis(), result);
    }
    return result;
 }
-ossimRefPtr<ossimJob> ossimJobQueue::removeById(const ossimString& id)
+std::shared_ptr<ossimJob> ossimJobQueue::removeById(const ossimString& id)
 {
-   ossimRefPtr<ossimJob> result;
-   ossimRefPtr<Callback> cb;
+   std::shared_ptr<ossimJob> result;
+   std::shared_ptr<Callback> cb;
    if(id.empty()) return result;
    {
-      OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_jobQueueMutex);
+      std::lock_guard<std::mutex> lock(m_jobQueueMutex);
       ossimJob::List::iterator iter = findById(id);
       if(iter!=m_jobQueue.end())
       {
          result = *iter;
          m_jobQueue.erase(iter);
       }
-      cb = m_callback.get();
+      cb = m_callback;
       m_block.set(!m_jobQueue.empty());
    }
-   if(cb.valid()&&result.valid())
+   if(cb&&result)
    {
-      cb->removed(this, result.get());
+      cb->removed(getSharedFromThis(), result);
    }
    return result;
 }
 
-void ossimJobQueue::remove(const ossimJob* Job)
+void ossimJobQueue::remove(const std::shared_ptr<ossimJob> job)
 {
-   ossimRefPtr<ossimJob> removedJob;
-   ossimRefPtr<Callback> cb;
+   std::shared_ptr<ossimJob> removedJob;
+   std::shared_ptr<Callback> cb;
    {
-      OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_jobQueueMutex);
-      ossimJob::List::iterator iter = std::find(m_jobQueue.begin(), m_jobQueue.end(), Job);
+      std::lock_guard<std::mutex> lock(m_jobQueueMutex);
+      ossimJob::List::iterator iter = std::find(m_jobQueue.begin(), m_jobQueue.end(), job);
       if(iter!=m_jobQueue.end())
       {
          removedJob = (*iter);
          m_jobQueue.erase(iter);
       }
-      cb = m_callback.get();
+      cb = m_callback;
    }
-   if(cb.valid()&&removedJob.valid())
+   if(cb&&removedJob)
    {
-      cb->removed(this, removedJob.get());
+      cb->removed(getSharedFromThis(), removedJob);
    }
 }
 
 void ossimJobQueue::removeStoppedJobs()
 {
    ossimJob::List removedJobs;
-   ossimRefPtr<Callback> cb;
+   std::shared_ptr<Callback> cb;
    {
-      OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_jobQueueMutex);
-      cb = m_callback.get();
+      std::lock_guard<std::mutex> lock(m_jobQueueMutex);
+      cb = m_callback;
       ossimJob::List::iterator iter = m_jobQueue.begin();
       while(iter!=m_jobQueue.end())
       {
@@ -127,12 +127,12 @@ void ossimJobQueue::removeStoppedJobs()
    }
    if(!removedJobs.empty())
    {
-      if(cb.valid())
+      if(cb)
       {
          ossimJob::List::iterator iter = removedJobs.begin();
          while(iter!=removedJobs.end())
          {
-            cb->removed(this, (*iter).get());
+            cb->removed(getSharedFromThis(), (*iter));
             ++iter;
          }
       }
@@ -143,23 +143,22 @@ void ossimJobQueue::removeStoppedJobs()
 void ossimJobQueue::clear()
 {
    ossimJob::List removedJobs(m_jobQueue);
-   ossimRefPtr<Callback> cb;
+   std::shared_ptr<Callback> cb;
    {
-      OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_jobQueueMutex);
+      std::lock_guard<std::mutex> lock(m_jobQueueMutex);
       m_jobQueue.clear();
-      cb = m_callback.get();
+      cb = m_callback;
    }
-   if(cb.valid())
+   if(cb)
    {
-      // ossim_uint32 idx = 0;
       for(ossimJob::List::iterator iter=removedJobs.begin();iter!=removedJobs.end();++iter)
       {
-         cb->removed(this, (*iter).get());
+         cb->removed(getSharedFromThis(), (*iter));
       }
    }
 }
 
-ossimRefPtr<ossimJob> ossimJobQueue::nextJob(bool blockIfEmptyFlag)
+std::shared_ptr<ossimJob> ossimJobQueue::nextJob(bool blockIfEmptyFlag)
 {
    m_jobQueueMutex.lock();
    bool emptyFlag = m_jobQueue.empty();
@@ -169,8 +168,8 @@ ossimRefPtr<ossimJob> ossimJobQueue::nextJob(bool blockIfEmptyFlag)
       m_block.block();
    }
    
-   ossimRefPtr<ossimJob> result;
-   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_jobQueueMutex);
+   std::shared_ptr<ossimJob> result;
+   std::lock_guard<std::mutex> lock(m_jobQueueMutex);
    
    if (m_jobQueue.empty())
    {
@@ -191,6 +190,7 @@ ossimRefPtr<ossimJob> ossimJobQueue::nextJob(bool blockIfEmptyFlag)
       m_jobQueue.erase(iter);
    }
    m_block.set(!m_jobQueue.empty());
+
    return result;
 }
 void ossimJobQueue::releaseBlock()
@@ -199,7 +199,7 @@ void ossimJobQueue::releaseBlock()
 }
 bool ossimJobQueue::isEmpty()const
 {
-   // OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_jobQueueMutex);
+   // std::lock_guard<std::mutex> lock(m_jobQueueMutex);
    // return m_jobQueue.empty();
    m_jobQueueMutex.lock();
    bool result =  m_jobQueue.empty();
@@ -209,7 +209,7 @@ bool ossimJobQueue::isEmpty()const
 
 ossim_uint32 ossimJobQueue::size()
 {
-   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_jobQueueMutex);
+   std::lock_guard<std::mutex> lock(m_jobQueueMutex);
    return (ossim_uint32) m_jobQueue.size();
 }
 
@@ -243,40 +243,45 @@ ossimJob::List::iterator ossimJobQueue::findByName(const ossimString& name)
    return m_jobQueue.end();
 }
 
-ossimJob::List::iterator ossimJobQueue::findByPointer(const ossimJob* job)
+ossimJob::List::iterator ossimJobQueue::findByPointer(const std::shared_ptr<ossimJob> job)
 {
    return std::find(m_jobQueue.begin(),
                     m_jobQueue.end(),
                     job);
 }
 
-ossimJob::List::iterator ossimJobQueue::findByNameOrPointer(const ossimJob* job)
+ossimJob::List::iterator ossimJobQueue::findByNameOrPointer(const std::shared_ptr<ossimJob> job)
 {
    ossimString n = job->name();
-   ossimJob::List::iterator iter = m_jobQueue.begin();
-   while(iter != m_jobQueue.end())
-   {
-      if((*iter).get() == job)
-      {
-         return iter;
-      }
-      else if((!n.empty())&&
-              (job->name() == (*iter)->name()))
-      {
-         return iter;
-      }
-      ++iter;
-   }  
+   ossimJob::List::iterator iter = std::find_if(m_jobQueue.begin(), m_jobQueue.end(), [n, job](const std::shared_ptr<ossimJob> jobIter){
+      bool result = (jobIter == job);
+      if(!result&&!n.empty()) result = jobIter->name() == n;
+      return result;
+   });
+   // ossimJob::List::iterator iter = m_jobQueue.begin();
+   // while(iter != m_jobQueue.end())
+   // {
+   //    if((*iter) == job)
+   //    {
+   //       return iter;
+   //    }
+   //    else if((!n.empty())&&
+   //            (job->name() == (*iter)->name()))
+   //    {
+   //       return iter;
+   //    }
+   //    ++iter;
+//   }  
    
-   return m_jobQueue.end();
+   return iter;
 }
 
-bool ossimJobQueue::hasJob(ossimJob* job)
+bool ossimJobQueue::hasJob(std::shared_ptr<ossimJob> job)
 {
    ossimJob::List::const_iterator iter = m_jobQueue.begin();
    while(iter != m_jobQueue.end())
    {
-      if(job == (*iter).get())
+      if(job == (*iter))
       {
          return true;
       }
@@ -286,14 +291,14 @@ bool ossimJobQueue::hasJob(ossimJob* job)
    return false;
 }
 
-void ossimJobQueue::setCallback(Callback* c)
+void ossimJobQueue::setCallback(std::shared_ptr<Callback> c)
 {
-   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_jobQueueMutex);
+   std::lock_guard<std::mutex> lock(m_jobQueueMutex);
    m_callback = c;
 }
 
-ossimJobQueue::Callback* ossimJobQueue::callback()
+std::shared_ptr<ossimJobQueue::Callback> ossimJobQueue::callback()
 {
-   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_jobQueueMutex);
-   return m_callback.get();
+   std::lock_guard<std::mutex> lock(m_jobQueueMutex);
+   return m_callback;
 }
diff --git a/src/parallel/ossimJobThreadQueue.cpp b/src/parallel/ossimJobThreadQueue.cpp
index f1a0de2..dd583e7 100644
--- a/src/parallel/ossimJobThreadQueue.cpp
+++ b/src/parallel/ossimJobThreadQueue.cpp
@@ -1,117 +1,104 @@
-#include<ossim/parallel/ossimJobThreadQueue.h>
-
-ossimJobThreadQueue::ossimJobThreadQueue(ossimJobQueue* jqueue)
+#include <ossim/parallel/ossimJobThreadQueue.h>
+#include <cstddef> // for std::nullptr
+ossimJobThreadQueue::ossimJobThreadQueue(std::shared_ptr<ossimJobQueue> jqueue)
 :m_doneFlag(false)
 {
    setJobQueue(jqueue);    
 }
-void ossimJobThreadQueue::setJobQueue(ossimJobQueue* jqueue)
+void ossimJobThreadQueue::setJobQueue(std::shared_ptr<ossimJobQueue> jqueue)
 {
-   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_threadMutex);
+   std::lock_guard<std::mutex> lock(m_threadMutex);
    
    if (m_jobQueue == jqueue) return;
    
-   if(isRunning())
-   {
-      ossimRefPtr<ossimJobQueue> jobQueueTemp = m_jobQueue;
-      m_jobQueue = jqueue;
-      if(jobQueueTemp.valid())
-      {
-         jobQueueTemp->releaseBlock();
-      }
-   }
-   else 
+   pause();
+   while(isRunning()&&!isPaused())
    {
-      m_jobQueue = jqueue;
+      m_jobQueue->releaseBlock();
    }
-   
-   startThreadForQueue();
+   m_jobQueue = jqueue;
+   resume();
+
+   if(m_jobQueue) startThreadForQueue();
 }
 
-ossimJobQueue* ossimJobThreadQueue::getJobQueue() 
+std::shared_ptr<ossimJobQueue> ossimJobThreadQueue::getJobQueue() 
 { 
-   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_threadMutex);
-   return m_jobQueue.get(); 
+   std::lock_guard<std::mutex> lock(m_threadMutex);
+   return m_jobQueue; 
 }
 
-const ossimJobQueue* ossimJobThreadQueue::getJobQueue() const 
+const std::shared_ptr<ossimJobQueue> ossimJobThreadQueue::getJobQueue() const 
 { 
-   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_threadMutex);
-   return m_jobQueue.get(); 
+   std::lock_guard<std::mutex> lock(m_threadMutex);
+   return m_jobQueue; 
 }
 
-ossimRefPtr<ossimJob> ossimJobThreadQueue::currentJob() 
+std::shared_ptr<ossimJob> ossimJobThreadQueue::currentJob() 
 { 
-   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_threadMutex);
+   std::lock_guard<std::mutex> lock(m_threadMutex);
    return m_currentJob; 
 }
 
 void ossimJobThreadQueue::cancelCurrentJob()
 {
-   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_threadMutex);
-   if(m_currentJob.valid())
+   std::lock_guard<std::mutex> lock(m_threadMutex);
+   if(m_currentJob)
    {
       m_currentJob->cancel();
    }
 }
 bool ossimJobThreadQueue::isValidQueue()const
 {
-   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_threadMutex);
-   return m_jobQueue.valid();
+   std::lock_guard<std::mutex> lock(m_threadMutex);
+   return (m_jobQueue!=nullptr);
 }
 
 void ossimJobThreadQueue::run()
 {
    bool firstTime = true;
    bool validQueue = true;
-   ossimRefPtr<ossimJob> job;
+   std::shared_ptr<ossimJob> job;
    do
    {
+      interrupt();
       // osg::notify(osg::NOTICE)<<"In thread loop "<<this<<std::endl;
       validQueue = isValidQueue();
       job = nextJob();
-      if (job.valid()&&!m_doneFlag)
+      if (job&&!m_doneFlag)
       {
          {
-            OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_threadMutex);
+            std::lock_guard<std::mutex> lock(m_threadMutex);
             m_currentJob = job;
          }
          
          // if the job is ready to execute
          if(job->isReady())
          {
-            job->resetState(ossimJob::ossimJob_RUNNING);
             job->start();
          }
          {            
-            OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_threadMutex);
+            std::lock_guard<std::mutex> lock(m_threadMutex);
             m_currentJob = 0;
          }
-         job->setState(ossimJob::ossimJob_FINISHED);
-         job = 0;
+         job.reset();
       }
       
       if (firstTime)
       {
-         // do a yield to get round a peculiar thread hang when testCancel() is called 
-         // in certain cirumstances - of which there is no particular pattern.
-         YieldCurrentThread();
+         ossim::Thread::yieldCurrentThread();
          firstTime = false;
       }
    } while (!m_doneFlag&&validQueue);
    
-   if(job.valid()&&m_doneFlag&&job->isReady())
-   {
-      {            
-         OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_threadMutex);
-         m_currentJob = 0;
-      }
-      job->cancel();
-   }
    {            
-      OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_threadMutex);
+      std::lock_guard<std::mutex> lock(m_threadMutex);
       m_currentJob = 0;
    }
+   if(job&&m_doneFlag&&job->isReady())
+   {
+      job->cancel();
+   }
    job = 0;
 }
 
@@ -128,42 +115,42 @@ void ossimJobThreadQueue::setDone(bool done)
    if(done)
    {
       {
-         OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_threadMutex);
-         if (m_currentJob.valid())
+         std::lock_guard<std::mutex> lock(m_threadMutex);
+         if (m_currentJob)
             m_currentJob->release();
       }
       
-      if (m_jobQueue.valid())
+      if (m_jobQueue)
          m_jobQueue->releaseBlock();
    }
 }
 
 bool ossimJobThreadQueue::isDone() const 
 { 
-   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_threadMutex);
+   std::lock_guard<std::mutex> lock(m_threadMutex);
    return m_doneFlag; 
 }
 
 bool ossimJobThreadQueue::isProcessingJob()const
 {
-   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_threadMutex);
-   return m_currentJob.valid();
+   std::lock_guard<std::mutex> lock(m_threadMutex);
+   return (m_currentJob!=nullptr);
 }
 
-int ossimJobThreadQueue::cancel()
+void ossimJobThreadQueue::cancel()
 {
    
    if( isRunning() )
    {
       {
-         OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_threadMutex);
+         std::lock_guard<std::mutex> lock(m_threadMutex);
          m_doneFlag = true;
-         if (m_currentJob.valid())
+         if (m_currentJob)
          {
             m_currentJob->cancel();
          }
          
-         if (m_jobQueue.valid()) 
+         if (m_jobQueue) 
          {
             m_jobQueue->releaseBlock();
          }
@@ -174,27 +161,22 @@ int ossimJobThreadQueue::cancel()
       {
 #if 1
          {
-            OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_threadMutex);
+            std::lock_guard<std::mutex> lock(m_threadMutex);
             
-            if (m_jobQueue.valid()) 
+            if (m_jobQueue) 
             {
                m_jobQueue->releaseBlock();
             }
          }
 #endif
-// RP - The extra cancel and join resolves a bug where threads were not being
-// closed out and OS thread limits are quickly hit
-         OpenThreads::Thread::YieldCurrentThread();
-	 OpenThreads::Thread::cancel();
+         ossim::Thread::yieldCurrentThread();
       }
    }
-   OpenThreads::Thread::join();
-   return OpenThreads::Thread::cancel();
 }
 
 bool ossimJobThreadQueue::isEmpty()const
 {
-   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_threadMutex);
+   std::lock_guard<std::mutex> lock(m_threadMutex);
    return m_jobQueue->isEmpty();
 }
 
@@ -205,15 +187,11 @@ ossimJobThreadQueue::~ossimJobThreadQueue()
 
 void ossimJobThreadQueue::startThreadForQueue()
 {
-   if(m_jobQueue.valid())
+   if(m_jobQueue)
    {
       if(!isRunning())
       {
          start();
-         while(!isRunning()) // wait for the thread to start running
-         {
-            OpenThreads::Thread::YieldCurrentThread();
-         }
       }
    }
 }
@@ -222,23 +200,23 @@ bool ossimJobThreadQueue::hasJobsToProcess()const
 {
    bool result = false;
    {
-      OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_threadMutex);
-      result = !m_jobQueue->isEmpty()||m_currentJob.valid();
+      std::lock_guard<std::mutex> lock(m_threadMutex);
+      result = (!m_jobQueue->isEmpty()||m_currentJob);
    }
    
    return result;
 }
 
-ossimRefPtr<ossimJob> ossimJobThreadQueue::nextJob()
+std::shared_ptr<ossimJob> ossimJobThreadQueue::nextJob()
 {
-   ossimRefPtr<ossimJob> job;
+   std::shared_ptr<ossimJob> job;
    m_threadMutex.lock();
-   ossimRefPtr<ossimJobQueue> jobQueue = m_jobQueue;
-   bool checkIfValid = !m_doneFlag&&jobQueue.valid();
+   std::shared_ptr<ossimJobQueue> jobQueue = m_jobQueue;
+   bool checkIfValid = !m_doneFlag&&jobQueue;
    m_threadMutex.unlock();
    if(checkIfValid)
    {
-      return jobQueue->nextJob(true);
+      job = jobQueue->nextJob(true);
    }
-   return 0;
+   return job;
 }
diff --git a/src/parallel/ossimMultiThreadSequencer.cpp b/src/parallel/ossimMultiThreadSequencer.cpp
index 1c3301e..951de76 100644
--- a/src/parallel/ossimMultiThreadSequencer.cpp
+++ b/src/parallel/ossimMultiThreadSequencer.cpp
@@ -16,7 +16,6 @@
 #include <ossim/parallel/ossimMtDebug.h>
 #include <ossim/base/ossimIrect.h>
 #include <ossim/base/ossimTimer.h>
-
 static const ossim_uint32 DEFAULT_MAX_TILE_CACHE_FACTOR = 8; // Must be > 1
 
 ossimMtDebug* ossimMtDebug::m_instance = NULL;
@@ -25,7 +24,7 @@ ossimMtDebug* ossimMtDebug::m_instance = NULL;
 // Job's start method performs actual getTile in a thread on cloned chain and saves the result
 // in the sequencer's results cache.
 //*************************************************************************************************
-void ossimMultiThreadSequencer::ossimGetTileJob::start()
+void ossimMultiThreadSequencer::ossimGetTileJob::run()
 {
    running();
    if (m_sequencer.d_debugEnabled)
@@ -94,7 +93,7 @@ ossimMultiThreadSequencer::ossimMultiThreadSequencer(ossimImageSource* input,
    m_inputChain(0),
    m_jobMtQueue(0),
    m_numThreads (num_threads),
-   m_callback(new ossimGetTileCallback()),
+   m_callback(std::make_shared<ossimGetTileCallback>()),
    m_nextTileID (0),
    m_tileCache(),                       
    m_maxCacheSize (DEFAULT_MAX_TILE_CACHE_FACTOR * num_threads),
@@ -125,7 +124,6 @@ ossimMultiThreadSequencer::ossimMultiThreadSequencer(ossimImageSource* input,
 
    // The base-class' initialize() method should have been called by the base class constructor
    // unless somebody moved it!
-   OpenThreads::Thread::Init();
    m_nextJobBlock.release();
    m_getTileBlock.release();
    ossimTimer::instance()->setStartTick();
@@ -138,7 +136,7 @@ ossimMultiThreadSequencer::~ossimMultiThreadSequencer()
 {
    m_inputChain = 0; //!< Same as base class' theInputConnection
    m_jobMtQueue = 0;
-   m_callback = 0;
+   m_callback.reset();
 }
 
 //*************************************************************************************************
@@ -196,15 +194,15 @@ void ossimMultiThreadSequencer::setToStartOfSequence()
    //// EXPERIMENTAL -- Fetch the first N tiles sequentially:
    for (ossim_uint32 i=0; i<m_numThreads; ++i)
    {
-      ossimGetTileJob* job = new ossimGetTileJob(m_nextTileID++, i, *this);
-      job->setCallback(m_callback.get());
+      std::shared_ptr<ossimGetTileJob> job = std::make_shared<ossimGetTileJob>(m_nextTileID++, i, *this);
+      job->setCallback(m_callback);
       job->t_launchNewJob = false;
       job->start();
    }
 
    // Set up the job queue and fill it with first N jobs:
    ossim_uint32 num_jobs_to_launch =  min<ossim_uint32>(m_numThreads, m_totalNumberOfTiles);
-   ossimRefPtr<ossimJobQueue> jobQueue = new ossimJobQueue();
+   std::shared_ptr<ossimJobQueue> jobQueue = std::make_shared<ossimJobQueue>();
    for (ossim_uint32 chain_id=0; chain_id<num_jobs_to_launch; ++chain_id)
    {
       if (d_debugEnabled)
@@ -214,15 +212,15 @@ void ossimMultiThreadSequencer::setToStartOfSequence()
          print(s);
       }
 
-      ossimGetTileJob* job = new ossimGetTileJob(m_nextTileID++, chain_id, *this);
-      job->setCallback(m_callback.get());
+      std::shared_ptr<ossimGetTileJob> job = std::make_shared<ossimGetTileJob>(m_nextTileID++, chain_id, *this);
+      job->setCallback(m_callback);
       jobQueue->add(job, false);
    }
 
-   // Initialize the multi-thread queue. Note the setQueue is done after construction as it was 
+   // Initialize the multi-thread queue. Note the setJobQueue is done after construction as it was 
    // crashing do to jobs being launched during init:
-   m_jobMtQueue = new ossimJobMultiThreadQueue(0, num_jobs_to_launch);
-   m_jobMtQueue->setQueue(jobQueue.get());
+   m_jobMtQueue = std::make_shared<ossimJobMultiThreadQueue>(nullptr, num_jobs_to_launch);
+   m_jobMtQueue->setJobQueue(jobQueue);
 }
 
 
@@ -338,7 +336,7 @@ void ossimMultiThreadSequencer::setNumberOfThreads(ossim_uint32 num_threads)
    if (m_inputChain.valid())
       m_inputChain->setNumberOfThreads(num_threads);
 
-   if (m_jobMtQueue.valid() && m_jobMtQueue->hasJobsToProcess())
+   if (m_jobMtQueue && m_jobMtQueue->hasJobsToProcess())
       m_jobMtQueue->getJobQueue()->clear();
 
    m_nextTileID = 0; // effectively resets this sequencer
@@ -379,7 +377,7 @@ void ossimMultiThreadSequencer::setTileInCache(ossim_uint32 tile_id,
 {
    if (d_timeMetricsEnabled)
       d_t1 = ossimTimer::instance()->time_s(); 
-   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_cacheMutex);
+   std::lock_guard<std::mutex> lock(m_cacheMutex);
    if (d_timeMetricsEnabled)
       d_idleTime4 += ossimTimer::instance()->time_s() - d_t1; 
 
@@ -447,12 +445,12 @@ void ossimMultiThreadSequencer::nextJob(ossim_uint32 chain_id)
    // Job queue will receive pointer into ossimRefPtr so no leak here:
    if (d_timeMetricsEnabled)
       d_t1 = ossimTimer::instance()->time_s(); 
-   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_jobMutex);
+   std::lock_guard<std::mutex> lock(m_jobMutex);
    if (d_timeMetricsEnabled)
       d_idleTime6 += ossimTimer::instance()->time_s() - d_t1; 
 
-   ossimGetTileJob* job = new ossimGetTileJob(m_nextTileID++, chain_id, *this);
-   job->setCallback(m_callback.get());
+   std::shared_ptr<ossimGetTileJob> job = std::make_shared<ossimGetTileJob>(m_nextTileID++, chain_id, *this);
+   job->setCallback(m_callback);
    m_jobMtQueue->getJobQueue()->add(job);
 }
 
@@ -461,7 +459,7 @@ void ossimMultiThreadSequencer::nextJob(ossim_uint32 chain_id)
 //*************************************************************************************************
 void ossimMultiThreadSequencer::print(ostringstream& msg) const
 {
-   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(d_printMutex);
+   std::lock_guard<std::mutex> lock(d_printMutex);
    cerr << msg.str() << endl;
 }
 double ossimMultiThreadSequencer::handlerGetTileT() 
diff --git a/src/plugin/ossimDynamicLibrary.cpp b/src/plugin/ossimDynamicLibrary.cpp
index ea76ff7..d25606e 100644
--- a/src/plugin/ossimDynamicLibrary.cpp
+++ b/src/plugin/ossimDynamicLibrary.cpp
@@ -45,7 +45,10 @@ bool ossimDynamicLibrary::load(const ossimString& name)
 #  if defined(__WIN32__) || defined(_WIN32)
    theLibrary = LoadLibrary(libraryName.c_str());
 #  else 
-   theLibrary = dlopen(libraryName.c_str(), RTLD_LAZY);
+   //theLibrary = dlopen(libraryName.c_str(), RTLD_LAZY|RTLD_LOCAL);
+   // Use of RTLD_GLOBAL fixes CSM3 plugin with MSP loading CSM plugins, but requires unique
+   // variable and method names in all *PluginInit.cpp code.
+   theLibrary = dlopen(libraryName.c_str(), RTLD_LAZY|RTLD_GLOBAL);
 #endif
 
    if (isLoaded())
diff --git a/src/projection/ossimQuickbirdRpcModel.cpp b/src/projection/ossimQuickbirdRpcModel.cpp
index becd455..3783640 100644
--- a/src/projection/ossimQuickbirdRpcModel.cpp
+++ b/src/projection/ossimQuickbirdRpcModel.cpp
@@ -15,6 +15,7 @@
 #include <ossim/projection/ossimQuickbirdRpcModel.h>
 #include <ossim/base/ossimException.h>
 #include <ossim/base/ossimNotify.h>
+#include <ossim/base/ossim2dTo2dShiftTransform.h>
 #include <ossim/support_data/ossimQuickbirdRpcHeader.h>
 #include <ossim/support_data/ossimQuickbirdTile.h>
 #include <ossim/support_data/ossimNitfFile.h>
@@ -22,12 +23,14 @@
 #include <ossim/support_data/ossimNitfImageHeader.h>
 #include <ossim/support_data/ossimNitfRpcBase.h>
 #include <ossim/support_data/ossimNitfUse00aTag.h>
+#include <ossim/support_data/ossimNitfIchipbTag.h>
 #include <ossim/support_data/ossimNitfPiaimcTag.h>
 #include <ossim/imaging/ossimTiffTileSource.h>
 #include <ossim/imaging/ossimQbTileFilesHandler.h>
 
 static const char* RPC00A_TAG = "RPC00A";
 static const char* RPC00B_TAG = "RPC00B";
+static const char* ICHIPB_TAG = "ICHIPB";
 static const char* PIAIMC_TAG = "PIAIMC";
 static const char* USE00A_TAG = "USE00A";
 
@@ -145,13 +148,16 @@ bool ossimQuickbirdRpcModel::parseNitfFile(const ossimFilename& file)
 
    theImageClipRect = ih->getImageRect();
  
-   // Give preference to external RPC data file:
-   bool useInternalRpcTags = false;
-   if(!parseRpcData(file))
-      useInternalRpcTags = true;
-   if (!parseTileData(file))
-      return false;
- 
+   // Give preference to external RPC data file. Only consider external tiling data if RPC is 
+   // provided externally, otherwise expect ICHIPB in NITF:
+   bool useInternalRpcTags = true;
+   if (parseRpcData(file))
+   {
+      useInternalRpcTags = false;
+      if (!parseTileData(file))
+         return false;
+   }
+
    // Check for IMD (metadata) file:
    parseMetaData(file);
 
@@ -262,9 +268,11 @@ bool ossimQuickbirdRpcModel::parseTiffFile(const ossimFilename& file)
 
    parseMetaData(file);
 
+   // TIFF format expects the RPC and TILE info to be provided externally:
    if (!parseRpcData(file))
       return false;
 
+   // If no TIL data present, assumes full image:
    if (!parseTileData(file))
       return false;
 
@@ -358,8 +366,11 @@ bool ossimQuickbirdRpcModel::parseTileData(const ossimFilename& image_file)
 {
    ossimFilename tileFile (image_file);
    tileFile.setExtension("TIL");
-  if (!findSupportFile(tileFile))
-      return false;
+
+   // The TIL file is optional. Consider the image to be the full image if not present:
+   if (!findSupportFile(tileFile))
+      return true;
+
    ossimQuickbirdTile tileHdr;
    if(!tileHdr.open(tileFile))
       return false;
@@ -367,23 +378,31 @@ bool ossimQuickbirdRpcModel::parseTileData(const ossimFilename& image_file)
    ossimQuickbirdTileInfo info;
    if(!tileHdr.getInfo(info, image_file.file()))
       return false;
-   if((info.theUlXOffset != OSSIM_INT_NAN) && (info.theUlYOffset != OSSIM_INT_NAN) &&
-      (info.theLrXOffset != OSSIM_INT_NAN) && (info.theLrYOffset != OSSIM_INT_NAN) &&
-      (info.theLlXOffset != OSSIM_INT_NAN) && (info.theLlYOffset != OSSIM_INT_NAN) &&
-      (info.theUrXOffset != OSSIM_INT_NAN) && (info.theUrYOffset != OSSIM_INT_NAN))
-   {
-      theImageClipRect = ossimIrect(ossimIpt(info.theUlXOffset, info.theUlYOffset),
-                                    ossimIpt(info.theUrXOffset, info.theUrYOffset),
-                                    ossimIpt(info.theLrXOffset, info.theLrYOffset),
-                                    ossimIpt(info.theLlXOffset, info.theLlYOffset));
-   }
-   else if ((info.theUlXOffset != OSSIM_INT_NAN) && (info.theUlYOffset != OSSIM_INT_NAN) &&
-      (theImageClipRect.width() != OSSIM_INT_NAN) && (theImageClipRect.height() != OSSIM_INT_NAN))
-   {
-      theImageClipRect = ossimIrect(info.theUlXOffset, info.theUlYOffset,
-                                    info.theUlXOffset+theImageClipRect.width()-1, 
-                                    info.theUlYOffset+theImageClipRect.height()-1);
-   }
+
+//   if((info.theUlXOffset != OSSIM_INT_NAN) && (info.theUlYOffset != OSSIM_INT_NAN) &&
+//      (info.theLrXOffset != OSSIM_INT_NAN) && (info.theLrYOffset != OSSIM_INT_NAN) &&
+//      (info.theLlXOffset != OSSIM_INT_NAN) && (info.theLlYOffset != OSSIM_INT_NAN) &&
+//      (info.theUrXOffset != OSSIM_INT_NAN) && (info.theUrYOffset != OSSIM_INT_NAN))
+//   {
+//      theImageClipRect = ossimIrect(ossimIpt(info.theUlXOffset, info.theUlYOffset),
+//                                    ossimIpt(info.theUrXOffset, info.theUrYOffset),
+//                                    ossimIpt(info.theLrXOffset, info.theLrYOffset),
+//                                    ossimIpt(info.theLlXOffset, info.theLlYOffset));
+//   }
+//   else if ((info.theUlXOffset != OSSIM_INT_NAN) && (info.theUlYOffset != OSSIM_INT_NAN) &&
+//      (theImageClipRect.width() != OSSIM_INT_NAN) && (theImageClipRect.height() != OSSIM_INT_NAN))
+//   {
+//      theImageClipRect = ossimIrect(info.theUlXOffset, info.theUlYOffset,
+//                                    info.theUlXOffset+theImageClipRect.width()-1,
+//                                    info.theUlYOffset+theImageClipRect.height()-1);
+//   }
+
+   // Define the RPC model's 2D transform for chipped imagery. Note that the TIL file will only
+   // define an offset, not a full affine.  Can only use the tile's UL corner:
+   ossimDpt ul (info.theUlXOffset, info.theUlYOffset);
+   if (!ul.hasNans())
+      setImageOffset(ul);
+      //theImageXform = new ossim2dTo2dShiftTransform(ul);
 
    return true;
 }
diff --git a/src/projection/ossimRpcModel.cpp b/src/projection/ossimRpcModel.cpp
index 2f8a58f..48f20f7 100644
--- a/src/projection/ossimRpcModel.cpp
+++ b/src/projection/ossimRpcModel.cpp
@@ -35,6 +35,10 @@ RTTI_DEF1(ossimRpcModel, "ossimRpcModel", ossimSensorModel);
 #include <sstream>
 #include <ossim/projection/ossimProjectionFactoryRegistry.h>
 
+#if OSSIM_HAS_JSONCPP
+#include <json/json.h>
+#endif
+
 //***
 // Define Trace flags for use within this file:
 //***
@@ -313,7 +317,6 @@ void ossimRpcModel::worldToLineSample(const ossimGpt& ground_point,
    // Now back out skew, scale, and offset adjustments:
    //***
    img_pt.line = U*(theLineScale+theIntrackScale) + theLineOffset + theIntrackOffset;
-   
    img_pt.samp = V*(theSampScale+theCrtrackScale) + theSampOffset + theCrtrackOffset;
 
    // if (traceExec())  ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimRpcModel::worldToLineSample(): returning..." << std::endl;
@@ -328,7 +331,6 @@ void ossimRpcModel::worldToLineSample(const ossimGpt& ground_point,
 void  ossimRpcModel::lineSampleToWorld(const ossimDpt& imagePoint,
                                        ossimGpt&       worldPoint) const
 {
-
 //---
 // Under debate... (drb 20130610)
 // this seems to be more accurate for the round trip
@@ -1397,3 +1399,142 @@ void ossimRpcModel::getRpcParameters(ossimRpcModel::rpcModelStruct& model) const
       model.type= 'B';
    }
 }
+
+void ossimRpcModel::setImageOffset(const ossimDpt& offset)
+{
+   theLineOffset -= offset.line;
+   theSampOffset -= offset.samp;
+
+   if (theImageClipRect.hasNans())
+      theImageClipRect = ossimDrect(0, 0, theImageSize.x-offset.x-1, theImageSize.y-offset.y-1);
+   else
+      theImageClipRect -= offset;
+}
+
+
+bool ossimRpcModel::toJSON(std::ostream& jsonStream) const
+{
+#if OSSIM_HAS_JSONCPP
+   Json::Value IMAGE;
+   IMAGE["ERRBIAS"]      = theBiasError;
+   IMAGE["ERRRAND"]      = theRandError;
+   IMAGE["LINEOFFSET"]   = (int)theLineOffset;
+   IMAGE["SAMPOFFSET"]   = (int)theSampOffset;
+   IMAGE["LATOFFSET"]    = theLatOffset;
+   IMAGE["LONGOFFSET"]   = theLonOffset;
+   IMAGE["HEIGHTOFFSET"] = theHgtOffset;
+   IMAGE["LINESCALE"]    = theLineScale;
+   IMAGE["SAMPSCALE"]    = theSampScale;
+   IMAGE["LATSCALE"]     = theLatScale;
+   IMAGE["LONGSCALE"]    = theLonScale;
+   IMAGE["HEIGHTSCALE"]  = theHgtScale;
+
+   // Preferred way to output coeff arrays:
+//   Json::Value LINENUMCOEF(Json::arrayValue);
+//   Json::Value LINEDENCOEF(Json::arrayValue);
+//   Json::Value SAMPNUMCOEF(Json::arrayValue);
+//   Json::Value SAMPDENCOEF(Json::arrayValue);
+//   for (int i=0; i<20; ++i)
+//   {
+//      LINENUMCOEF.append(theLineNumCoef[i]);
+//      LINEDENCOEF.append(theLineDenCoef[i]);
+//      SAMPNUMCOEF.append(theSampNumCoef[i]);
+//      SAMPDENCOEF.append(theSampDenCoef[i]);
+//   }
+
+   // Write coeffs as string list for JSON to XML converter to output properly:
+   ossimString LINENUMCOEF;
+   ossimString LINEDENCOEF;
+   ossimString SAMPNUMCOEF;
+   ossimString SAMPDENCOEF;
+   for (int i=0; i<20; ++i)
+   {
+      LINENUMCOEF += ossimString::toString(theLineNumCoef[i]) + " ";
+      LINEDENCOEF += ossimString::toString(theLineDenCoef[i]) + " ";
+      SAMPNUMCOEF += ossimString::toString(theSampNumCoef[i]) + " ";
+      SAMPDENCOEF += ossimString::toString(theSampDenCoef[i]) + " ";
+   }
+
+   Json::Value LINENUMCOEFList;
+   LINENUMCOEFList["LINENUMCOEF"] = LINENUMCOEF.string();
+   IMAGE["LINENUMCOEFList"] = LINENUMCOEFList;
+
+   Json::Value LINEDENCOEFList;
+   LINEDENCOEFList["LINEDENCOEF"] = LINEDENCOEF.string();
+   IMAGE["LINEDENCOEFList"] = LINEDENCOEFList;
+
+   Json::Value SAMPNUMCOEFList;
+   SAMPNUMCOEFList["SAMPNUMCOEF"] = SAMPNUMCOEF.string();
+   IMAGE["SAMPNUMCOEFList"] = SAMPNUMCOEFList;
+
+   Json::Value SAMPDENCOEFList;
+   SAMPDENCOEFList["SAMPDENCOEF"] = SAMPDENCOEF.string();
+   IMAGE["SAMPDENCOEFList"] = SAMPDENCOEFList;
+
+   Json::Value RPB;
+   RPB["SATID"] = "NOT_ASSIGNED";
+   RPB["BANDID"] = "NOT_ASSIGNED";
+   if (thePolyType == A)
+      RPB["SPECID"] = "RPC00A"; // Not sure this will work
+   else
+      RPB["SPECID"] = "RPC00B";
+   RPB["IMAGE"] = IMAGE;
+
+   Json::Value ISD;
+   ISD["RPB"] = RPB;
+
+   Json::Value root;
+   root["isd"] = ISD;
+   Json::StyledWriter writer;
+   jsonStream << writer.write(root);
+   return true;
+#else
+   jsonStream<<"Error: JSON format not supported."<<endl;
+   return false;
+#endif
+}
+
+bool ossimRpcModel::toRPB(ostream& out) const
+{
+   out<<"satId = \"NOT_ASSIGNED\";\n";
+   out<<"bandId = \"NOT_ASSIGNED\";\n";
+   out<<"SpecId = \"RPC00B\";\n";
+
+   out<<"BEGIN_GROUP = IMAGE\n";
+   out<<"\terrBias = "<<theBiasError<<";\n";
+   out<<"\terrRand = "<<theRandError<<";\n";
+   out<<"\tlineOffset = "<<(int)theLineOffset<<";\n";
+   out<<"\tsampOffset = "<<(int)theSampOffset<<";\n";
+   out<<"\tlatOffset = "<<theLatOffset<<";\n";
+   out<<"\tlongOffset = "<<theLonOffset<<";\n";
+   out<<"\theightOffset = "<<theHgtOffset<<";\n";
+   out<<"\tlineScale = "<<theLineScale<<";\n";
+   out<<"\tsampScale = "<<theSampScale<<";\n";
+   out<<"\tlatScale = "<<theLatScale<<";\n";
+   out<<"\tlongScale = "<<theLonScale<<";\n";
+   out<<"\theightScale = "<<theHgtScale<<";\n";
+
+   out<<"\tlineNumCoef = (\n";
+   for (int i=0; i<19; ++i)
+      out<<"\t\t\t"<<std::scientific<<theLineNumCoef[i]<<",\n";
+   out<<"\t\t\t"<<std::scientific<<theLineNumCoef[19]<<");\n";
+
+   out<<"\tlineDenCoef = (\n";
+   for (int i=0; i<19; ++i)
+      out<<"\t\t\t"<<std::scientific<<theLineDenCoef[i]<<",\n";
+   out<<"\t\t\t"<<std::scientific<<theLineDenCoef[19]<<");\n";
+
+   out<<"\tsampNumCoef = (\n";
+   for (int i=0; i<19; ++i)
+      out<<"\t\t\t"<<std::scientific<<theSampNumCoef[i]<<",\n";
+   out<<"\t\t\t"<<std::scientific<<theSampNumCoef[19]<<");\n";
+
+   out<<"\tsampDenCoef = (\n";
+   for (int i=0; i<19; ++i)
+      out<<"\t\t\t"<<std::scientific<<theSampDenCoef[i]<<",\n";
+   out<<"\t\t\t"<<std::scientific<<theSampDenCoef[19]<<");\n";
+
+   out<<"END_GROUP = IMAGE\n";
+   out<<"END;";
+}
+
diff --git a/src/projection/ossimRpcProjection.cpp b/src/projection/ossimRpcProjection.cpp
index 435700e..1a82d46 100644
--- a/src/projection/ossimRpcProjection.cpp
+++ b/src/projection/ossimRpcProjection.cpp
@@ -13,6 +13,7 @@
 #include <ossim/projection/ossimProjectionFactoryRegistry.h>
 #include <ossim/projection/ossimRpcProjection.h>
 #include <ossim/projection/ossimRpcSolver.h>
+#include <ossim/projection/ossimRpcModel.h>
 #include <ossim/base/ossimEcefPoint.h>
 #include <ossim/base/ossimEcefVector.h>
 #include <ossim/base/ossimTieGptSet.h>
@@ -897,13 +898,6 @@ bool ossimRpcProjection::loadState(const ossimKeywordlist& kwl,
       theSampDenCoef[i] = ossimString(value).toDouble();
    }
 
-   loadAdjustments(kwl, prefix);
-
-   if(getNumberOfAdjustableParameters() < 1)
-   {
-      initAdjustableParameters();
-   }
-      
    if (traceExec())  ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimRpcProjection::loadState(): returning..." << std::endl;
 
    return true;
@@ -1029,7 +1023,6 @@ ossimRpcProjection::getForwardDeriv(int parmIdx, const ossimGpt& gpos, double hd
 double
 ossimRpcProjection::optimizeFit(const ossimTieGptSet& tieSet, double* /* targetVariance */)
 {
-#if 1
    //NOTE : ignore targetVariance
    ossimRefPtr<ossimRpcSolver> solver = new ossimRpcSolver(false, false); //TBD : choices should be part of setupFromString
 
@@ -1038,7 +1031,7 @@ ossimRpcProjection::optimizeFit(const ossimTieGptSet& tieSet, double* /* targetV
    tieSet.getSlaveMasterPoints(imagePoints, groundPoints);
    solver->solveCoefficients(imagePoints, groundPoints);
 
-   ossimRefPtr< ossimImageGeometry > optProj = solver->createRpcProjection();
+   const ossimRefPtr< ossimRpcModel > optProj = solver->getRpcModel();
    if (!optProj)
    {
       ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimRpcProjection::optimizeFit(): error when optimizing the RPC with given tie points"
@@ -1046,141 +1039,11 @@ ossimRpcProjection::optimizeFit(const ossimTieGptSet& tieSet, double* /* targetV
       return -1.0;
    }
 
-   if(optProj->hasProjection())
-   {
       ossimKeywordlist kwl;
-      optProj->getProjection()->saveState(kwl);
+      optProj->saveState(kwl);
       this->loadState(kwl);
-   }
 
    return std::pow(solver->getRmsError(), 2); //variance in pixel^2
-#else
-   // COPIED from ossimRpcProjection
-   //
-   //
-   //use a simple Levenberg-Marquardt non-linear optimization
-   //note : please limit the number of tie points
-   //
-   //INPUTS: requires Jacobian matrix (partial derivatives with regards to parameters)
-   //OUTPUTS: will also compute parameter covariance matrix
-   //
-   //TBD: use targetVariance!
- 
-   int np = getNumberOfAdjustableParameters();
-   int nobs = tieSet.size();
-
-   //setup initail values
-   int iter=0;
-   int iter_max = 200;
-   double minResidue = 1e-10; //TBC
-   double minDelta = 1e-10; //TBC
-
-   //build Least Squares initial normal equation
-   // don't waste memory, add samples one at a time
-   NEWMAT::SymmetricMatrix A;
-   NEWMAT::ColumnVector residue;
-   NEWMAT::ColumnVector projResidue;
-   double deltap_scale = 1e-4; //step_Scale is 1.0 because we expect parameters to be between -1 and 1
-   buildNormalEquation(tieSet, A, residue, projResidue, deltap_scale);
-   double ki2=residue.SumSquare();
-
-   //get current adjustment (between -1 and 1 normally) and convert to ColumnVector
-   ossimAdjustmentInfo cadj;
-   getAdjustment(cadj);
-   std::vector< ossimAdjustableParameterInfo >& parmlist = cadj.getParameterList();
-   NEWMAT::ColumnVector cparm(np), nparm(np);
-   for(int n=0;n<np;++n)
-   {
-      cparm(n+1) = parmlist[n].getParameter();
-   }
-
-   double damping_speed = 2.0;
-   //find max diag element for A
-   double maxdiag=0.0;
-   for(int d=1;d<=np;++d) {
-      if (maxdiag < A(d,d)) maxdiag=A(d,d);
-   }
-   double damping = 1e-3 * maxdiag;
-   double olddamping = 0.0;
-   bool found = false;
-
-//DEBUG TBR
-cout<<"rms="<<sqrt(ki2/nobs)<<" ";
-cout.flush();
-
-   while ( (!found) && (iter < iter_max) ) //non linear optimization loop
-   {
-      bool decrease = false;
-
-      do
-      {
-         //add damping update to normal matrix
-         for(int d=1;d<=np;++d) A(d,d) += damping - olddamping;
-         olddamping = damping;
-
-         NEWMAT::ColumnVector deltap = solveLeastSquares(A, projResidue);
-
-         if (deltap.NormFrobenius() <= minDelta) 
-         {
-            found = true;
-         } else {
-            //update adjustment
-            nparm = cparm + deltap;
-            for(int n=0;n<np;++n)
-            {
-               setAdjustableParameter(n, nparm(n+1), false); //do not update now, wait
-            }
-            adjustableParametersChanged();
-
-            //check residue is reduced
-            NEWMAT::ColumnVector newresidue = getResidue(tieSet);
-            double newki2=newresidue.SumSquare();
-            double res_reduction = (ki2 - newki2) / (deltap.t()*(deltap*damping + projResidue)).AsScalar();
- //DEBUG TBR
-       cout<<sqrt(newki2/nobs)<<" ";
-       cout.flush();
-
-            if (res_reduction > 0)
-            {
-               //accept new parms
-               cparm = nparm;
-               ki2=newki2;
-
-               deltap_scale = max(1e-15, deltap.NormInfinity()*1e-4);
-
-               buildNormalEquation(tieSet, A, residue, projResidue, deltap_scale);
-               olddamping = 0.0;
-
-               found = ( projResidue.NormInfinity() <= minResidue );
-               //update damping factor
-               damping *= std::max( 1.0/3.0, 1.0-std::pow((2.0*res_reduction-1.0),3));
-               damping_speed = 2.0;
-               decrease = true;
-            } else {
-               //cancel parameter update
-               for(int n=0;n<np;++n)
-               {
-                  setAdjustableParameter(n, nparm(n+1), false); //do not update right now
-               }
-               adjustableParametersChanged();
-
-               damping *= damping_speed;
-               damping_speed *= 2.0;
-            }
-         }
-      } while (!decrease && !found);
-      ++iter;
-   }
-
-//DEBUG TBR
-cout<<endl;
-
-   //compute parameter correlation
-   // use normal matrix inverse
-   //TBD
-
-   return ki2/nobs;
-#endif
 }
 
 void
diff --git a/src/projection/ossimRpcSolver.cpp b/src/projection/ossimRpcSolver.cpp
index f61d462..1c0c7ca 100644
--- a/src/projection/ossimRpcSolver.cpp
+++ b/src/projection/ossimRpcSolver.cpp
@@ -1,14 +1,9 @@
-//*****************************************************************************
-// FILE: ossimRpcModel.h
+//**************************************************************************************************
 //
-// License:  LGPL
-// 
-// See LICENSE.txt file in the top level directory for more details.
+//     OSSIM Open Source Geospatial Data Processing Library
+//     See top level LICENSE.txt file for license information
 //
-// AUTHOR: Garrett Potts
-//
-//*****************************************************************************
-//  $Id: ossimRpcSolver.cpp 18960 2011-02-25 12:07:18Z gpotts $
+//**************************************************************************************************
 
 #include <cstdlib>
 #include <ctime>
@@ -27,134 +22,93 @@
 #include <ossim/support_data/ossimNitfRpcBTag.h>
 #include <ossim/imaging/ossimImageGeometry.h>
 #include <ossim/base/ossim2dTo2dIdentityTransform.h>
-ossimRpcSolver::ossimRpcSolver(bool useElevation,
-                               bool useHeightAboveMSLFlag)
+
+static const ossim_uint32 STARTING_GRID_SIZE = 8;
+static const ossim_uint32 ENDING_GRID_SIZE = 64;
+
+ossimRpcSolver::ossimRpcSolver(bool useElevation, bool useHeightAboveMSLFlag)
+:  theUseElevationFlag(useElevation),
+   theHeightAboveMSLFlag(useHeightAboveMSLFlag),
+   theMeanResidual(0),
+   theMaxResidual(0)
 {
-   theUseElevationFlag   = useElevation;
-   theHeightAboveMSLFlag = useHeightAboveMSLFlag;
-   theXNumCoeffs.resize(20);
-   theXDenCoeffs.resize(20);
-   theYNumCoeffs.resize(20);
-   theYDenCoeffs.resize(20);
-
-   std::fill(theXNumCoeffs.begin(),
-             theXNumCoeffs.end(), 0.0);
-   std::fill(theXDenCoeffs.begin(),
-             theXDenCoeffs.end(), 0.0);
-   std::fill(theYNumCoeffs.begin(),
-             theYNumCoeffs.end(), 0.0);
-   std::fill(theYDenCoeffs.begin(),
-             theYDenCoeffs.end(), 0.0);
-   theXNumCoeffs[0] = 1.0;
-   theXDenCoeffs[0] = 1.0;
-   theYNumCoeffs[0] = 1.0;
-   theYDenCoeffs[0] = 1.0;
 }
 
 void ossimRpcSolver::solveCoefficients(const ossimDrect& imageBounds,
                                        ossimProjection* proj,
                                        ossim_uint32 xSamples,
-                                       ossim_uint32 ySamples,
-                                       bool shiftTo0Flag)
+                                       ossim_uint32 ySamples)
 {
    ossimRefPtr<ossimImageGeometry> geom = new ossimImageGeometry();
    geom->setProjection(proj);
-   solveCoefficients(imageBounds, geom.get(), xSamples, ySamples, shiftTo0Flag);
+   solveCoefficients(imageBounds, geom.get(), xSamples, ySamples);
 }
 
 void ossimRpcSolver::solveCoefficients(const ossimDrect& imageBounds,
                                        ossimImageGeometry* geom,
                                        ossim_uint32 xSamples,
-                                       ossim_uint32 ySamples,
-                                       bool shiftTo0Flag)
+                                       ossim_uint32 ySamples)
 {
-   std::vector<ossimGpt> theGroundPoints;
-   std::vector<ossimDpt> theImagePoints;
-   ossim_uint32 x,y;
-   ossim_float64 w = imageBounds.width();
-   ossim_float64 h = imageBounds.height();
+   if (!geom || !(geom->getProjection()))
+      return;
+   theRefGeom = geom;
+
+   std::vector<ossimGpt> groundPoints;
+   std::vector<ossimDpt> imagePoints;
+   ossim_uint32 x,y,img_x, img_y;
    ossimGpt gpt;
    ossimGpt defaultGround;
-   if(ySamples < 1) ySamples = 12;
-   if(xSamples < 1) xSamples = 12;
+   if (ySamples <= 1)
+      ySamples = STARTING_GRID_SIZE;
+   if (xSamples <= 1)
+      xSamples = STARTING_GRID_SIZE;
    srand(time(0));
-   double xnorm;
-   double ynorm;
-   ossimDpt ul = imageBounds.ul();
-   ossimDpt shiftTo0(-ul.x,
-                     -ul.y);
+   double Dx = imageBounds.width()/(xSamples-1);
+   double Dy = imageBounds.height()/(ySamples-1);
+   ossimDpt dpt;
    for(y = 0; y < ySamples; ++y)
    {
+      dpt.y = y*Dy + imageBounds.ul().y;
       for(x = 0; x < xSamples; ++x)
       {
-         if(ySamples > 1)
-         {
-//            ynorm = (double)y/(double)(ySamples-1.0);
-            ynorm = (double)y/(double)(ySamples);
-         }
+         dpt.x = x*Dx + imageBounds.ul().x;
+         if (theUseElevationFlag)
+            geom->localToWorld(dpt, gpt);
          else
-         {
-            ynorm = 0.0;
-         }
-         if(xSamples > 1)
-         {
-//            xnorm = (double)x/(double)(xSamples-1.0);
-            xnorm = (double)x/(double)(xSamples);
-         }
-         else
-         {
-            xnorm = 0.0;
-         }
-         
-//          ossimDpt dpt((.25 + .5*xnorm)*w + ul.x,
-//                       (.25 + .5*ynorm)*h + ul.y);
-         ossimDpt dpt(w*xnorm + ul.x,
-                      h*ynorm + ul.y);
-         
-         geom->localToWorld(dpt, gpt);
-         gpt.changeDatum(defaultGround.datum());
+            geom->localToWorld(dpt, 0, gpt);
 
-         if(shiftTo0Flag)
-         {
-            theImagePoints.push_back(dpt+shiftTo0);
-         }
-         else
-         {
-            theImagePoints.push_back(dpt);
-         }
+         if (gpt.isLatLonNan())
+            continue;
+
+         if(gpt.isHgtNan())
+            gpt.height(0.0);
+
+         gpt.changeDatum(defaultGround.datum());
          if(theHeightAboveMSLFlag)
          {
             double h = ossimElevManager::instance()->getHeightAboveMSL(gpt);
             if(ossim::isnan(h) == false)
-            {
                gpt.height(h);
-            }
-         }
-         if(gpt.isHgtNan())
-         {
-            gpt.height(0.0);
          }
-         theGroundPoints.push_back(gpt);
+
+         imagePoints.push_back(dpt);
+         groundPoints.push_back(gpt);
       }
    }
-   solveCoefficients(theImagePoints,
-                     theGroundPoints);
+   solveCoefficients(imagePoints, groundPoints);
 }
 
 void ossimRpcSolver::solveCoefficients(const std::vector<ossimDpt>& imagePoints,
-                                       const std::vector<ossimGpt>& groundControlPoints,
-                                       const ossimDpt& /* imageShift */)
+                                       const std::vector<ossimGpt>& groundControlPoints)
 {
    if((imagePoints.size() != groundControlPoints.size()))
-   {
       return;
-   }
 
    // we will first create f which holds the result of f(x,y,z).
    // This basically holds the cooresponding image point for each
    // ground control point.  One for x and a second array for y
-   //
-   std::vector<double> f[2];
+   int numPoints = imagePoints.size();
+   std::vector<double> fx, fy;
 
    //  Holds the x, y, z vectors
    //
@@ -162,35 +116,25 @@ void ossimRpcSolver::solveCoefficients(const std::vector<ossimDpt>& imagePoints,
    std::vector<double> y;
    std::vector<double> z;
    ossim_uint32 c = 0;
-   f[0].resize(imagePoints.size());
-   f[1].resize(imagePoints.size());
+   fx.resize(imagePoints.size());
+   fy.resize(imagePoints.size());
    x.resize(imagePoints.size());
    y.resize(imagePoints.size());
    z.resize(imagePoints.size());
 
    // compute the image bounds for the given image points
-   //
    ossimDrect rect(imagePoints);
+   ossimDpt centerImagePoint  = rect.midPoint();
 
-   // get the widtha dn height that will be used
-   // in data normalization
-   //
+   // get the width and height that will be used in data normalization
    ossim_float64 w = rect.width();
    ossim_float64 h = rect.height();
 
-   // setup scales for normalization
-//   ossim_float64 xScale = w/2.0;
-//   ossim_float64 yScale = h/2.0;
-
-   // get the shift for the cneter of the data
-   ossimDpt centerImagePoint  = rect.midPoint();
-   
    double latSum=0.0;
    double lonSum=0.0;
    double heightSum=0.0;
 
    // find the center ground  Use elevation only if its enabled
-   //
    for(c = 0; c < groundControlPoints.size();++c)
    {
       if(ossim::isnan(groundControlPoints[c].latd()) == false)
@@ -217,10 +161,6 @@ void ossimRpcSolver::solveCoefficients(const std::vector<ossimDpt>& imagePoints,
                          heightSum/groundControlPoints.size());
 
    // set up ground scales and deltas for normalization
-   //
-//   ossim_float64 latScale       = 0.0;
-//   ossim_float64 lonScale       = 0.0;
-//   ossim_float64 heightScale    = 0.0;
    ossim_float64 deltaLat       = 0.0;
    ossim_float64 deltaLon       = 0.0;
    ossim_float64 deltaHeight    = 0.0;
@@ -249,34 +189,39 @@ void ossimRpcSolver::solveCoefficients(const std::vector<ossimDpt>& imagePoints,
       {
          deltaHeight = 0.0;
       }
-      f[0][c] = (imagePoints[c].x - centerImagePoint.x)/(w/2.0);
-      f[1][c] = (imagePoints[c].y - centerImagePoint.y)/(h/2.0);
+      fx[c] = (imagePoints[c].x - centerImagePoint.x)/(w/2.0);
+      fy[c] = (imagePoints[c].y - centerImagePoint.y)/(h/2.0);
       
       x[c] = deltaLon;
       y[c] = deltaLat;
       z[c] = deltaHeight;
 
-      if(fabs(deltaLat) > maxDeltaLat) maxDeltaLat          = fabs(deltaLat);
-      if(fabs(deltaLon) > maxDeltaLon) maxDeltaLon          = fabs(deltaLon);
-      if(fabs(heightTest) > maxDeltaHeight) maxDeltaHeight  = fabs(heightTest);
+      if(fabs(deltaLat) > maxDeltaLat)
+         maxDeltaLat = fabs(deltaLat);
+      if(fabs(deltaLon) > maxDeltaLon)
+         maxDeltaLon = fabs(deltaLon);
+      if(fabs(heightTest) > maxDeltaHeight)
+         maxDeltaHeight = fabs(heightTest);
    }
+
    bool elevationEnabled = theUseElevationFlag;
-   // always normalize, except if too small
-   //
+
    // if max delta is less than a degree set it to 1 degree.
-   //
-   if(maxDeltaLat < 1.0)    maxDeltaLat = 1.0;
-   // if max delta is less than 1 degree then set it to 1.0 degree
-   if(maxDeltaLon < 1.0)    maxDeltaLon = 1.0;
+//   if(maxDeltaLat < 1.0)
+//      maxDeltaLat = 1.0;
+//   if(maxDeltaLon < 1.0)
+//      maxDeltaLon = 1.0;
 
-   if(fabs(maxDeltaHeight) < FLT_EPSILON) elevationEnabled = false;
-   // if max delta is less than a meter then set it to a meter.
-   if(maxDeltaHeight < 1.0) maxDeltaHeight = 1.0;
+   if(maxDeltaHeight < FLT_EPSILON)
+      elevationEnabled = false;
+   if(maxDeltaHeight < 1.0)
+      maxDeltaHeight = 1.0;
 
    // set the height scale to something pretty large
    if(!elevationEnabled)
    {
       maxDeltaHeight = 1.0/DBL_EPSILON;
+      maxDeltaHeight = 10000;
       centerGround.height(0.0);
    }
    // normalize the ground points
@@ -287,229 +232,197 @@ void ossimRpcSolver::solveCoefficients(const std::vector<ossimDpt>& imagePoints,
       z[c] /= maxDeltaHeight;
    }
 
-   theLatScale    = maxDeltaLat;
-   theLonScale    = maxDeltaLon;
-   theHeightScale = maxDeltaHeight;
+   theRpcModel = new ossimRpcModel;
+   theRpcModel->thePolyType = ossimRpcModel::B;
+   theRpcModel->theLineOffset = centerImagePoint.y;
+   theRpcModel->theSampOffset = centerImagePoint.x;
+   theRpcModel->theLineScale  = h/2.0;
+   theRpcModel->theSampScale  = w/2.0;
 
-   theImageOffset = centerImagePoint;
-   theImageScale  = ossimDpt(w/2.0,
-                             h/2.0);
-   theGroundOffset = centerGround;
+   theRpcModel->theLatScale = maxDeltaLat;
+   theRpcModel->theLonScale = maxDeltaLon;
+   theRpcModel->theHgtScale = maxDeltaHeight;
 
-   if(ossim::isnan(theGroundOffset.height()))
-   {
-      theGroundOffset.height(0.0);
-   }
+   theRpcModel->theLatOffset = centerGround.lat;
+   theRpcModel->theLonOffset = centerGround.lon;
+   theRpcModel->theHgtOffset = centerGround.hgt;
 
-   // now lets solve the coefficients
-   //
-   std::vector<double> coeffx;
-   std::vector<double> coeffy;
+   if(ossim::isnan(theRpcModel->theHgtOffset))
+      theRpcModel->theHgtOffset = 0.0;
 
    NEWMAT::ColumnVector coeffxVec;
    NEWMAT::ColumnVector coeffyVec;
+
    // perform a least squares fit for sample values found in f
    // given the world values with variables x, y, z
-   //
-   solveCoefficients(coeffxVec,
-                     f[0],
-                     x,
-                     y,
-                     z);
+   solveCoefficients(coeffxVec, fx, x, y, z);
 
-   
    // perform a least squares fit for line values found in f
    // given the world values with variables x, y, z
-   //
-   solveCoefficients(coeffyVec,
-                     f[1],
-                     x,
-                     y,
-                     z);
-
-   coeffx.resize(coeffxVec.Nrows());
-   coeffy.resize(coeffyVec.Nrows());
-   
-   for(c = 0; c < coeffx.size();++c)
+   solveCoefficients(coeffyVec, fy, x, y, z);
+
+   // there are 20 numerator coefficients and 19 denominator coefficients.
+   // I believe that the very first one for the denominator coefficients is fixed at 1.
+   theRpcModel->theLineNumCoef[0] = coeffyVec[0];
+   theRpcModel->theLineDenCoef[0] = 1.0;
+   theRpcModel->theSampNumCoef[0] = coeffxVec[0];
+   theRpcModel->theSampDenCoef[0] = 1.0;
+   for (int i=1; i<20; i++)
    {
-      coeffx[c] = coeffxVec[c];
-      coeffy[c] = coeffyVec[c];
+      theRpcModel->theLineNumCoef[i] = coeffyVec[i];
+      theRpcModel->theLineDenCoef[i] = coeffyVec[i+19];
+      theRpcModel->theSampNumCoef[i] = coeffxVec[i];
+      theRpcModel->theSampDenCoef[i] = coeffxVec[i+19];
    }
-   // there are 20 numerator coefficients
-   // and 19 denominator coefficients
-   // I believe that the very first one for the
-   // denominator coefficients is fixed at 1.0
-   //
-   std::copy(coeffx.begin(),
-             coeffx.begin()+20,
-             theXNumCoeffs.begin());
-   std::copy(coeffx.begin()+20,
-             coeffx.begin()+39,
-             theXDenCoeffs.begin()+1);
-   std::copy(coeffy.begin(),
-             coeffy.begin()+20,
-             theYNumCoeffs.begin());
-   std::copy(coeffy.begin()+20,
-             coeffy.begin()+39,
-             theYDenCoeffs.begin()+1);
-   theXDenCoeffs[0] = 1.0;
-   theYDenCoeffs[0] = 1.0;
-
 
    // now lets compute the RMSE for the given control points by feeding it
    // back through the modeled RPC
-   //
    ossim_float64  sumSquareError = 0.0;
    ossim_uint32 idx = 0;
 
-//    std::cout << "ground offset height = " << theGroundOffset.height()
-//              << "Height scale         = " << theHeightScale << std::endl;
+   theMaxResidual = 0;
    for (idx = 0; idx<imagePoints.size(); idx++)
    {
-      ossim_float64 x = (groundControlPoints[idx].lond() - theGroundOffset.lond())/theLonScale;
-      ossim_float64 y = (groundControlPoints[idx].latd() - theGroundOffset.latd())/theLatScale;
-      ossim_float64 z = (groundControlPoints[idx].height() - theGroundOffset.height())/theHeightScale;
-      
-      if(ossim::isnan(z))
-      {
-         z = 0.0;
-      }
-      else
-      {
-         z = (z - theGroundOffset.height()/theHeightScale);
-      }
-       ossim_float64 imageX = ((eval(theXNumCoeffs, x, y, z)/
-                                eval(theXDenCoeffs, x, y, z))*theImageScale.x) + theImageOffset.x;
-      
-       ossim_float64 imageY = ((eval(theYNumCoeffs, x, y, z)/
-                                eval(theYDenCoeffs, x, y, z))*theImageScale.y) + theImageOffset.y;
-      
-      ossimDpt evalPt(imageX, imageY);
+      ossimDpt evalPt;
+      evalPoint(groundControlPoints[idx], evalPt);
       ossim_float64 len = (evalPt - imagePoints[idx]).length();
-      
+      if (len > theMaxResidual)
+         theMaxResidual = len;
       sumSquareError += (len*len);
    }
 
    // set the error
-   //
-   theError = sqrt(sumSquareError/imagePoints.size());
+   theMeanResidual = sqrt(sumSquareError/imagePoints.size());
 }
 
-ossimImageGeometry* ossimRpcSolver::createRpcModel()const
+bool ossimRpcSolver::solve(const ossimDrect& imageBounds,
+                           ossimImageGeometry* geom,
+                           const double& tolerance)
 {
-   ossimRpcModel* model = new ossimRpcModel;
-   
-   model->setAttributes(theImageOffset.x,
-                        theImageOffset.y,
-                        theImageScale.x,
-                        theImageScale.y,
-                        theGroundOffset.latd(),
-                        theGroundOffset.lond(),
-                        theGroundOffset.height(),
-                        theLatScale,
-                        theLonScale,
-                        theHeightScale,
-                        theXNumCoeffs,
-                        theXDenCoeffs,
-                        theYNumCoeffs,
-                        theYDenCoeffs);
-   return new ossimImageGeometry(new ossim2dTo2dIdentityTransform, model);
-}
+   static const char* MODULE = "ossimRpcSolver::solve()  ";
 
-ossimImageGeometry* ossimRpcSolver::createRpcProjection()const
-{
-   ossimRpcProjection* proj = new ossimRpcProjection;
-   
-   proj->setAttributes(theImageOffset.x,
-                       theImageOffset.y,
-                       theImageScale.x,
-                       theImageScale.y,
-                       theGroundOffset.latd(),
-                       theGroundOffset.lond(),
-                       theGroundOffset.height(),
-                       theLatScale,
-                       theLonScale,
-                       theHeightScale,
-                       theXNumCoeffs,
-                       theXDenCoeffs,
-                       theYNumCoeffs,
-                       theYDenCoeffs);
-   return new ossimImageGeometry(new ossim2dTo2dIdentityTransform, proj);
-}
+   if (!geom)
+      return false;
 
-const std::vector<double>& ossimRpcSolver::getImageXNumCoefficients()const
-{
-   return theXNumCoeffs;
-}
+   theRefGeom = geom;
+   ossimDpt ul = imageBounds.ul();
+   ossim_float64 w = imageBounds.width();
+   ossim_float64 h = imageBounds.height();
+   ossimDpt gsd (geom->getMetersPerPixel());
 
-const std::vector<double>& ossimRpcSolver::getImageXDenCoefficients()const
-{
-   return theXDenCoeffs;
-}
+   double dxRms = 0;
+   double dyRms = 0;
+   ossimDpt ipt, irpc;
+   ossimGpt gpt;
 
-const std::vector<double>& ossimRpcSolver::getImageYNumCoefficients()const
-{
-   return theYNumCoeffs;
-}
+   // Start at the minimum grid size:
+   ossim_uint32 xSamples = STARTING_GRID_SIZE;
+   ossim_uint32 ySamples = STARTING_GRID_SIZE;
 
-const std::vector<double>& ossimRpcSolver::getImageYDenCoefficients()const
-{
-   return theYDenCoeffs;
-}
+   // Loop until error is below threshold:
+   bool converged = false;
+   while (!converged)
+   {
+      double residual = 0;
+      double sumResiduals = 0;
+      int numResiduals = 0;
+      theMaxResidual = 0;
 
-double ossimRpcSolver::getImageXOffset()const
-{
-   return theImageOffset.x;
-}
+      converged = true; // hope for the best and get proved otherwise below
+      solveCoefficients(imageBounds, geom, xSamples, ySamples);
 
-double ossimRpcSolver::getImageYOffset()const
-{
-   return theImageOffset.y;
-}
+      // Sample along x and y directions to accumulate errors:
+      double deltaX = w/(xSamples-1);
+      double deltaY = h/(ySamples-1);
 
-double ossimRpcSolver::getLatOffset()const
-{
-   return theGroundOffset.latd();
-}
+      // Sample the midpoints between image grid used to compute RPC:
+      for (ossim_uint32 y=0; y<ySamples-1; ++y)
+      {
+         ipt.y = deltaY*((double)y + 0.5) + ul.y;
+         for (ossim_uint32 x=0; x<xSamples-1; ++x)
+         {
+            // Forward projection using input model:
+            ipt.x = deltaX*((double)x + 0.5) + ul.x;
+            if (theUseElevationFlag)
+               geom->localToWorld(ipt, gpt);
+            else
+               geom->localToWorld(ipt, 0, gpt);
+            if(theHeightAboveMSLFlag)
+            {
+               double h = ossimElevManager::instance()->getHeightAboveMSL(gpt);
+               if(ossim::isnan(h) == false)
+                  gpt.height(h);
+            }
 
-double ossimRpcSolver::getLonOffset()const
-{
-   return theGroundOffset.lond();
-}
+            // Reverse projection using RPC:
+            evalPoint(gpt, irpc);
 
-double ossimRpcSolver::getHeightOffset()const
-{
-   return theGroundOffset.height();
-}
+            // Compute residual and accumulate:
+            residual = (ipt-irpc).length();
+            if (residual > theMaxResidual)
+               theMaxResidual = residual;
+            sumResiduals += residual;
+            ++numResiduals;
+         }
+      }
 
-double ossimRpcSolver::getImageXScale()const
-{
-   return theImageScale.x;
-}
+      theMeanResidual = sumResiduals/numResiduals;
+      if (theMaxResidual > tolerance)
+         converged = false;
+
+#if 1
+      { //### DEBUG BLOCK ###
+         ossimNotify(ossimNotifyLevel_INFO)<<MODULE
+               <<"\n   sampling grid size: ("<<xSamples<<", "<<ySamples<<")"
+               <<"\n        mean residual: "<<theMeanResidual
+               <<"\n         max residual: "<<theMaxResidual
+               <<"\n            converged: "<<ossimString::toString(converged)<<endl;
+      }
+#endif
 
-double ossimRpcSolver::getImageYScale()const
-{
-   return theImageScale.y;
-}
+      if ((xSamples >= ENDING_GRID_SIZE) && (ySamples >= ENDING_GRID_SIZE))
+         break;
 
-double ossimRpcSolver::getLatScale()const
-{
-   return theLatScale;
-}
+      if (!converged)
+      {
+         xSamples *= 2;
+         if (xSamples > ENDING_GRID_SIZE)
+            xSamples = ENDING_GRID_SIZE;
+         ySamples *= 2;
+         if (ySamples > ENDING_GRID_SIZE)
+            ySamples = ENDING_GRID_SIZE;
+      }
+   }
 
-double ossimRpcSolver::getLonScale()const
-{
-   return theLonScale;
+   // Was testing the max residual. But use the mean for final test:
+   if (theMeanResidual <= tolerance)
+         converged = true;
+
+   if (!converged)
+   {
+      ossimNotify(ossimNotifyLevel_WARN)
+            << "WARNING: Unable to converge on desired error tolerance ("<<tolerance<<" p).\n"
+            <<"    RMS residual error: " << theMeanResidual << "\n"
+            <<"    Max residual error: " << theMaxResidual<<std::endl;
+   }
+   else if (theMaxResidual > tolerance)
+   {
+      ossimNotify(ossimNotifyLevel_WARN)
+            << "WARNING: While the RPC solution did converge, at least one residual ("
+            <<theMaxResidual<<") is larger than the desired error tolerance ("<<tolerance<<" p)."
+            << std::endl;
+   }
+   return converged;
 }
 
-double ossimRpcSolver::getHeightScale()const
+double ossimRpcSolver::getRmsError()const
 {
-   return theHeightScale;
+   return theMeanResidual;
 }
 
-double ossimRpcSolver::getRmsError()const
+double ossimRpcSolver::getMaxError()const
 {
-   return theError;
+   return theMaxResidual;
 }
 
 void ossimRpcSolver::solveInitialCoefficients(NEWMAT::ColumnVector& coeff,
@@ -525,11 +438,7 @@ void ossimRpcSolver::solveInitialCoefficients(NEWMAT::ColumnVector& coeff,
    {
       r[idx] = f[idx];
    }
-   setupSystemOfEquations(m,
-                          r,
-                          x,
-                          y,
-                          z);
+   setupSystemOfEquations(m, r, x, y, z);
    
    coeff = invert(m.t()*m)*m.t()*r;
 }
@@ -571,48 +480,60 @@ void ossimRpcSolver::solveCoefficients(NEWMAT::ColumnVector& coeff,
    {
       w2 = weights*weights;
 
-      // sets up the matrix to hold the system of
-      // equations
-      setupSystemOfEquations(m,
-                             r,
-                             x,
-                             y,
-                             z);
+#if 0
+      { //### DEBUG ###
+         cout<<"\nw2 = \n"<<w2<<endl;
+         cout<<"\nr = "<<r<<endl;
+      }
+#endif
+
+      // sets up the matrix to hold the system of equations
+      setupSystemOfEquations(m, r, x, y, z);
 
       // solve the least squares solution.  Note: the invert is used
       // to do a Singular Value Decomposition for the inverse since the
       // matrix is more than likely singular.  Slower but more robust
-      //
+#if 0
+      { //### DEBUG ###
+         NEWMAT::Matrix mt = m.t();
+         cout<<"\nm = "<<m<<endl;
+         cout<<"\nmt = "<<mt<<endl;
+
+         NEWMAT::Matrix mtw2 = m.t()*w2;
+         cout<<"\nmtw2 = "<<mtw2<<endl;
+         NEWMAT::Matrix mtw2m = mtw2*m;
+         cout<<"\nmtw2m = "<<mtw2m<<endl;
+         NEWMAT::Matrix mtw2r = mtw2*r;
+         cout<<"\nmtw2r = "<<mtw2r<<endl;
+
+         NEWMAT::Matrix mtw2m_inv = invert(mtw2m);
+         cout<<"\nmtw2m_inv = "<<mtw2m_inv<<endl;
+         tempCoeff = mtw2m_inv * mtw2r;
+         cout<<"\ntempCoeff = "<<tempCoeff<<endl;
+      }
+#else
       tempCoeff = invert(m.t()*w2*m)*m.t()*w2*r;
+#endif
 
       // set up the weight matrix by using the denominator
-      //
       for(idx = 0; idx < 19; ++idx)
       {
          denominator[idx+1] = tempCoeff[20+idx];
       }
       denominator[0] = 1.0;
       
-      setupWeightMatrix(weights,
-                        denominator,
-                        r,
-                        x,
-                        y,
-                        z);
+      setupWeightMatrix(weights, denominator, r, x, y, z);
 
       // compute the residual
-      //
       NEWMAT::ColumnVector residual = m.t()*w2*(m*tempCoeff-r);
 
       // now get the innerproduct
-      //
       NEWMAT::Matrix tempRes = (residual.t()*residual);
-      residualValue = tempRes[0][0];
+      residualValue = sqrt(tempRes[0][0]);
 
       ++iterations;
-      
-   }while((residualValue >FLT_EPSILON)&&
-          (iterations < 10));
+
+   } while ((residualValue > FLT_EPSILON) && (iterations < 10));
    coeff = tempCoeff;
 
 }
@@ -627,7 +548,7 @@ NEWMAT::Matrix ossimRpcSolver::invert(const NEWMAT::Matrix& m)const
    // decompose m.t*m which is stored in Temp into the singular values and vectors.
    //
    NEWMAT::SVD(m, d, u, v, true, true);
-   
+
    // invert the diagonal
    // this is just doing the reciprical fo all diagonal components and store back int
    // d.  ths compute d inverse.
@@ -656,8 +577,7 @@ void ossimRpcSolver::setupSystemOfEquations(NEWMAT::Matrix& equations,
                                             const std::vector<double>& z)const
 {
    ossim_uint32 idx;
-   equations.ReSize(f.Nrows(),
-                    39);
+   equations.ReSize(f.Nrows(), 39);
    
    for(idx = 0; idx < (ossim_uint32)f.Nrows();++idx)
    {
@@ -751,75 +671,23 @@ void ossimRpcSolver::setupWeightMatrix(NEWMAT::DiagonalMatrix& result, // holds
     }
 }
 
-double ossimRpcSolver::eval(const std::vector<double>& coeff,
-                            double x,
-                            double y,
-                            double z)const
+void ossimRpcSolver::evalPoint(const ossimGpt& gpt, ossimDpt& ipt) const
 {
-   return coeff[ 0]       + coeff[ 1]*x     + coeff[ 2]*y     + coeff[ 3]*z     +
-          coeff[ 4]*x*y   + coeff[ 5]*x*z   + coeff[ 6]*y*z   + coeff[ 7]*x*x   +
-          coeff[ 8]*y*y   + coeff[ 9]*z*z   + coeff[10]*x*y*z + coeff[11]*x*x*x +
-          coeff[12]*x*y*y + coeff[13]*x*z*z + coeff[14]*x*x*y + coeff[15]*y*y*y +
-          coeff[16]*y*z*z + coeff[17]*x*x*z + coeff[18]*y*y*z + coeff[19]*z*z*z;
+   if (!theRpcModel)
+   {
+      ipt.makeNan();
+      return;
+   }
+
+   theRpcModel->worldToLineSample(gpt, ipt);
 }
 
 
 ossimRefPtr<ossimNitfRegisteredTag> ossimRpcSolver::getNitfRpcBTag() const
 {
    ossimNitfRpcBTag* rpcbTag = new ossimNitfRpcBTag();
-
-   // success always true
-   rpcbTag->setSuccess(true);
-
-   // temp "0"...
-   rpcbTag->setErrorBias(0.0);
-
-   // temp "0"...
-   rpcbTag->setErrorRand(0.0);
-
-   // line offset
-   rpcbTag->setLineOffset(static_cast<ossim_uint32>(getImageYOffset()));
-
-   // sample offset
-   rpcbTag->setSampleOffset(static_cast<ossim_uint32>(getImageXOffset()));
-
-   // latitude offset
-   rpcbTag->setGeodeticLatOffset(getLatOffset());
-
-   // longitude offset
-   rpcbTag->setGeodeticLonOffset(getLonOffset());
-
-   // height offset
-   rpcbTag->setGeodeticHeightOffset(
-      static_cast<ossim_int32>(getHeightOffset()));
-
-   // line scale
-   rpcbTag->setLineScale(static_cast<ossim_uint32>(getImageYScale()));
-
-   // sample scale
-   rpcbTag->setSampleScale(static_cast<ossim_uint32>(getImageXScale()));
-
-   // latitude scale
-   rpcbTag->setGeodeticLatScale(getLatScale());
-
-   // longitude scale
-   rpcbTag->setGeodeticLonScale(getLonScale());
-
-   // height scale
-   rpcbTag->setGeodeticHeightScale(static_cast<ossim_int32>(getHeightScale()));
-
-   // line numerator coefficients
-   rpcbTag->setLineNumeratorCoeff(getImageYNumCoefficients());
+   rpcbTag->setRpcModelParams(theRpcModel);
    
-   // line denominator coefficients
-   rpcbTag->setLineDenominatorCoeff(getImageYDenCoefficients());
-
-   // sample numerator coefficients
-   rpcbTag->setSampleNumeratorCoeff(getImageXNumCoefficients());
-
-   // sample denominator coefficients
-   rpcbTag->setSampleDenominatorCoeff(getImageXDenCoefficients());
-
    // Return it as an ossimRefPtr<ossimNitfRegisteredTag>...
    ossimRefPtr<ossimNitfRegisteredTag> tag = rpcbTag;
    
diff --git a/src/projection/ossimSensorModel.cpp b/src/projection/ossimSensorModel.cpp
index 0d0e3f9..fc131e4 100644
--- a/src/projection/ossimSensorModel.cpp
+++ b/src/projection/ossimSensorModel.cpp
@@ -537,6 +537,7 @@ void ossimSensorModel::setImageRect(const ossimDrect& imageRect)
 {
    theImageClipRect = imageRect;
    theRefImgPt = imageRect.midPoint();
+   theImageSize = imageRect.size();
 }
 void ossimSensorModel::setGroundRect(const ossimGpt& ul,
                                      const ossimGpt& ur,
diff --git a/src/projection/ossimSensorModelFactory.cpp b/src/projection/ossimSensorModelFactory.cpp
index 7fcc902..ec3819b 100644
--- a/src/projection/ossimSensorModelFactory.cpp
+++ b/src/projection/ossimSensorModelFactory.cpp
@@ -40,7 +40,6 @@ static ossimTrace traceDebug = ossimTrace("ossimSensorModelFactory:debug");
 //***
 #include <ossim/projection/ossimCoarseGridModel.h>
 #include <ossim/projection/ossimRpcModel.h>
-#include <ossim/projection/ossimRpcProjection.h>
 #include <ossim/projection/ossimIkonosRpcModel.h>
 #include <ossim/projection/ossimNitfRpcModel.h>
 #include <ossim/projection/ossimQuickbirdRpcModel.h>
@@ -182,10 +181,6 @@ ossimSensorModelFactory::createProjection(const ossimString &name) const
    {
       return new ossimNitfRpcModel;
    }
-   if(name == STATIC_TYPE_NAME(ossimRpcProjection))
-   {
-      return new ossimRpcProjection;
-   }
    if(name == STATIC_TYPE_NAME(ossimFcsiModel))
    {
       return new ossimFcsiModel;
@@ -423,6 +418,24 @@ ossimProjection* ossimSensorModelFactory::createProjection(
       qbModel = 0;
    }
    
+//   ossimRefPtr<ossimRpcModel> qbModel = new ossimQuickbirdRpcModel;
+//   if(qbModel->parseFile(filename))
+//   {
+//      if(traceDebug())
+//      {
+//         ossimNotify(ossimNotifyLevel_DEBUG)
+//            << MODULE << " DEBUG: returning ossimQuickbirdRpcModel"
+//            << std::endl;
+//      }
+//      model = qbModel.get();
+//      qbModel = 0;
+//      return model.release();
+//   }
+//   else
+//   {
+//      qbModel = 0;
+//   }
+//
    //---
    // Test for ikonos rpc.  Could be tiff or nitf which is handled in
    // parseFile method.
diff --git a/src/projection/ossimTiffProjectionFactory.cpp b/src/projection/ossimTiffProjectionFactory.cpp
index 6925085..f9e8a26 100644
--- a/src/projection/ossimTiffProjectionFactory.cpp
+++ b/src/projection/ossimTiffProjectionFactory.cpp
@@ -17,6 +17,7 @@
 #include <ossim/base/ossimFilename.h>
 #include <ossim/projection/ossimProjection.h>
 #include <ossim/imaging/ossimTiffTileSource.h>
+#include <ossim/support_data/TiffHandlerState.h>
 #include <fstream>
 
 ossimTiffProjectionFactory* ossimTiffProjectionFactory::theInstance = 0;
@@ -39,23 +40,19 @@ ossimProjection*
 ossimTiffProjectionFactory::createProjection(const ossimFilename& filename,
                                               ossim_uint32 entryIdx)const
 {
-   if(!filename.exists())
+   std::shared_ptr<ossim::TiffHandlerState> state = std::make_shared<ossim::TiffHandlerState>();
+   if(state->loadDefaults(filename))
    {
-      return 0;
-   }
-
-   if(isTiff(filename))
-   {
-      ossimGeoTiff geotiff(filename, entryIdx);
+      ossimGeoTiff geotiff;
       ossimKeywordlist kwl;
-      
-      if(geotiff.addImageGeometry(kwl))
+      if(geotiff.readTags(state, entryIdx))
       {
-         return ossimProjectionFactoryRegistry::instance()->
-            createProjection(kwl);
+         if(geotiff.addImageGeometry(kwl))
+         {
+            return ossimProjectionFactoryRegistry::instance()->createProjection(kwl);
+         }
       }
    }
-   
    return 0;
 }
 
@@ -87,14 +84,22 @@ ossimProjection* ossimTiffProjectionFactory::createProjection(ossimImageHandler*
    {
       ossimGeoTiff geotiff;
       ossimKeywordlist kwl;
-      
-      geotiff.readTags(tiff->tiffPtr(), tiff->getCurrentEntry(), false);
-      
-      if(geotiff.addImageGeometry(kwl))
+      std::shared_ptr<ossim::TiffHandlerState> state = std::dynamic_pointer_cast<ossim::TiffHandlerState>(tiff->getState());
+      bool addGeometry = false;
+      if(state)
+      {
+         addGeometry = geotiff.readTags(state, 
+                                        tiff->getCurrentEntry());
+      }
+      else
+      {
+         addGeometry = geotiff.readTags(tiff->tiffPtr(), 
+                                        tiff->getCurrentEntry(), false);
+      }
+      if(addGeometry&&geotiff.addImageGeometry(kwl))
       {
          return ossimProjectionFactoryRegistry::instance()->createProjection(kwl);
       }
-      
    }
    
    return 0;
diff --git a/src/support_data/ImageHandlerState.cpp b/src/support_data/ImageHandlerState.cpp
new file mode 100644
index 0000000..a5b9f53
--- /dev/null
+++ b/src/support_data/ImageHandlerState.cpp
@@ -0,0 +1,121 @@
+//*******************************************************************
+//
+// License:  See top level LICENSE.txt file
+//
+//*************************************************************************
+
+#include <ossim/support_data/ImageHandlerState.h>
+#include <ossim/base/ossimKeywordNames.h>
+#include <ossim/support_data/ImageHandlerStateRegistry.h>
+
+const ossimString ossim::ImageHandlerState::m_typeName = "ossim::ImageHandlerState";
+
+ossim::ImageHandlerState::ImageHandlerState()
+: State(),
+m_currentEntry(0)
+{
+
+}
+
+ossim::ImageHandlerState::ImageHandlerState::~ImageHandlerState()
+{
+
+}
+
+const ossimString& ossim::ImageHandlerState::getTypeName()const
+{
+   return m_typeName;
+}
+
+const ossimString& ossim::ImageHandlerState::getStaticTypeName()
+{
+   return m_typeName;
+}
+
+bool ossim::ImageHandlerState::hasMetaData()const
+{
+  if(m_omd)
+  {
+      return m_omd->isValid(); 
+  }
+
+  return false;
+}
+
+bool ossim::ImageHandlerState::loadDefaults(const ossimFilename& filename, 
+                                            ossim_uint32 entry)
+{
+   m_connectionString = filename;
+   m_currentEntry     = entry;
+
+   // we still need to add initialization of the defaults for 
+   // valid vertices and overview detections, ... etc
+   //
+
+   return true;
+}
+
+bool ossim::ImageHandlerState::load(const ossimKeywordlist& kwl,
+                                    const ossimString& prefix)
+{
+   bool result = ossim::State::load(kwl, prefix);
+   m_overviewState = ossim::ImageHandlerStateRegistry::instance()->createState(kwl, prefix+"overview.");
+   m_connectionString = kwl.find(prefix, "connection_string");
+   m_imageHandlerType = kwl.find(prefix, "image_handler_type");
+   ossimString currentEntry = kwl.find(prefix, "current_entry");
+
+   if(currentEntry.empty())
+   {
+      m_currentEntry = 0;
+   } 
+   else
+   {
+      m_currentEntry = currentEntry.toUInt32();
+   }
+
+   ossimString omdType = kwl.find(prefix, "ossimImageMetaData");
+   if(!omdType.empty())
+   {
+      m_omd = std::make_shared<ossimImageMetaData>();
+      
+      m_omd->loadState(kwl, prefix+"omd.");
+   }
+   ossimKeywordlist tempKwl;
+   kwl.extractKeysThatMatch(tempKwl, "^("+prefix+"valid_vertices.)");
+   if(tempKwl.getSize())
+   {
+      tempKwl.stripPrefixFromAll("^("+prefix+"valid_vertices.)");
+      m_validVertices = std::make_shared<ossimKeywordlist>(tempKwl);
+   }
+
+   return result;
+}
+
+bool ossim::ImageHandlerState::save(ossimKeywordlist& kwl,
+                                    const ossimString& prefix)const
+{
+   bool result = ossim::State::save(kwl, prefix);
+   
+   if(m_overviewState)
+   {
+      ossimString tempPrefix = prefix + "overview.";
+      m_overviewState->save(kwl, tempPrefix);
+   }
+   if(m_omd)
+   {
+      ossimString tempPrefix = prefix + "omd.";
+      m_omd->saveState(kwl, tempPrefix);      
+   }
+   kwl.add(prefix, "connection_string",  m_connectionString.c_str(), true);
+   kwl.add(prefix, "image_handler_type", m_imageHandlerType.c_str(), true);
+   kwl.add(prefix, "current_entry",      m_currentEntry, true);
+
+   if(m_validVertices)
+   {
+      ossimString validVerticesPrefix = prefix+"valid_vertices.";
+      kwl.add(validVerticesPrefix.c_str(), *m_validVertices);
+      kwl.add(validVerticesPrefix, "type", "ossimValidVertices");
+   }
+
+   return result;
+}
diff --git a/src/support_data/ImageHandlerStateFactory.cpp b/src/support_data/ImageHandlerStateFactory.cpp
new file mode 100644
index 0000000..dedd761
--- /dev/null
+++ b/src/support_data/ImageHandlerStateFactory.cpp
@@ -0,0 +1,54 @@
+#include <ossim/support_data/ImageHandlerStateFactory.h>
+#include <ossim/base/ossimKeywordNames.h>
+#include <ossim/base/ossimException.h>
+#include <ossim/support_data/TiffHandlerState.h>
+#include <mutex>
+
+
+ossim::ImageHandlerStateFactory::ImageHandlerStateFactory()
+{
+
+}
+
+std::shared_ptr<ossim::ImageHandlerStateFactory> ossim::ImageHandlerStateFactory::instance()
+{
+   static std::shared_ptr<ImageHandlerStateFactory> 
+                 imageHandlerFactory = std::make_shared< ossim::ImageHandlerStateFactory >();
+   return imageHandlerFactory;                  
+}
+
+std::shared_ptr<ossim::ImageHandlerState> ossim::ImageHandlerStateFactory::createState(const ossimKeywordlist& kwl, 
+                                                                    const ossimString& prefix)const
+{
+   std::shared_ptr<ossim::ImageHandlerState> result;
+   ossimString typeValue = kwl.find(prefix, ossimKeywordNames::TYPE_KW);
+   if(typeValue)
+   {
+      result = createState(typeValue);
+      if(result)
+      {
+         try
+         {
+            result->load(kwl, prefix);
+         }
+         catch(ossimException& e)
+         {
+            result = nullptr;
+         }
+      }   
+   }
+
+   return result;  
+}
+
+std::shared_ptr<ossim::ImageHandlerState> ossim::ImageHandlerStateFactory::createState(const ossimString& typeName)const
+{
+   std::shared_ptr<ossim::ImageHandlerState> result;
+
+   if(typeName == ossim::TiffHandlerState::getStaticTypeName())
+   {
+      result = std::make_shared<ossim::TiffHandlerState>(); 
+   }
+
+   return result;  
+}
diff --git a/src/support_data/ImageHandlerStateRegistry.cpp b/src/support_data/ImageHandlerStateRegistry.cpp
new file mode 100644
index 0000000..57ef917
--- /dev/null
+++ b/src/support_data/ImageHandlerStateRegistry.cpp
@@ -0,0 +1,43 @@
+#include <ossim/support_data/ImageHandlerStateRegistry.h>
+#include <ossim/support_data/ImageHandlerStateFactory.h>
+
+
+ossim::ImageHandlerStateRegistry::ImageHandlerStateRegistry()
+{
+}
+
+std::shared_ptr<ossim::ImageHandlerStateRegistry> ossim::ImageHandlerStateRegistry::instance()
+{
+
+   static std::shared_ptr<ossim::ImageHandlerStateRegistry> imageHandlerStateRegistry = std::make_shared<ImageHandlerStateRegistry>();
+
+   return imageHandlerStateRegistry;
+}
+
+std::shared_ptr<ossim::ImageHandlerState> ossim::ImageHandlerStateRegistry::createState(const ossimKeywordlist& kwl,
+                                                                    const ossimString& prefix)const
+{
+   ScopeReadLock scopedReadLock(m_rwlock);
+   std::shared_ptr<ossim::ImageHandlerState> result;
+   for(const auto& factory:m_factoryList)
+   {
+      result = factory->createState(kwl, prefix);
+      if(result) break;
+   }
+
+   return result;
+}
+
+std::shared_ptr<ossim::ImageHandlerState> ossim::ImageHandlerStateRegistry::createState(const ossimString& typeName)const
+{
+   ScopeReadLock scopedReadLock(m_rwlock);
+   std::shared_ptr<ossim::ImageHandlerState> result;
+   for(const auto& factory:m_factoryList)
+   {
+      result = factory->createState(typeName);
+      if(result) break;
+   }
+
+   return result;
+}
+
diff --git a/src/support_data/TiffHandlerState.cpp b/src/support_data/TiffHandlerState.cpp
new file mode 100644
index 0000000..2e95125
--- /dev/null
+++ b/src/support_data/TiffHandlerState.cpp
@@ -0,0 +1,822 @@
+#include <ossim/support_data/TiffHandlerState.h>
+#include <ossim/base/ossimStreamFactoryRegistry.h>
+#include <ossim/support_data/ossimGeoTiff.h>
+#include <ossim/base/ossimTieGptSet.h>
+#include <ossim/base/ossimTrace.h>
+#include <ossim/projection/ossimUtmpt.h>
+#include <ossim/projection/ossimMapProjection.h>
+#include <ossim/projection/ossimBilinearProjection.h>
+#include <ossim/projection/ossimEpsgProjectionFactory.h>
+#include <ossim/projection/ossimProjectionFactoryRegistry.h>
+#include <ossim/base/ossimGeoTiffCoordTransformsLut.h>
+#include <ossim/base/ossimGeoTiffDatumLut.h>
+#include <ossim/base/ossimStreamFactoryRegistry.h>
+#include <ossim/support_data/TiffStreamAdaptor.h>
+#include <xtiffio.h>
+#include <geo_normalize.h>
+#include <geotiff.h>
+#include <geovalues.h>
+#include <cstddef> //nullptr
+#include <sstream>
+static ossimTrace traceDebug("ossim::TiffHandlerState");
+
+static const ossimGeoTiffCoordTransformsLut COORD_TRANS_LUT;
+static const ossimGeoTiffDatumLut DATUM_LUT;
+
+const ossimString ossim::TiffHandlerState::m_typeName = "ossim::TiffHandlerState";
+
+ossim::TiffHandlerState::TiffHandlerState()
+{
+
+}
+      
+ossim::TiffHandlerState::~TiffHandlerState()
+{
+
+}
+
+const ossimString& ossim::TiffHandlerState::getTypeName()const
+{
+   return m_typeName;
+}
+
+const ossimString& ossim::TiffHandlerState::getStaticTypeName()
+{
+   return m_typeName;
+}
+
+void ossim::TiffHandlerState::addValue(const ossimString& key, 
+                                       const ossimString& value)
+{
+  m_tags.add(key.c_str(), value.c_str());
+}
+
+bool ossim::TiffHandlerState::getValue(ossimString& value,
+                                       const ossim_uint32 directory, 
+                                        const ossimString& key)const
+{
+  return getValue(value, 
+                  "dir"+ossimString::toString(directory)+"."+key);
+}
+
+bool ossim::TiffHandlerState::getValue(ossimString& value,
+                                       const ossimString& key)const
+{
+  bool result = false;
+
+  const char* v = m_tags.find(key.c_str());
+  if(v)
+  {
+    result = true;
+    value  = v;
+  }
+
+  return result;
+}
+
+bool ossim::TiffHandlerState::exists(ossim_uint32 directory, const ossimString& key)const
+{
+  return exists("dir"+
+                ossimString::toString(directory)+
+                "."+key);
+
+}
+bool ossim::TiffHandlerState::exists(const ossimString& key)const
+{
+  return (m_tags.find(key)!= 0);
+
+}
+
+bool ossim::TiffHandlerState::checkBool(ossim_uint32 directory, const ossimString& key)const
+{
+  return checkBool("dir"+ossimString::toString(directory)+"."+key);
+}
+
+bool ossim::TiffHandlerState::checkBool(const ossimString& key)const
+{
+  bool result = false;
+  const char* value = m_tags.find(key);
+  if(value)
+  {
+    result = ossimString(value).toBool();
+  }
+  return result;
+}
+
+bool ossim::TiffHandlerState::loadDefaults(const ossimFilename& file, 
+                                           ossim_uint32 entry)
+{
+  bool result = ImageHandlerState::loadDefaults(file, entry);
+  
+  if(result)
+  {
+    std::shared_ptr<std::istream> tiffStream = ossim::StreamFactoryRegistry::instance()->createIstream(file);
+    if(tiffStream)
+    {
+       std::shared_ptr<ossim::TiffIStreamAdaptor> streamAdaptor = std::make_shared<ossim::TiffIStreamAdaptor>(tiffStream,
+                                                                   file.c_str());
+       TIFF* tiffPtr = XTIFFClientOpen(file.c_str(), "rm", 
+                                    (thandle_t)streamAdaptor.get(),
+                                    ossim::TiffIStreamAdaptor::tiffRead, 
+                                    ossim::TiffIStreamAdaptor::tiffWrite, 
+                                    ossim::TiffIStreamAdaptor::tiffSeek, 
+                                    ossim::TiffIStreamAdaptor::tiffClose, 
+                                    ossim::TiffIStreamAdaptor::tiffSize,
+                                    ossim::TiffIStreamAdaptor::tiffMap, 
+                                    ossim::TiffIStreamAdaptor::tiffUnmap);
+
+       if(tiffPtr)
+       {
+         loadDefaults(tiffPtr);
+         result = true;
+         XTIFFClose(tiffPtr);
+         tiffPtr = 0;
+       }
+    }    
+  }
+
+  return result;
+}
+
+void ossim::TiffHandlerState::loadDefaults(TIFF* tiffPtr)
+{
+  ossim_int64   currentDirectory = TIFFCurrentDirectory(tiffPtr);
+  TIFFSetDirectory(tiffPtr, 0);
+  ossim_int32   numberOfDirectories = TIFFNumberOfDirectories(tiffPtr);
+
+  addValue("number_of_directories", ossimString::toString(numberOfDirectories));
+
+  ossim_int32 idx=0;
+  for(;idx < numberOfDirectories;++idx)
+  {
+    if (!TIFFSetDirectory(tiffPtr, idx))
+    {
+       break;
+    }
+    else
+    {
+      loadDirectory(tiffPtr, idx);
+    }
+  }
+  TIFFSetDirectory(tiffPtr, currentDirectory);
+}
+
+
+void ossim::TiffHandlerState::loadCurrentDirectory(TIFF* tiffPtr)
+{
+  if(tiffPtr) 
+  {
+    loadDirectory(tiffPtr, TIFFCurrentDirectory(tiffPtr));
+  }
+}
+
+void ossim::TiffHandlerState::loadDirectory(TIFF* tiffPtr, 
+                                            ossim_uint32 directory)
+{
+  ossim_uint32  imageWidth=0;
+  ossim_uint32  imageLength=0;
+  ossim_int32   readMethod=0;
+  ossim_uint16  planarConfig=0;
+  ossim_uint16  photometric=0;
+  ossim_uint32  rowsPerStrip=0;
+  ossim_uint32  imageTileWidth=0;
+  ossim_uint32  imageTileLength=0;
+  ossim_uint32  imageDirectoryList=0;
+  ossim_int32   compressionType=0;
+  ossim_uint32  subFileType=0;
+  ossim_uint16  bitsPerSample=0;
+  ossim_uint16  samplesPerPixel=0;
+  ossim_uint16  sampleFormatUnit=0;
+  ossim_float64 sampleValue=0;
+  ossim_uint16  sampleUintValue = 0;
+
+  ossim_int32   numberOfDirectories = TIFFNumberOfDirectories(tiffPtr);
+
+  addValue("number_of_directories", ossimString::toString(numberOfDirectories));
+
+  if(TIFFCurrentDirectory(tiffPtr) != directory)
+  {
+    if(!TIFFSetDirectory(tiffPtr, directory))
+    {
+      return;
+    }
+  }
+  ossimString dirPrefix = "dir"+ossimString::toString(directory)+".";
+
+  if(TIFFGetField(tiffPtr, TIFFTAG_COMPRESSION, &compressionType))
+  {
+    addValue(dirPrefix+"tifftag.compression", ossimString::toString(compressionType));
+  } 
+
+  if( TIFFGetField(tiffPtr, TIFFTAG_BITSPERSAMPLE, &bitsPerSample) )
+  {
+    addValue(dirPrefix+"tifftag.bits_per_sample", ossimString::toString(bitsPerSample));
+  }
+  if( TIFFGetField(tiffPtr,
+                   TIFFTAG_SAMPLESPERPIXEL,
+                   &samplesPerPixel ) )
+  {
+    addValue(dirPrefix+"tifftag.samples_per_pixel", ossimString::toString(samplesPerPixel));
+  }
+
+  if ( TIFFGetField( tiffPtr,
+                     TIFFTAG_SAMPLEFORMAT,
+                     &sampleFormatUnit ) )
+  {
+    addValue(dirPrefix+"tifftag.sample_format", ossimString::toString(sampleFormatUnit));
+  }
+
+  if (TIFFGetField(tiffPtr,
+                   TIFFTAG_SMAXSAMPLEVALUE,
+                    &sampleValue ) )
+  {
+    addValue(dirPrefix+"tifftag.max_sample_value", ossimString::toString(sampleValue));
+  }
+  else
+  {
+    if(TIFFGetField( tiffPtr,
+                      TIFFTAG_MAXSAMPLEVALUE,
+                      &sampleUintValue))
+    {
+      addValue(dirPrefix+"tifftag.max_sample_value", ossimString::toString(sampleUintValue));
+    }
+
+  }
+
+  if ( TIFFGetField( tiffPtr,
+                     TIFFTAG_SMINSAMPLEVALUE,
+                     &sampleValue ) )
+  {
+    addValue(dirPrefix+"tifftag.min_sample_value", ossimString::toString(sampleValue));
+  }
+  else
+  {
+    if(TIFFGetField( tiffPtr,
+                      TIFFTAG_MINSAMPLEVALUE,
+                      &sampleUintValue))
+    {
+      addValue(dirPrefix+"tifftag.min_sample_value", ossimString::toString(sampleUintValue));
+    }
+  }
+
+    
+  // lines:
+  if ( TIFFGetField( tiffPtr,
+                      TIFFTAG_IMAGELENGTH,
+                      &imageLength ) )
+  {
+    addValue(dirPrefix+"tifftag.image_length", 
+             ossimString::toString(imageLength));
+  }
+
+  // samples:
+  if ( TIFFGetField( tiffPtr,
+                      TIFFTAG_IMAGEWIDTH,
+                      &imageWidth ) )
+  {
+    addValue(dirPrefix+"tifftag.image_width", 
+             ossimString::toString(imageWidth));
+  }
+  
+  if (TIFFGetField(tiffPtr,
+                   TIFFTAG_SUBFILETYPE ,
+                   &subFileType ) )
+  {
+    addValue(dirPrefix+"tifftag.sub_file_type", ossimString::toString(subFileType));
+  }
+
+  if( TIFFGetField( tiffPtr, TIFFTAG_PLANARCONFIG,
+                     &planarConfig ) )
+  {
+    addValue(dirPrefix+"tifftag.planar_config", 
+             ossimString::toString(planarConfig));
+  }
+  
+  if( TIFFGetField( tiffPtr, TIFFTAG_PHOTOMETRIC,
+                     &photometric ) )
+  {
+    addValue(dirPrefix+"tifftag.photometric", 
+             ossimString::toString(photometric));
+  }
+
+  // Check for palette.
+  ossim_uint16* red;
+  ossim_uint16* green;
+  ossim_uint16* blue;
+  if(TIFFGetField(tiffPtr, TIFFTAG_COLORMAP, &red, &green, &blue))
+  {
+    if(bitsPerSample)
+    {
+      saveColorMap(dirPrefix, red, green, blue, 1<<bitsPerSample);
+    }
+  }
+
+  if( TIFFIsTiled(tiffPtr))
+  {
+    addValue(dirPrefix+"is_tiled", "true");
+    if ( TIFFGetField( tiffPtr,
+                       TIFFTAG_TILEWIDTH,
+                       &imageTileWidth ) )
+    {
+      addValue(dirPrefix+"tifftag.tile_width", 
+               ossimString::toString(imageTileWidth));
+    }
+    if ( TIFFGetField( tiffPtr,
+                       TIFFTAG_TILELENGTH,
+                       &imageTileLength ) )
+    {
+      addValue(dirPrefix+"tifftag.tile_length", 
+               ossimString::toString(imageTileLength));
+    }
+  }
+  else
+  {
+    addValue(dirPrefix+"tiff_is_tiled", "false");
+    if( TIFFGetField( tiffPtr, TIFFTAG_ROWSPERSTRIP,
+                      &rowsPerStrip ) )
+    {
+      addValue(dirPrefix+"tifftag.rows_per_strip", 
+               ossimString::toString(rowsPerStrip));
+    }
+  }
+
+  loadGeotiffTags(tiffPtr, dirPrefix);    
+}
+
+
+void ossim::TiffHandlerState::saveColorMap(const ossimString& dirPrefix,
+                                            const ossim_uint16* red, 
+                                            const ossim_uint16* green,
+                                            const ossim_uint16* blue,
+                                            ossim_uint32 numberOfEntries)
+{
+  ossim_uint32 idx = 0;
+  std::ostringstream redStream;
+  std::ostringstream greenStream;
+  std::ostringstream blueStream;
+  redStream << "(";
+  greenStream << "(";
+  blueStream << "(";  
+  for(;idx < (numberOfEntries-1);++idx,++red,++green,++blue)
+  {
+    redStream   << *red << ",";
+    greenStream << *green << ",";
+    blueStream  << *blue << ",";
+    if((idx%16)==0)
+    {
+      redStream   << "\n";
+      greenStream << "\n";
+      blueStream  << "\n";      
+    }
+  }  
+  redStream   << *red << ")";
+  greenStream << *green << ")";
+  blueStream  << *blue << ")";
+  
+  addValue(dirPrefix+"tifftag.colormap.red", 
+           redStream.str());
+  addValue(dirPrefix+"tifftag.colormap.green", 
+           greenStream.str());
+  addValue(dirPrefix+"tifftag.colormap.blue", 
+           blueStream.str());
+}
+
+void ossim::TiffHandlerState::loadGeotiffTags(TIFF* tiffPtr,
+                                              const ossimString& dirPrefix )
+{
+  const int CITATION_STRING_SIZE = 512;
+  ossim_uint16 rasterType = 0;
+  ossim_uint16 pcsCode = 0;
+  ossim_uint16 coordTransGeoCode = 0;
+  ossim_uint32 idx = 0;
+  GTIF* gtif = GTIFNew(tiffPtr);
+  char citationStrPtr[CITATION_STRING_SIZE];
+  char* buf = 0;
+  ossim_uint16 doubleArraySize = 0;
+  double tempDouble=0.0;
+  double* doubleArray=0;
+  ossimString doubleArrayStr;
+  bool loadedGeotiff = false;
+  if(!gtif)
+  {
+    addValue(dirPrefix+"is_geotiff", "false");
+    return;
+  } 
+
+  // Note:  For some reason I am having troubles using
+  // GTIFGetDefn so I have to query them directly.  I was getting
+  // Core dumps in the JNI calls to the OSSIM core library.
+  // Until this is resolved I will use the direct method of getting
+  // the values I need.
+  //
+  ossim_uint16 tempUint16 = 0; 
+  if(GTIFKeyGet(gtif, GTModelTypeGeoKey, &tempUint16, 0, 1))
+  {
+    loadedGeotiff = true;
+    addValue(dirPrefix+"tifftag.model_type", 
+           ossimString::toString(tempUint16));
+  }
+  if(GTIFKeyGet(gtif, GeographicTypeGeoKey, &tempUint16, 0, 1))
+  {
+    loadedGeotiff = true;
+    addValue(dirPrefix+"tifftag.gcs_code", 
+           ossimString::toString(tempUint16));
+  }
+  if(GTIFKeyGet(gtif, GeogGeodeticDatumGeoKey, &tempUint16, 0, 1))
+  {
+    loadedGeotiff = true;
+    addValue(dirPrefix+"tifftag.datum_code", 
+           ossimString::toString(tempUint16));
+  }
+  if(GTIFKeyGet(gtif, GeogAngularUnitsGeoKey, &tempUint16, 0, 1))
+  {
+    loadedGeotiff = true;
+    addValue(dirPrefix+"tifftag.angular_units", 
+           ossimString::toString(tempUint16));
+  }
+  if(GTIFKeyGet(gtif, GeogLinearUnitsGeoKey, &tempUint16, 0, 1))
+  {
+    loadedGeotiff = true;
+    addValue(dirPrefix+"tifftag.linear_units", 
+           ossimString::toString(tempUint16));
+  }
+
+  if(GTIFKeyGet(gtif, ProjStdParallel1GeoKey, &tempDouble, 0, 1))
+  {
+    loadedGeotiff = true;
+    addValue(dirPrefix+"tifftag.std_parallel_1", 
+            ossimString::toString(tempDouble));
+  }
+  if(GTIFKeyGet(gtif, ProjStdParallel2GeoKey, &tempDouble, 0, 1))
+  {
+    loadedGeotiff = true;
+    addValue(dirPrefix+"tifftag.std_parallel_2", 
+            ossimString::toString(tempDouble));
+  }
+  if(GTIFKeyGet(gtif, ProjNatOriginLongGeoKey, &tempDouble, 0, 1))
+  {
+    loadedGeotiff = true;
+    addValue(dirPrefix+"tifftag.origin_lon", 
+            ossimString::toString(tempDouble));
+  }
+  else if(GTIFKeyGet(gtif, ProjOriginLongGeoKey, &tempDouble, 0, 1))
+  {
+    loadedGeotiff = true;
+    addValue(dirPrefix+"tifftag.origin_lon", 
+            ossimString::toString(tempDouble));
+  }
+  if(GTIFKeyGet(gtif, ProjNatOriginLatGeoKey, &tempDouble, 0, 1))
+  {
+    loadedGeotiff = true;
+    addValue(dirPrefix+"tifftag.origin_lat", 
+            ossimString::toString(tempDouble));
+  }
+  else if(GTIFKeyGet(gtif, ProjOriginLatGeoKey, &tempDouble, 0, 1))
+  {
+    loadedGeotiff = true;
+    addValue(dirPrefix+"tifftag.origin_lat", 
+            ossimString::toString(tempDouble));
+  }
+  if(GTIFKeyGet(gtif, ProjFalseEastingGeoKey, &tempDouble, 0, 1))
+  {
+    loadedGeotiff = true;
+    addValue(dirPrefix+"tifftag.false_easting", 
+            ossimString::toString(tempDouble));
+  }
+  if(GTIFKeyGet(gtif, ProjFalseNorthingGeoKey, &tempDouble, 0, 1))
+  {
+    loadedGeotiff = true;
+    addValue(dirPrefix+"tifftag.false_northing", 
+            ossimString::toString(tempDouble));
+  }
+  if(GTIFKeyGet(gtif, ProjCenterLongGeoKey, &tempDouble, 0, 1))
+  {
+    loadedGeotiff = true;
+    addValue(dirPrefix+"tifftag.center_lon", 
+            ossimString::toString(tempDouble));
+  }
+  if(GTIFKeyGet(gtif, ProjCenterLatGeoKey, &tempDouble, 0, 1))
+  {
+    loadedGeotiff = true;
+    addValue(dirPrefix+"tifftag.center_lat", 
+            ossimString::toString(tempDouble));
+  }
+  if(GTIFKeyGet(gtif, ProjScaleAtNatOriginGeoKey, &tempDouble, 0, 1))
+  {
+    loadedGeotiff = true;
+    addValue(dirPrefix+"tifftag.scale_factor", 
+            ossimString::toString(tempDouble));
+  }
+  if(GTIFKeyGet(gtif, GTRasterTypeGeoKey, &rasterType, 0, 1))
+  {
+    loadedGeotiff = true;
+    addValue(dirPrefix+"tifftag.raster_type", 
+             ossimString::toString(rasterType));
+
+  }
+  if (GTIFKeyGet(gtif, ProjectedCSTypeGeoKey, &pcsCode, 0, 1))
+  {
+    loadedGeotiff = true;
+    addValue(dirPrefix+"tifftag.pcs_code", 
+             ossimString::toString(pcsCode));
+  }
+
+  if ( GTIFKeyGet(gtif, GTCitationGeoKey, &citationStrPtr ,
+                  0, CITATION_STRING_SIZE))
+  {
+    loadedGeotiff = true;
+    addValue(dirPrefix+"tifftag.citation", 
+             ossimString(citationStrPtr));
+  }
+  if(GTIFKeyGet(gtif, PCSCitationGeoKey , &buf, 0, 1))
+  {
+    loadedGeotiff = true;
+    addValue(dirPrefix+"tifftag.pcs_citation", 
+             buf);
+  }
+  if(GTIFKeyGet(gtif, ProjCoordTransGeoKey , &coordTransGeoCode, 0, 1))
+  {
+    loadedGeotiff = true;
+    addValue(dirPrefix+"tifftag.coord_trans_code", 
+             ossimString::toString(coordTransGeoCode));
+  }
+
+  if(TIFFGetField(tiffPtr, TIFFTAG_GEOPIXELSCALE, &doubleArraySize, &doubleArray))
+  {
+    loadedGeotiff = true;
+    convertArrayToStringList(doubleArrayStr, doubleArray, doubleArraySize);
+    if(!doubleArrayStr.empty())
+    {
+      addValue(dirPrefix+"tifftag.geo_pixel_scale", doubleArrayStr);
+    }
+  }
+  if(TIFFGetField(tiffPtr, TIFFTAG_GEOTIEPOINTS,  &doubleArraySize, &doubleArray))
+  {
+    loadedGeotiff = true;
+    convertArrayToStringList(doubleArrayStr, doubleArray, doubleArraySize);
+    if(!doubleArrayStr.empty())
+    {
+      addValue(dirPrefix+"tifftag.geo_tie_points", doubleArrayStr);
+    }
+  }
+  if(TIFFGetField(tiffPtr, TIFFTAG_GEODOUBLEPARAMS, &doubleArraySize, &doubleArray))
+  {
+    loadedGeotiff = true;
+    convertArrayToStringList(doubleArrayStr, doubleArray, doubleArraySize);
+    if(!doubleArrayStr.empty())
+    {
+      addValue(dirPrefix+"tifftag.geo_double_params", doubleArrayStr);
+    }
+  }
+  if(TIFFGetField(tiffPtr, TIFFTAG_GEOTRANSMATRIX, &doubleArraySize, &doubleArray))
+  {
+    loadedGeotiff = true;
+    convertArrayToStringList(doubleArrayStr, doubleArray, doubleArraySize);
+    if(!doubleArrayStr.empty())
+    {
+      addValue(dirPrefix+"tifftag.geo_trans_matrix", doubleArrayStr);
+    }
+  }
+  if(TIFFGetField(tiffPtr, TIFFTAG_GEOASCIIPARAMS, &buf))
+  {
+    loadedGeotiff = true;
+    addValue(dirPrefix+"tifftag.geo_ascii_params", buf);
+  }
+  addValue(dirPrefix+"is_geotiff", ossimString::toString(loadedGeotiff));
+  GTIFFree(gtif);
+}
+
+bool ossim::TiffHandlerState::isReduced(ossim_uint32 directory)const
+{
+  return getInt32Value("tifftag.sub_file_type", directory)&FILETYPE_REDUCEDIMAGE;
+}
+
+bool ossim::TiffHandlerState::isMask(ossim_uint32 directory)const
+{
+  return getInt32Value("tifftag.sub_file_type", directory)&FILETYPE_MASK;
+}
+
+bool ossim::TiffHandlerState::isPage(ossim_uint32 directory)const
+{
+  return getInt32Value("tifftag.sub_file_type", directory)&FILETYPE_PAGE;
+}
+
+bool ossim::TiffHandlerState::isTiled(ossim_uint32 directory)const
+{
+  return checkBool(directory, "is_tiled");
+}
+
+void ossim::TiffHandlerState::convertArrayToStringList(ossimString& result, double* doubleArray, ossim_int32 doubleArraySize)const
+{
+  ossim_int32 idx = 0;
+  result = "";
+  if(doubleArray && (doubleArraySize > 0))
+  {
+    ossim_int32 precision = 20;
+    std::ostringstream doubleArrayStream;
+    doubleArrayStream << "(";
+    for(idx = 0; idx < doubleArraySize-1;++idx)
+    {
+      doubleArrayStream << ossimString::toString(doubleArray[idx],20) << ",";
+    }
+    doubleArrayStream << ossimString::toString(doubleArray[idx],20) << ")";
+    result = doubleArrayStream.str();
+  }
+}
+
+ossim_int32 ossim::TiffHandlerState::getModelType(ossim_int32 directory)const
+{
+  return getInt32Value("tifftag.model_type", directory);
+}
+
+ossim_int32 ossim::TiffHandlerState::getAngularUnits(ossim_int32 directory)const
+{
+  return getInt32Value("tifftag.angular_units", directory);
+}
+
+ossim_int32 ossim::TiffHandlerState::getLinearUnits(ossim_int32 directory)const
+{
+  return getInt32Value("tifftag.linear_units", directory);
+}
+
+ossim_int32 ossim::TiffHandlerState::getRasterType(ossim_int32 directory)const
+{
+  return getInt32Value("tifftag.raster_type", directory);
+}
+
+ossim_int32 ossim::TiffHandlerState::getDatumCode(ossim_int32 directory)const
+{
+  return getInt32Value("tifftag.datum_code", directory);
+}
+
+ossim_int32 ossim::TiffHandlerState::getPcsCode(ossim_int32 directory)const
+{
+  return getInt32Value("tifftag.pcs_code", directory);
+}
+
+ossim_int32 ossim::TiffHandlerState::getGcsCode(ossim_int32 directory)const
+{
+
+  return getInt32Value("tifftag.gcs_code", directory);
+}
+
+ossim_int32 ossim::TiffHandlerState::getInt32Value(const ossimString& key, 
+                                                    ossim_int32 directory)const
+{
+  ossimString tempStr;
+  
+  if(getValue(tempStr, directory, key))
+  {
+    return tempStr.toDouble();
+  }
+  
+  return ossimGeoTiff::UNDEFINED;    
+}
+
+
+ossim_float64 ossim::TiffHandlerState::getDoubleValue(const ossimString& key, 
+                                                      ossim_int32 directory)const
+{
+  ossimString tempStr;
+  
+  if(getValue(tempStr, directory, key))
+  {
+    return tempStr.toDouble();
+  }
+  
+  return ossim::nan();  
+}
+
+ossim_float64 ossim::TiffHandlerState::getOriginLat(ossim_int32 directory)const
+{
+  return getDoubleValue("tifftag.origin_lat", directory);  
+}
+
+ossim_float64 ossim::TiffHandlerState::getOriginLon(ossim_int32 directory)const
+{
+  return getDoubleValue("tifftag.origin_lon", directory);  
+}
+
+ossim_float64 ossim::TiffHandlerState::getStandardParallel1(ossim_int32 directory)const
+{
+  return getDoubleValue("tifftag.std_parallel_1", directory);  
+}
+
+ossim_float64 ossim::TiffHandlerState::getStandardParallel2(ossim_int32 directory)const
+{
+  return getDoubleValue("tifftag.std_parallel_2", directory);  
+}
+
+ossim_float64 ossim::TiffHandlerState::getFalseEasting(ossim_int32 directory)const
+{
+  return getDoubleValue("tifftag.false_easting", directory);  
+}
+
+ossim_float64 ossim::TiffHandlerState::getFalseNorthing(ossim_int32 directory)const
+{
+  return getDoubleValue("tifftag.false_northing", directory);  
+
+}
+
+ossim_float64 ossim::TiffHandlerState::getScaleFactor(ossim_int32 directory)const
+{
+  return getDoubleValue("tifftag.scale_factor", directory);  
+}
+
+ossim_int64 ossim::TiffHandlerState::getImageLength(ossim_int32 directory)const
+{
+  ossimString tempStr;
+
+  if(getValue(tempStr, directory, "tifftag.image_length"))
+  {
+    return tempStr.toInt64();
+  }
+
+  return 0;
+}
+
+ossim_int64 ossim::TiffHandlerState::getImageWidth(ossim_int32 directory)const
+{
+  ossimString tempStr;
+
+  if(getValue(tempStr, directory, "tifftag.image_width"))
+  {
+    return tempStr.toInt64();
+  }
+
+  return 0;
+}
+
+bool ossim::TiffHandlerState::getDoubleArray(std::vector<ossim_float64>& result, 
+                                              ossim_int32 directory,
+                                              const ossimString& key)const
+{
+  ossimString tempStr;
+
+  if(getValue(tempStr, directory, key))
+  {
+    if(!tempStr.empty())
+    {
+      if(!toSimpleVector(result, tempStr))
+      {
+        result.clear();
+      }
+      tempStr="";
+    }
+  }
+
+  return !result.empty();
+
+}
+
+bool ossim::TiffHandlerState::getGeoDoubleParams(std::vector<ossim_float64>& result,
+                                                 ossim_int32 directory)const
+{
+  return getDoubleArray(result, directory, "tifftag.geo_double_params");
+}
+
+bool ossim::TiffHandlerState::getGeoPixelScale(std::vector<ossim_float64>& result,
+                                                 ossim_int32 directory)const
+{
+  return getDoubleArray(result, directory, "tifftag.geo_pixel_scale");
+}
+
+bool ossim::TiffHandlerState::getGeoTiePoints(std::vector<ossim_float64>& result,
+                                              ossim_int32 directory)const
+{
+  return getDoubleArray(result, directory, "tifftag.geo_tie_points");
+}
+
+bool ossim::TiffHandlerState::getGeoTransMatrix(std::vector<ossim_float64>& result,
+                                              ossim_int32 directory)const
+{
+  return getDoubleArray(result, directory, "tifftag.geo_trans_matrix");
+}
+
+bool ossim::TiffHandlerState::load(const ossimKeywordlist& kwl,
+                                   const ossimString& prefix)
+{
+  bool result = ossim::ImageHandlerState::load(kwl, prefix);
+  m_tags.clear();
+
+  kwl.extractKeysThatMatch(m_tags, "^("+prefix+"dir[0-9]+)");
+  if(!prefix.empty())
+  {
+    m_tags.stripPrefixFromAll("^("+prefix+")");
+  }
+  ossimString numberOfDirectories = kwl.find(prefix, "number_of_directories");
+
+  if(!numberOfDirectories.empty()) m_tags.add("number_of_directories", numberOfDirectories, true);
+
+  return result;
+}
+
+bool ossim::TiffHandlerState::save(ossimKeywordlist& kwl,
+                                   const ossimString& prefix)const
+{
+   bool result = ossim::ImageHandlerState::save(kwl, prefix);
+   
+   kwl.add(prefix.c_str(), m_tags);
+
+   return result;
+}
diff --git a/src/support_data/TiffStreamAdaptor.cpp b/src/support_data/TiffStreamAdaptor.cpp
new file mode 100644
index 0000000..3322a1a
--- /dev/null
+++ b/src/support_data/TiffStreamAdaptor.cpp
@@ -0,0 +1,99 @@
+#include <ossim/support_data/TiffStreamAdaptor.h>
+
+
+tsize_t ossim::TiffIStreamAdaptor::tiffRead(thandle_t st,tdata_t buffer,tsize_t size)
+{
+   TiffIStreamAdaptor* streamAdaptor = static_cast<TiffIStreamAdaptor*>(st);
+   tsize_t result = -1;
+   std::shared_ptr<ossim::istream> is = streamAdaptor->getStream();
+   if(is)
+   {
+      if(!is->good()) is->clear();
+      is->read((char*)buffer, size);
+
+      result = is->gcount();
+   }
+
+   return result;
+};
+
+tsize_t ossim::TiffIStreamAdaptor::tiffWrite(thandle_t st, tdata_t buffer,tsize_t size)
+{
+   return -1;
+};
+
+int ossim::TiffIStreamAdaptor::tiffClose(thandle_t st)
+{
+   TiffIStreamAdaptor* streamAdaptor = static_cast<TiffIStreamAdaptor*>(st);
+
+   streamAdaptor->close();
+   
+   return 0;
+};
+
+toff_t ossim::TiffIStreamAdaptor::tiffSeek(thandle_t st,toff_t pos, int whence)
+{
+   TiffIStreamAdaptor* streamAdaptor = static_cast<TiffIStreamAdaptor*>(st);
+   toff_t result = -1;
+   std::ios_base::seekdir seekDir = std::ios::beg;
+   std::shared_ptr<ossim::istream> is = streamAdaptor->getStream();
+
+   
+   if(is)
+   {
+      // Because we are adapting, on each seek we need to clear our previous error so 
+      // we can continue on.  Do not want the stream to stay in a failed state.
+      //
+      if(!is->good()) is->clear();
+
+      switch(whence)
+      {
+         case 0: // SEEK_SET
+         {
+          seekDir = std::ios::beg;
+          break;
+         }
+         case 1: // SEEK_CUR
+         {
+            seekDir = std::ios::cur;
+            break;
+         }
+         case 2: // SEEK_END
+         {
+           seekDir = std::ios::end;
+            break;
+         }
+      }
+
+      is->seekg(pos, seekDir);
+      result = is->tellg();
+   }
+
+   return result;
+};
+
+toff_t ossim::TiffIStreamAdaptor::tiffSize(thandle_t st)
+{
+   toff_t result = -1;
+   TiffIStreamAdaptor* streamAdaptor = static_cast<TiffIStreamAdaptor*>(st);
+   std::shared_ptr<ossim::istream> is = streamAdaptor->getStream();
+   if (is)
+   {
+      if(!is->good()) is->clear();
+      ossim_int64 currentOffset = is->tellg();
+      is->seekg(0, std::ios::end);
+      result = is->tellg();
+      is->seekg(currentOffset);
+   }
+   return result;
+};
+
+int ossim::TiffIStreamAdaptor::tiffMap(thandle_t, tdata_t*, toff_t*)
+{
+    return 0;
+};
+
+void ossim::TiffIStreamAdaptor::tiffUnmap(thandle_t, tdata_t, toff_t)
+{
+    return;
+};
diff --git a/src/support_data/ossimAlphaSensorSupportData.cpp b/src/support_data/ossimAlphaSensorSupportData.cpp
index e283eac..4be5dae 100644
--- a/src/support_data/ossimAlphaSensorSupportData.cpp
+++ b/src/support_data/ossimAlphaSensorSupportData.cpp
@@ -215,7 +215,7 @@ bool ossimAlphaSensorSupportData::readHdrFile(const ossimEnviHeader& hdr)
       }
 
       // Set the hsi flag:
-      if ( m_sensorType.contains("HSI") || (hdr.getBands() > 63 ) ) // arbitrary...
+      if ( m_sensorType.contains("HSI") || (hdr.getBands() > 7 ) ) // arbitrary...
       {
          m_isHSI = true;
       }
@@ -449,7 +449,7 @@ bool ossimAlphaSensorSupportData::readInsGpsFile(const ossimFilename& file)
          {
             ossimNotify(ossimNotifyLevel_DEBUG)
                << "\n SA  poly deg, rms error = "
-               << SCAN_ANGLE_DEG << ", " << ossim::radiansToDegrees(rms) << " deg";
+               << SCAN_ANGLE_DEG << ", " << ossim::radiansToDegrees(rms) << " deg\n";
          }
       }
       if (result)
@@ -459,7 +459,7 @@ bool ossimAlphaSensorSupportData::readInsGpsFile(const ossimFilename& file)
          {
             ossimNotify(ossimNotifyLevel_DEBUG)
                << "\n R   poly deg, rms error = "
-               << ROLL_DEG << ", " << ossim::radiansToDegrees(rms) << " deg";
+               << ROLL_DEG << ", " << ossim::radiansToDegrees(rms) << " deg\n";
          }
 
          if (result)
@@ -469,7 +469,7 @@ bool ossimAlphaSensorSupportData::readInsGpsFile(const ossimFilename& file)
             {
                ossimNotify(ossimNotifyLevel_DEBUG)
                   << "\n P   poly deg, rms error = "
-                  << PITCH_DEG << ", " << ossim::radiansToDegrees(rms) << " deg";
+                  << PITCH_DEG << ", " << ossim::radiansToDegrees(rms) << " deg\n";
             }
 
             if (result)
@@ -479,7 +479,7 @@ bool ossimAlphaSensorSupportData::readInsGpsFile(const ossimFilename& file)
                {
                   ossimNotify(ossimNotifyLevel_DEBUG)
                      << "\n H   poly deg, rms error = "
-                     << HEADING_DEG << ", " << ossim::radiansToDegrees(rms) << " deg";
+                     << HEADING_DEG << ", " << ossim::radiansToDegrees(rms) << " deg\n";
                }
 
                if (result)
@@ -489,7 +489,7 @@ bool ossimAlphaSensorSupportData::readInsGpsFile(const ossimFilename& file)
                   {
                      ossimNotify(ossimNotifyLevel_DEBUG)
                         << "\n Lon poly deg, rms error = "
-                        << LON_DEG << ", " << ossim::radiansToDegrees(rms) << " deg";
+                        << LON_DEG << ", " << ossim::radiansToDegrees(rms) << " deg\n";
                   }
 
                   if (result)
@@ -499,7 +499,7 @@ bool ossimAlphaSensorSupportData::readInsGpsFile(const ossimFilename& file)
                      {
                         ossimNotify(ossimNotifyLevel_DEBUG)
                            << "\n Lat poly deg, rms error = "
-                           << LAT_DEG << ", " << ossim::radiansToDegrees(rms) << " deg";
+                           << LAT_DEG << ", " << ossim::radiansToDegrees(rms) << " deg\n";
                      }
 
                      if (result)
@@ -509,7 +509,7 @@ bool ossimAlphaSensorSupportData::readInsGpsFile(const ossimFilename& file)
                         {
                            ossimNotify(ossimNotifyLevel_DEBUG)
                               << "\n Alt poly deg, rms error = "
-                              << ALT_DEG << ", " << rms << " mtr";
+                              << ALT_DEG << ", " << rms << " mtr" << std::endl;
                         }
                      }
                   }
diff --git a/src/support_data/ossimGeoTiff.cpp b/src/support_data/ossimGeoTiff.cpp
index 879c6de..fcf6ce1 100644
--- a/src/support_data/ossimGeoTiff.cpp
+++ b/src/support_data/ossimGeoTiff.cpp
@@ -50,7 +50,7 @@
 
 static const ossimGeoTiffCoordTransformsLut COORD_TRANS_LUT;
 static const ossimGeoTiffDatumLut DATUM_LUT;
-OpenThreads::Mutex ossimGeoTiff::theMutex;
+std::mutex ossimGeoTiff::theMutex;
 
 #ifdef OSSIM_ID_ENABLED
 static const char OSSIM_ID[] = "$Id: ossimGeoTiff.cpp 21024 2012-05-30 08:45:13Z dburken $";
@@ -239,7 +239,7 @@ bool ossimGeoTiff::writeTags(TIFF* tifPtr,
                              const ossimRefPtr<ossimMapProjectionInfo> projectionInfo,
                              bool imagineNad27Flag)
 {
-   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(theMutex);
+   std::lock_guard<std::mutex> lock(theMutex);
 
    const ossimMapProjection* mapProj = projectionInfo->getProjection();
 
@@ -973,10 +973,156 @@ bool ossimGeoTiff::readTags(const ossimFilename& file, ossim_uint32 entryIdx)
    return result;
 }
 
+bool ossimGeoTiff::readTags(std::shared_ptr<ossim::TiffHandlerState> state, ossim_uint32 entryIdx)
+{
+   std::lock_guard<std::mutex> lock(theMutex);
+
+   if(!state) return false;
+
+   if(!state->checkBool(entryIdx, "is_geotiff"))
+   {
+      return false;
+   }
+   ossimString value;
+   theLength             = state->getImageLength(entryIdx);
+   theWidth              = state->getImageWidth(entryIdx);
+   theScaleFactor        = 0.0;
+   theModelType          = state->getModelType(entryIdx);
+   theGcsCode            = state->getGcsCode(entryIdx);
+   theDatumCode          = state->getDatumCode(entryIdx);
+   theAngularUnits       = state->getAngularUnits(entryIdx);
+   theLinearUnitsCode    = state->getLinearUnits(entryIdx);
+   theGeoKeysPresentFlag = true;
+
+   if (theAngularUnits == ANGULAR_DMS_HEMISPHERE || theAngularUnits == 9122)
+   {
+      //---
+      // Hack for bug, where the libgeotiff funtion GTIFGetDefn sets the angular units 
+      // incorrectly to ANGULAR_DMS_HEMISPHERE:
+      if ( traceDebug() )
+      {
+         ossimNotify(ossimNotifyLevel_WARN)
+            << " WARNING ossimGeoTiff::addImageGeometry:"           
+            << "The angular units (key 2054) is set to ANGULAR_DMS_HEMISPHERE!"  
+            << "\nAssuming \"Angular_Degree\"..." << std::endl;
+      }
+      theAngularUnits = ANGULAR_DEGREE;  
+   }
+
+  if (state->getValue(value, entryIdx, "tifftag.pcs_code"))
+  {
+    thePcsCode = value.toInt32();
+    parsePcsCode();    
+  }
+   //---
+   // ESH 2/2008 -- Handle geotiff's with state plane coordinate systems produced by ERDAS.
+   // They use the citation filed to specify the geometry (complete HACK by Erdas)
+   //---
+   else
+   {
+    ossimString gTCitation;
+    if(state->getValue(gTCitation, entryIdx, "tifftag.citation"))
+    {
+         // Extract state plane string from the citation key
+         ossimString projStrTemp =
+            gTCitation.afterRegExp( "Projection Name = " );
+         
+         ossimString projStr  = projStrTemp.beforeRegExp( "\n" );
+         if ( projStr.empty() == false )
+         {
+            ossimEpsgProjectionFactory* f = ossimEpsgProjectionFactory::instance();
+            ossimProjection* proj = f->createProjection(projStr);
+            ossimMapProjection* map_proj = PTR_CAST(ossimMapProjection, proj);
+            parseProjection(map_proj);
+         }
+      }  // End of "if(GTIFKeyGet(gtif, GTCitationGeoKey..."
+   }
+   
+   theOriginLon = ossim::nan();
+   theOriginLat = ossim::nan();
+   state->getValue(thePcsCitation, entryIdx, "tifftag.pcs_citation");
+   if(state->getValue(value, entryIdx, "tifftag.coord_trans_code"))
+   {
+      theCoorTransGeoCode = value.toInt32(); 
+   }
+   if(state->getValue(value, entryIdx, "tifftag.std_parallel_1"))
+   {
+      theStdPar1 = value.toDouble();
+   }
+   if(state->getValue(value, entryIdx, "tifftag.std_parallel_2"))
+   {
+      theStdPar2 = value.toDouble();
+   }
+   if(state->getValue(value, entryIdx, "tifftag.origin_lon"))
+   {
+      theOriginLon = value.toDouble();
+   }
+   else if(state->getValue(value, entryIdx, "tifftag.center_lon"))
+   {
+      theOriginLon = value.toDouble();
+   }
+   else if(state->getValue(value, entryIdx, "tifftag.false_origin_lon"))
+   {
+      theOriginLon = value.toDouble();
+   }
+   else if(state->getValue(value, entryIdx, "tifftag.straight_vert_pole_lon"))
+   {
+      theOriginLon = value.toDouble();
+   }
+
+   if(state->getValue(value, entryIdx, "tifftag.origin_lat"))
+   {
+      theOriginLat = value.toDouble();
+   }
+   else if(state->getValue(value, entryIdx, "tifftag.center_lat"))
+   {
+      theOriginLat = value.toDouble();
+   }
+   else if(state->getValue(value, entryIdx, "tifftag.false_origin_lat"))
+   {
+      theOriginLat = value.toDouble();
+   }
+
+   if(state->getValue(value, entryIdx, "tifftag.false_easting"))
+   {
+      theFalseEasting = value.toDouble();
+   }
+   if(state->getValue(value, entryIdx, "tifftag.false_northing"))
+   {
+      theFalseNorthing = value.toDouble();
+   }
+   if(state->getValue(value, entryIdx, "tifftag.scale_factor"))
+   {
+      theScaleFactor = value.toDouble();
+   }
+   theScale.clear();
+   if(state->getGeoPixelScale(theScale, entryIdx))
+   {
+      if ( theModelType == ModelTypeGeographic )
+      {
+         // The origin latitude must be computed so as to achieve the proper horizontal scaling:
+         theOriginLat = ossim::acosd(theScale[1]/theScale[0]);
+      }    
+   }
+   theTiePoint.clear();
+   state->getGeoTiePoints(theTiePoint, entryIdx);
+   theModelTransformation.clear();
+   state->getGeoTransMatrix(theModelTransformation, entryIdx);
+   theDoubleParam.clear();
+   state->getGeoDoubleParams(theDoubleParam, entryIdx);
+
+   state->getValue(theAsciiParam, entryIdx, "tifftag.geo_ascii_params");
+
+   setOssimProjectionName(state, entryIdx);
+   setOssimDatumName(state, entryIdx);
+
+   return true;
+}
+
 bool ossimGeoTiff::readTags(
    TIFF* tiff, ossim_uint32 entryIdx, bool ownTiffPtrFlag)
 {
-   OpenThreads::ScopedLock<OpenThreads::Mutex> lock(theMutex);
+   std::lock_guard<std::mutex> lock(theMutex);
 
    if ( !tiff )
    {
@@ -1803,6 +1949,46 @@ void ossimGeoTiff::setOssimProjectionName()
    
 }
 
+void ossimGeoTiff::setOssimProjectionName(std::shared_ptr<ossim::TiffHandlerState> state, ossim_int32 entryIdx)
+{
+  ossimString value;
+   //---
+   // The "parsePcsCode" method can also set the projection name.  So check
+   // it prior to looking in the lookup table.
+   //---
+   if (theProjectionName == "unknown")
+   {
+      if(state->getValue(value, entryIdx, "tifftag.coord_trans_code"))
+      {
+        ossimString name =  COORD_TRANS_LUT.getEntryString(value.toInt32());
+        
+        if (name.size())
+        {
+           theProjectionName = name;
+        }
+      }
+   }
+
+   // If still unknown check for the model type.
+   if (theProjectionName == "unknown")
+   {
+      if (theModelType == ModelTypeGeographic)
+      {
+         theProjectionName = "ossimEquDistCylProjection";
+      }
+   }
+
+   if (traceDebug())
+   {
+      ossimNotify(ossimNotifyLevel_DEBUG)
+         << "DEBUG ossimGeoTiff::setOssimProjectionName: "
+         << "theProjectionName:  "
+         << theProjectionName
+         << std::endl;
+   }
+   
+}
+
 ossimString ossimGeoTiff::getOssimDatumName() const
 {
    return theDatumName;
@@ -1842,6 +2028,48 @@ void ossimGeoTiff::setOssimDatumName()
    } 
 }
 
+void ossimGeoTiff::setOssimDatumName(std::shared_ptr<ossim::TiffHandlerState> state, 
+                                     ossim_int32 entryIdx)
+{
+  ossimString value;
+   //---
+   // The "parsePcsCode" method can also set the datum name.  So check
+   // it prior to trying to assign.
+   //---
+   if (theDatumName == "unknown")
+   {
+      if(state->getValue(value, entryIdx, "tifftag.datum_code"))
+      {
+        ossimString name = DATUM_LUT.getEntryString(value.toInt32());
+        
+        if (!name.empty())
+        {
+           theDatumName = name;
+        }
+        else
+        {
+           // Try the GCS code.
+           if(state->getValue(value, entryIdx, "tifftag.gcs_code"))
+           {
+             name = DATUM_LUT.getEntryString(value.toInt32());
+             if (name.size())
+             {
+                theDatumName = name;
+             }
+           }
+        }        
+      }
+   }
+   if (traceDebug())
+   {
+      ossimNotify(ossimNotifyLevel_DEBUG)
+         << "DEBUG ossimGeoTiff::setOssimDatumName: "
+         << "theDatumName:  "
+         << theDatumName
+         << std::endl;
+   } 
+}
+
 //*************************************************************************************************
 //! Initializes data members given a projection code. Returns TRUE if valid PCS code specified.
 //*************************************************************************************************
diff --git a/src/imaging/ossimImageMetaData.cpp b/src/support_data/ossimImageMetaData.cpp
similarity index 99%
rename from src/imaging/ossimImageMetaData.cpp
rename to src/support_data/ossimImageMetaData.cpp
index 87fc1e5..74f3541 100644
--- a/src/imaging/ossimImageMetaData.cpp
+++ b/src/support_data/ossimImageMetaData.cpp
@@ -12,7 +12,7 @@
 //*******************************************************************
 //  $Id: ossimImageMetaData.cpp 21745 2012-09-16 15:21:53Z dburken $
 
-#include <ossim/imaging/ossimImageMetaData.h>
+#include <ossim/support_data/ossimImageMetaData.h>
 #include <ossim/base/ossimCommon.h>
 #include <ossim/base/ossimKeywordlist.h>
 #include <ossim/base/ossimKeywordNames.h>
@@ -241,6 +241,7 @@ bool ossimImageMetaData::loadState(const ossimKeywordlist& kwl, const char* pref
 bool ossimImageMetaData::saveState(ossimKeywordlist& kwl,
 				   const char* prefix)const
 {
+   kwl.add(prefix, "type", "ossimImageMetaData", true);
    if ( theNumberOfBands )
    {
       ossim_uint32 band = 0;
diff --git a/src/support_data/ossimInfoBase.cpp b/src/support_data/ossimInfoBase.cpp
index 98e57be..4dfa064 100644
--- a/src/support_data/ossimInfoBase.cpp
+++ b/src/support_data/ossimInfoBase.cpp
@@ -32,8 +32,8 @@ bool ossimInfoBase::open(const ossimFilename& file)
    return open(str, connectionString);
 }
 
-bool ossimInfoBase::open(std::shared_ptr<ossim::istream>& str,
-                         const std::string& connectionString)
+bool ossimInfoBase::open(std::shared_ptr<ossim::istream>& /* str */,
+                         const std::string& /* connectionString */)
 {
    return false;
 }
diff --git a/src/support_data/ossimNitfRpcBase.cpp b/src/support_data/ossimNitfRpcBase.cpp
index a97d088..ac982fd 100644
--- a/src/support_data/ossimNitfRpcBase.cpp
+++ b/src/support_data/ossimNitfRpcBase.cpp
@@ -190,6 +190,45 @@ void ossimNitfRpcBase::clearFields()
    }
 }
 
+void ossimNitfRpcBase::setRpcModelParams(ossimRefPtr<ossimRpcModel> rpc)
+{
+   theSuccess[0] = '0';
+   if (!rpc)
+      return;
+
+   theSuccess[0] = '1';
+   setErrorBias(rpc->theBiasError);
+   setErrorRand(rpc->theRandError);
+   setLineOffset((int) rpc->theLineOffset);
+   setSampleOffset((int) rpc->theSampOffset);
+   setGeodeticLatOffset(rpc->theLatOffset);
+   setGeodeticLonOffset(rpc->theLonOffset);
+   setGeodeticHeightOffset(rpc->theHgtOffset);
+   setLineScale((int) rpc->theLineScale);
+   setSampleScale((int) rpc->theSampScale);
+   setGeodeticLatScale(rpc->theLatScale);
+   setGeodeticLonScale(rpc->theLonScale);
+   setGeodeticHeightScale(rpc->theHgtScale);
+
+   int idx;
+   vector<double> coef (20);
+   for(idx = 0; idx < 20; ++idx)
+      coef.push_back(rpc->theLineNumCoef[idx]);
+   setLineNumeratorCoeff(coef);
+
+   for(idx = 0; idx < 20; ++idx)
+      coef[idx] = rpc->theLineDenCoef[idx];
+   setLineDenominatorCoeff(coef);
+
+   for(idx = 0; idx < 20; ++idx)
+      coef[idx] = rpc->theSampNumCoef[idx];
+   setSampleNumeratorCoeff(coef);
+
+   for(idx = 0; idx < 20; ++idx)
+      coef[idx] = rpc->theSampDenCoef[idx];
+   setSampleDenominatorCoeff(coef);
+}
+
 bool ossimNitfRpcBase::getSuccess()const
 {
    return (theSuccess[0] == '1');
diff --git a/src/support_data/ossimNitfXmlDataContentDes.cpp b/src/support_data/ossimNitfXmlDataContentDes.cpp
index 1c70183..f5c234d 100644
--- a/src/support_data/ossimNitfXmlDataContentDes.cpp
+++ b/src/support_data/ossimNitfXmlDataContentDes.cpp
@@ -15,28 +15,35 @@ ossimNitfXmlDataContentDes::ossimNitfXmlDataContentDes()
 
 void ossimNitfXmlDataContentDes::parseStream(std::istream& in)
 {
-   in.read(m_descrc, DESCRC_SIZE);
-   in.read(m_desshft, DESSHFT_SIZE);
-   in.read(m_desshdt, DESSHDT_SIZE);
-   in.read(m_desshrp, DESSHRP_SIZE);
-   in.read(m_desshsi, DESSHSI_SIZE);
-   in.read(m_desshsv, DESSHSV_SIZE);
-   in.read(m_desshsd, DESSHSD_SIZE);
-   in.read(m_desshtn, DESSHTN_SIZE);
-
-   if(getSizeInBytes())
-   {
-     char* c = new char[getSizeInBytes()+1];
-     in.read(c, getSizeInBytes());
-     c[getSizeInBytes()] = '\0';
-     m_xmlString.string().resize(getSizeInBytes());
-     m_xmlString = c;
-     m_xmlDocument = new ossimXmlDocument;;
-     std::istringstream xmlStringStream(m_xmlString.string());
-     m_xmlDocument->read(xmlStringStream);
-     delete [] c;
-     c = 0;
-   }
+  clearFields();
+
+  in.read(m_descrc, DESCRC_SIZE);
+  in.read(m_desshft, DESSHFT_SIZE);
+  in.read(m_desshdt, DESSHDT_SIZE);
+  in.read(m_desshrp, DESSHRP_SIZE);
+  in.read(m_desshsi, DESSHSI_SIZE);
+  in.read(m_desshsv, DESSHSV_SIZE);
+  in.read(m_desshsd, DESSHSD_SIZE);
+  in.read(m_desshtn, DESSHTN_SIZE);
+  in.read(m_desshlpg, DESSHLPG_SIZE);
+  in.read(m_desshlpt, DESSHLPT_SIZE);
+  in.read(m_desshli, DESSHLI_SIZE);
+  in.read(m_desshlin, DESSHLIN_SIZE);
+  in.read(m_desshabs, DESSHABS_SIZE);
+
+  if(getSizeInBytes())
+  {
+    char* c = new char[getSizeInBytes()+1];
+    in.read(c, getSizeInBytes());
+    c[getSizeInBytes()] = '\0';
+    m_xmlString.string().resize(getSizeInBytes());
+    m_xmlString = c;
+    m_xmlDocument = new ossimXmlDocument;;
+    std::istringstream xmlStringStream(m_xmlString.string());
+    m_xmlDocument->read(xmlStringStream);
+    delete [] c;
+    c = 0;
+  }
 }
 
 void ossimNitfXmlDataContentDes::writeStream(std::ostream& out)
@@ -50,6 +57,11 @@ void ossimNitfXmlDataContentDes::writeStream(std::ostream& out)
    out.write(m_desshsv, DESSHSV_SIZE);
    out.write(m_desshsd, DESSHSD_SIZE);
    out.write(m_desshtn, DESSHTN_SIZE);
+   out.write(m_desshlpg, DESSHLPG_SIZE);
+   out.write(m_desshlpt, DESSHLPT_SIZE);
+   out.write(m_desshli, DESSHLI_SIZE);
+   out.write(m_desshlin, DESSHLIN_SIZE);
+   out.write(m_desshabs, DESSHABS_SIZE);
 }
 
 std::ostream& ossimNitfXmlDataContentDes::print(std::ostream& out,
@@ -69,7 +81,11 @@ std::ostream& ossimNitfXmlDataContentDes::print(std::ostream& out,
        << pfx << std::setw(24) << "DESSHSV:" << ((typeinfo) ? "(string)" : "") << m_desshsv << "\n"
        << pfx << std::setw(24) << "DESSHSD:" << ((typeinfo) ? "(string)" : "") << m_desshsd << "\n"
        << pfx << std::setw(24) << "DESSHTN:" << ((typeinfo) ? "(string)" : "") << m_desshtn << "\n"
-       // Quick hack to print on one line, this will leave extra spaces in CDATA sections
+       << pfx << std::setw(24) << "DESSHLPG:" << ((typeinfo) ? "(string)" : "") <<  m_desshlpg << "\n"
+       << pfx << std::setw(24) << "DESSHLPT:" << ((typeinfo) ? "(string)" : "") <<  m_desshlpt << "\n"
+       << pfx << std::setw(24) << "DESSHLI:" << ((typeinfo) ? "(string)" : "") <<  m_desshli << "\n"
+       << pfx << std::setw(24) << "DESSHABS:" << ((typeinfo) ? "(string)" : "") <<  m_desshabs << "\n"
+        // Quick hack to print on one line, this will leave extra spaces in CDATA sections
        << pfx << std::setw(24) << "XML:" << m_xmlString.substitute(ossimString("\n"), " ", true) << "\n"
    ;
    return out;
@@ -93,6 +109,16 @@ void ossimNitfXmlDataContentDes::clearFields()
    m_desshsd[DESSHSD_SIZE] = '\0';
    memset(m_desshtn, ' ', DESSHTN_SIZE);
    m_desshtn[DESSHTN_SIZE] = '\0';
+   memset(m_desshlpg, ' ', DESSHLPG_SIZE);
+   m_desshlpg[DESSHLPG_SIZE] = '\0';
+   memset(m_desshlpt, ' ', DESSHLPT_SIZE);
+   m_desshlpt[DESSHLPT_SIZE] = '\0';
+   memset(m_desshli, ' ', DESSHLI_SIZE);
+   m_desshli[DESSHLI_SIZE] = '\0';
+   memset(m_desshlin, ' ', DESSHLIN_SIZE);
+   m_desshlin[DESSHLIN_SIZE] = '\0';
+   memset(m_desshabs, ' ', DESSHABS_SIZE);
+   m_desshabs[DESSHABS_SIZE] = '\0';
 }
 
 bool ossimNitfXmlDataContentDes::loadState(const ossimKeywordlist& kwl, const char* prefix)
diff --git a/src/support_data/ossimTiffInfo.cpp b/src/support_data/ossimTiffInfo.cpp
index 99b9c8b..a4ca27a 100644
--- a/src/support_data/ossimTiffInfo.cpp
+++ b/src/support_data/ossimTiffInfo.cpp
@@ -301,14 +301,14 @@ std::ostream& ossimTiffInfo::print(std::ostream& out) const
    ossim_int32 ifdIndex = 0;
    while(seekOffset)
    {
-      out << "tiff.directory_offset: " << seekOffset << "\n";
+      // directory prefix for prints.
+      std::string prefix = "tiff.";
+      getDirPrefix(ifdIndex, prefix);
+      out << prefix << "directory_offset: " << seekOffset << "\n";
 
       // Seek to the image file directory.
       m_inputStream->seekg(seekOffset, std::ios_base::beg);  
 
-      // directory prefix for prints.
-      std::string prefix = "tiff.";
-      getDirPrefix(ifdIndex, prefix);
 
       //---
       // Things we need to save for printGeoKeys:
@@ -723,14 +723,15 @@ std::ostream& ossimTiffInfo::print(std::istream& inStr,
    ossim_int32 ifdIndex = 0;
    while(seekOffset)
    {
-      outStr << "tiff.directory_offset: " << seekOffset << "\n";
+      // directory prefix for prints.
+      std::string prefix = "tiff.";
+      getDirPrefix(ifdIndex, prefix);
+
+      outStr << prefix << "directory_offset: " << seekOffset << "\n";
 
       // Seek to the image file directory.
       inStr.seekg(startPosition+seekOffset, std::ios_base::beg);  
 
-      // directory prefix for prints.
-      std::string prefix = "tiff.";
-      getDirPrefix(ifdIndex, prefix);
 
       //---
       // Things we need to save for printGeoKeys:
diff --git a/src/util/ossimBatchTest.cpp b/src/util/ossimBatchTest.cpp
index e696a7e..0bfe0bd 100644
--- a/src/util/ossimBatchTest.cpp
+++ b/src/util/ossimBatchTest.cpp
@@ -72,7 +72,7 @@ bool ossimBatchTest::initialize(ossimArgumentParser& ap)
    }
 
    // Initialize environment:
-#if defined(WIN32) || defined(_MSC_VER) && !defined(__CYGWIN__) && !defined(__MWERKS__)
+#if defined(_WIN32) || defined(_MSC_VER) && !defined(__CYGWIN__) && !defined(__MWERKS__)
    _putenv("DEL_CMD=del /Q"); // For backwards compatiblity.
    _putenv("DIFF_CMD=fc /W");
    _putenv("COPY_CMD=copy /Y");
diff --git a/src/util/ossimChipperUtil.cpp b/src/util/ossimChipperUtil.cpp
index 2694e6d..99036c5 100644
--- a/src/util/ossimChipperUtil.cpp
+++ b/src/util/ossimChipperUtil.cpp
@@ -130,6 +130,7 @@ static const std::string UP_IS_UP_KW             = "up_is_up"; // bool
 static const std::string WRITER_KW               = "writer";
 static const std::string WRITER_PROPERTY_KW      = "writer_property";
 static const std::string COMBINER_TYPE_KW        = "combiner_type";
+static const std::string NULL_PIXEL_FLIP_KW      = "null_pixel_flip";
 
 static const std::string TWOCMV_OLD_INPUT_BAND_KW      = "2cmv_old_input_band";
 static const std::string TWOCMV_NEW_INPUT_BAND_KW      = "2cmv_new_input_band";
@@ -236,6 +237,7 @@ void ossimChipperUtil::addArguments(ossimArgumentParser& ap)
 
    au->addCommandLineOption("--degrees","<dpp_xy> | <dpp_x> <dpp_y>\nSpecifies an override for degrees per pixel. Takes either a single value applied equally to x and y directions, or two values applied correspondingly to x then y. This option takes precedence over the \"--meters\" option.");
 
+   au->addCommandLineOption("--enable-null-pixel-flip", "Will add to the start of the chain and will flip interior pixels that are null to valid.");
    au->addCommandLineOption("--elevation", "<elevation>\nhillshade option - Light source elevation angle for bumb shade.\nRange: 0 to 90, Default = 45.0");
 
    au->addCommandLineOption("-e or --entry", "<entry> For multi image handlers which entry do you wish to extract. For list of entries use: \"ossim-info -i <your_image>\" ");
@@ -539,6 +541,11 @@ bool ossimChipperUtil::initialize(ossimArgumentParser& ap)
       m_kwl->addPair( HIST_AOI_KW, tempString1 );
    }
 
+   if(ap.read("--enable-null-pixel-flip"))
+   {
+     m_kwl->addPair(NULL_PIXEL_FLIP_KW, TRUE_KW);
+   }
+
    if ( ap.read( "--histogram-center-tile" ) )
    {
       m_kwl->addPair( HIST_CENTER_KW, TRUE_KW );
@@ -1835,6 +1842,11 @@ ossimRefPtr<ossimSingleImageChain> ossimChipperUtil::createChain(const ossimFile
            }
         }
 
+        ossimString nullPixelFlip = m_kwl->find(NULL_PIXEL_FLIP_KW.c_str());
+        if(nullPixelFlip.toBool())
+        {
+          ic->setAddNullPixelFlipFlag(true);
+        }
         //---
         // If multiple inputs and scaleToEightBit do it at the end of the processing
         // chain to alleviate un-even stretches between inputs.
diff --git a/src/util/ossimFileWalker.cpp b/src/util/ossimFileWalker.cpp
index 74aaa4d..e1ea150 100644
--- a/src/util/ossimFileWalker.cpp
+++ b/src/util/ossimFileWalker.cpp
@@ -20,14 +20,14 @@
 #include <ossim/base/ossimDirectory.h>
 #include <ossim/base/ossimFileProcessorInterface.h>
 #include <ossim/base/ossimTrace.h>
+#include <ossim/base/Thread.h>
 #include <ossim/parallel/ossimJobQueue.h>
-#include <OpenThreads/Thread>
 
 static ossimTrace traceDebug(ossimString("ossimFileWalker:debug"));
 
 ossimFileWalker::ossimFileWalker()
    : m_fileProcessor(0),
-     m_jobQueue(new ossimJobMultiThreadQueue(new ossimJobQueue(), 1)),     
+     m_jobQueue(std::make_shared<ossimJobMultiThreadQueue>(std::make_shared<ossimJobQueue>(), 1)),     
      m_filteredExtensions(0),
      m_recurseFlag(true),
      m_waitOnDirFlag(false),
@@ -75,18 +75,18 @@ void ossimFileWalker::walk(const std::vector<ossimFilename>& files)
                      }
                      
                      // Make the job:
-                     ossimRefPtr<ossimFileWalkerJob> job =
-                        new ossimFileWalkerJob( m_fileProcessor, file );
+                     std::shared_ptr<ossimFileWalkerJob> job =
+                        std::make_shared<ossimFileWalkerJob>( m_fileProcessor, file );
                      
                      job->setName( ossimString( file.string() ) );
                      
-                     job->setCallback( new ossimFileWalkerJobCallback() );
+                     job->setCallback( std::make_shared<ossimFileWalkerJobCallback>() );
                      
                      // Set the state to ready:
                      job->ready();
                      
                      // Add job to the queue:
-                     m_jobQueue->getJobQueue()->add( job.get() );
+                     m_jobQueue->getJobQueue()->add( job );
                      
                      m_mutex.lock();
                      if ( m_abortFlag )
@@ -114,12 +114,10 @@ void ossimFileWalker::walk(const std::vector<ossimFilename>& files)
       // FOREVER loop until all jobs are completed.
       while (1)
       {
-         if ( OpenThreads::Thread::microSleep(250) == 0 )
+         ossim::Thread::sleepInMicroSeconds(250);
+         if ( m_jobQueue->hasJobsToProcess() == false )
          {
-            if ( m_jobQueue->hasJobsToProcess() == false )
-            {
-               break;
-            }
+            break;
          }
       }
 
@@ -152,12 +150,10 @@ void ossimFileWalker::walk(const ossimFilename& root)
             // FOREVER loop until all jobs are completed.
             while (1)
             {
-               if ( OpenThreads::Thread::microSleep(250) == 0 )
+               ossim::Thread::sleepInMicroSeconds(250);
+               if ( m_jobQueue->hasJobsToProcess() == false )
                {
-                  if ( m_jobQueue->hasJobsToProcess() == false )
-                  {
-                     break;
-                  }
+                  break;
                }
             }
          }
@@ -240,18 +236,18 @@ void ossimFileWalker::walkDir(const ossimFilename& dir)
          }
          
          // Make the job:
-         ossimRefPtr<ossimFileWalkerJob> job =
-            new ossimFileWalkerJob( m_fileProcessor, (*i) );
+         std::shared_ptr<ossimFileWalkerJob> job =
+            std::make_shared<ossimFileWalkerJob>( m_fileProcessor, (*i) );
 
          job->setName( ossimString( (*i).string() ) );
 
-         job->setCallback( new ossimFileWalkerJobCallback() );
+         job->setCallback( std::make_shared<ossimFileWalkerJobCallback>() );
 
          // Set the state to ready:
          job->ready();
 
          // Add job to the queue:
-         m_jobQueue->getJobQueue()->add( job.get() );
+         m_jobQueue->getJobQueue()->add( job );
 
          m_mutex.lock();
          if ( m_abortFlag )
@@ -271,12 +267,10 @@ void ossimFileWalker::walkDir(const ossimFilename& dir)
          // FOREVER loop until all jobs are completed.
          while (1)
          {
-            if ( OpenThreads::Thread::microSleep(250) == 0 )
+            ossim::Thread::sleepInMicroSeconds(250);
+            if ( m_jobQueue->hasJobsToProcess() == false )
             {
-               if ( m_jobQueue->hasJobsToProcess() == false )
-               {
-                  break;
-               }
+               break;
             }
          }
       }
@@ -505,7 +499,7 @@ ossimFileWalker::ossimFileWalkerJob::ossimFileWalkerJob(
 {
 }
 
-void ossimFileWalker::ossimFileWalkerJob::start()
+void ossimFileWalker::ossimFileWalkerJob::run()
 {
    if ( m_fileProcessor && m_file.size() )
    {
@@ -518,17 +512,17 @@ ossimFileWalker::ossimFileWalkerJobCallback::ossimFileWalkerJobCallback()
 {
 }
 
-void ossimFileWalker::ossimFileWalkerJobCallback::started(ossimJob* job)
+void ossimFileWalker::ossimFileWalkerJobCallback::started(std::shared_ptr<ossimJob> job)
 {
    ossimJobCallback::started(job);
 }
 
-void ossimFileWalker::ossimFileWalkerJobCallback::finished(ossimJob* job)
+void ossimFileWalker::ossimFileWalkerJobCallback::finished(std::shared_ptr<ossimJob> job)
 {
    ossimJobCallback::finished(job);
 }
 
-void ossimFileWalker::ossimFileWalkerJobCallback::canceled(ossimJob* job)
+void ossimFileWalker::ossimFileWalkerJobCallback::canceled(std::shared_ptr<ossimJob> job)
 {
    ossimJobCallback::canceled(job);
 }
diff --git a/src/util/ossimHlzTool.cpp b/src/util/ossimHlzTool.cpp
index e7d9def..810ad01 100644
--- a/src/util/ossimHlzTool.cpp
+++ b/src/util/ossimHlzTool.cpp
@@ -28,7 +28,9 @@
 #include <ossim/imaging/ossimIndexToRgbLutFilter.h>
 #include <ossim/point_cloud/ossimPointCloudHandlerRegistry.h>
 #include <ossim/util/ossimHlzTool.h>
+#include <ossim/base/Thread.h>
 #include <fstream>
+#include <cstddef>
 
 static const string MASK_EXCLUDE_KW = "exclude_regions";
 static const string MASK_INCLUDE_KW = "include_regions";
@@ -468,11 +470,11 @@ bool ossimHlzTool::computeHLZ()
       {
          for (chip_origin.x = min_x; chip_origin.x <= max_x; chip_origin.x += dem_step)
          {
-            ossimHlzTool::PatchProcessorJob* job = 0;
+            std::shared_ptr<ossimHlzTool::PatchProcessorJob> job = 0;
             if (m_useLsFitMethod)
-               job = new ossimHlzTool::LsFitPatchProcessorJob(this, chip_origin, chipId++);
+               job = std::make_shared<ossimHlzTool::LsFitPatchProcessorJob>(this, chip_origin, chipId++);
             else
-               job = new ossimHlzTool::NormPatchProcessorJob(this, chip_origin, chipId++);
+               job = std::make_shared<ossimHlzTool::NormPatchProcessorJob>(this, chip_origin, chipId++);
             job->start();
          }
          setPercentComplete(100*chipId/numPatches);
@@ -484,9 +486,9 @@ bool ossimHlzTool::computeHLZ()
          m_numThreads = ossim::getNumberOfThreads();
 
       // Loop over input DEM, creating a thread job for each filter window:
-      ossimRefPtr<ossimJobMultiThreadQueue> jobMtQueue =
-            new ossimJobMultiThreadQueue(0, m_numThreads);
-      ossimJobQueue* jobQueue = jobMtQueue->getJobQueue();
+      std::shared_ptr<ossimJobMultiThreadQueue> jobMtQueue =
+            std::make_shared<ossimJobMultiThreadQueue>(nullptr, m_numThreads);
+      std::shared_ptr<ossimJobQueue> jobQueue = jobMtQueue->getJobQueue();
 
       ossimNotify(ossimNotifyLevel_INFO) << "\nPreparing " << numPatches << " jobs..." << endl; // TODO: DEBUG
       setPercentComplete(0);
@@ -498,11 +500,11 @@ bool ossimHlzTool::computeHLZ()
          for (chip_origin.x = min_x; chip_origin.x <= max_x; ++chip_origin.x)
          {
             //ossimNotify(ossimNotifyLevel_INFO) << "Submitting " << chipId << endl;
-            ossimHlzTool::PatchProcessorJob* job = 0;
+            std::shared_ptr<ossimHlzTool::PatchProcessorJob> job = 0;
             if (m_useLsFitMethod)
-               job = new ossimHlzTool::LsFitPatchProcessorJob(this, chip_origin, chipId++);
+               job = std::make_shared<ossimHlzTool::LsFitPatchProcessorJob>(this, chip_origin, chipId++);
             else
-               job = new ossimHlzTool::NormPatchProcessorJob(this, chip_origin, chipId++);
+               job = std::make_shared<ossimHlzTool::NormPatchProcessorJob>(this, chip_origin, chipId++);
             jobQueue->add(job, false);
          }
          qsize = jobQueue->size();
@@ -515,7 +517,7 @@ bool ossimHlzTool::computeHLZ()
       {
          qsize = jobMtQueue->getJobQueue()->size();
          setPercentComplete(100*(numPatches-qsize)/numPatches);
-         OpenThreads::Thread::microSleep(10000);
+         ossim::Thread::sleepInMicroSeconds(10000);
       }
       jobMtQueue = 0;
    }
@@ -543,7 +545,7 @@ void ossimHlzTool::writeSlopeImage()
    }
 }
 
-OpenThreads::ReadWriteMutex ossimHlzTool::PatchProcessorJob::m_bufMutex;
+std::mutex ossimHlzTool::PatchProcessorJob::m_bufMutex;
 
 ossimHlzTool::PatchProcessorJob::PatchProcessorJob(ossimHlzTool* hlzUtil, const ossimIpt& origin,
                                    ossim_uint32 /*chip_id*/)
@@ -556,12 +558,12 @@ ossimHlzTool::PatchProcessorJob::PatchProcessorJob(ossimHlzTool* hlzUtil, const
    m_demPatchLR.y = m_demPatchUL.y + m_hlzUtil->m_demFilterSize.y;
 }
 
-void ossimHlzTool::PatchProcessorJob::start()
+void ossimHlzTool::PatchProcessorJob::run()
 {
    bool passed = level1Test() && level2Test() && maskTest();
    ossimIpt p;
 
-   OpenThreads::ScopedWriteLock lock (m_bufMutex);
+   std::lock_guard<std::mutex> lock (m_bufMutex);
    for (p.y = m_demPatchUL.y; p.y < m_demPatchLR.y; ++p.y)
    {
       for (p.x = m_demPatchUL.x; p.x < m_demPatchLR.x; ++p.x)
diff --git a/src/util/ossimInfo.cpp b/src/util/ossimInfo.cpp
index 09e4430..6ff097d 100644
--- a/src/util/ossimInfo.cpp
+++ b/src/util/ossimInfo.cpp
@@ -48,6 +48,7 @@
 #include <ossim/support_data/ossimInfoBase.h>
 #include <ossim/support_data/ossimInfoFactoryRegistry.h>
 #include <ossim/support_data/ossimSupportFilesList.h>
+#include <ossim/support_data/ImageHandlerStateRegistry.h>
 
 #include <iomanip>
 #include <sstream>
@@ -55,6 +56,7 @@
 #include <memory>
 
 static const char BUILD_DATE_KW[]           = "build_date";
+static const char CAN_OPEN_KW[]             = "can_open";
 static const char CENTER_GROUND_KW[]        = "center_ground";
 static const char CENTER_IMAGE_KW[]         = "center_image";
 static const char CONFIGURATION_KW[]        = "configuration";
@@ -102,6 +104,8 @@ static const char WRITERS_KW[]              = "writers_kw";
 static const char WRITER_PROPS_KW[]         = "writer_props";
 static const char ZOOM_LEVEL_GSDS_KW[]      = "zoom_level_gsds";
 static const char ECEF2LLH_KW[]             = "ecef2llh";
+static const char DUMP_STATE_KW[]           = "dump_state";
+static const char STATE_KW[]                = "state";
 
 const char* ossimInfo::DESCRIPTION =
       "Dumps metadata information about input image and OSSIM in general.";
@@ -126,7 +130,7 @@ void ossimInfo::setUsage(ossimArgumentParser& ap)
    // Set the general usage:
    ossimApplicationUsage* au = ap.getApplicationUsage();
    ossimString usageString = ap.getApplicationName();
-   usageString += " [options] <optional-image>";
+   usageString += " [options] <optional-image | optional-state>";
    au->setCommandLineUsage(usageString);
 
    // Set the command line options:
@@ -135,6 +139,8 @@ void ossimInfo::setUsage(ossimArgumentParser& ap)
    au->addCommandLineOption("--build-date", "Build date of code.");
 
    au->addCommandLineOption("-c", "Will print ground and image center.");
+   
+   au->addCommandLineOption("--can-open", "return can_open: true or can_open: false");
 
    au->addCommandLineOption("--cg", "Will print out ground center.");
 
@@ -146,12 +152,14 @@ void ossimInfo::setUsage(ossimArgumentParser& ap)
 
    au->addCommandLineOption("-d", "A generic dump if one is available.");
 
-   au->addCommandLineOption("--datums", "Prints datum list.");   
+   au->addCommandLineOption("--datums", "Prints datum list.");
 
    au->addCommandLineOption("--deg2rad", "<degrees> Gives radians from degrees.");
 
    au->addCommandLineOption("--dno", "A generic dump if one is available.  This option ignores overviews.");
 
+   au->addCommandLineOption("--dump-state", "If the image supports a state object then the state object will be dumped.");
+
    au->addCommandLineOption("--ecef2llh", "<X> <Y> <Z> in ECEF coordinates and returns latitude longitude height position.");
 
    au->addCommandLineOption("-f", "<format> Will output the information specified format [KWL | XML].  Default is KWL.");   
@@ -315,6 +323,17 @@ bool ossimInfo::initialize(ossimArgumentParser& ap)
          }
       }
 
+      if( ap.read("--can-open") )
+      {
+         m_kwl.add( CAN_OPEN_KW, TRUE_KW );
+         requiresInputImage = true;
+         if ( ap.argc() < 2 )
+         {
+            break;
+         }
+      }
+
+
       if( ap.read("--cg") )
       {
          m_kwl.add( CENTER_GROUND_KW, TRUE_KW );
@@ -380,6 +399,16 @@ bool ossimInfo::initialize(ossimArgumentParser& ap)
          }
       }
 
+      if( ap.read("--dump-state") )
+      {
+         m_kwl.add( DUMP_STATE_KW, TRUE_KW );
+         requiresInputImage = true;
+         if ( ap.argc() < 2 )
+         {
+            break;
+         }
+      }
+
       if( ap.read("--dno") )
       {
          m_kwl.add( DUMP_KW, TRUE_KW );
@@ -771,6 +800,7 @@ bool ossimInfo::initialize(ossimArgumentParser& ap)
       setUsage(ap);
       ap.getApplicationUsage()->write(ossimNotify(ossimNotifyLevel_INFO));
       result = false;
+
    }
 
    if ( traceDebug() )
@@ -1172,6 +1202,16 @@ ossim_uint32 ossimInfo::executeImageOptions(const ossimFilename& file)
    bool upIsUpFlag        = false;
    bool imageToGroundFlag = false;
    bool groundToImageFlag = false;
+   bool dumpState         = false;
+   bool canOpenFlag       = false;
+
+   lookup = m_kwl.find( DUMP_STATE_KW );
+   if ( lookup )
+   {
+      ++consumedKeys;
+      value     = lookup;
+      dumpState = value.toBool();
+   }
 
    // Center Ground:
    lookup = m_kwl.find( CENTER_GROUND_KW );
@@ -1292,6 +1332,15 @@ ossim_uint32 ossimInfo::executeImageOptions(const ossimFilename& file)
       upIsUpFlag = value.toBool();
    }
 
+   // Up is up:
+   lookup = m_kwl.find( CAN_OPEN_KW );
+   if ( lookup )
+   {
+      ++consumedKeys;
+      value = lookup;
+      canOpenFlag = value.toBool();
+   }
+
    // If no options consumed default is image info and geom info:
    if ( consumedKeys == 0 )
    {
@@ -1301,14 +1350,26 @@ ossim_uint32 ossimInfo::executeImageOptions(const ossimFilename& file)
 
    if ( centerGroundFlag || centerImageFlag || imageBoundsFlag || imageCenterFlag ||
         imageRectFlag || img2grdFlag || grd2imgFlag || metaDataFlag || paletteFlag ||
-        imageInfoFlag || imageGeomFlag || northUpFlag || upIsUpFlag || 
-        imageToGroundFlag || groundToImageFlag)
+        imageInfoFlag || imageGeomFlag || northUpFlag || upIsUpFlag || dumpState ||
+        imageToGroundFlag || groundToImageFlag || canOpenFlag)
    {
       // Requires open image.
-      if ( m_img.valid() == false )
+      if ( ! m_img )
       {
          openImage(file);
       }
+      
+      if( canOpenFlag )
+      {
+         if(m_img)
+         {
+            okwl.add("can_open", "true", true);
+         }
+         else
+         {
+            okwl.add("can_open", "false", true);
+         }
+      }
 
       if ( centerGroundFlag )
       {
@@ -1381,6 +1442,17 @@ ossim_uint32 ossimInfo::executeImageOptions(const ossimFilename& file)
          getUpIsUpAngle( okwl );
       }
 
+      if(dumpState)
+      {
+         if(m_img)
+         {
+            if(m_img->getState())
+            {
+               m_img->getState()->save(okwl);               
+            }
+         }
+      }
+
    } // if ( metaDataFlag || paletteFlag || imageInfoFlag || imageGeomFlag )
 
    if ( okwl.getSize() ) // Output section:
@@ -1423,6 +1495,7 @@ ossim_uint32 ossimInfo::executeImageOptions(const ossimFilename& file)
 
    } // if ( okwl )
 
+
    if ( traceDebug() )
    {
       ossimNotify(ossimNotifyLevel_DEBUG)
@@ -1506,16 +1579,58 @@ bool ossimInfo::getImageInfo( const ossimFilename& file,
 
 void ossimInfo::openImage(const ossimFilename& file)
 {
-   m_img = openImageHandler( file );
+   if(file.ext().downcase()=="kwl")
+   {
+      openImageFromState(file);
+   }
+   else
+   {
+      m_img = openImageHandler( file );      
+   }
 }
 
+void ossimInfo::openImageFromState(const ossimFilename& file)
+{
+   std::shared_ptr<ossim::ImageHandlerState> state;
+   ossimKeywordlist kwl;
+   if(kwl.addFile(file))
+   {
+      state = ossim::ImageHandlerStateRegistry::instance()->createState(kwl);
+      if(state)
+      {
+         m_img = ossimImageHandlerRegistry::instance()->open(state);
+      }
+   }
+}
+
+
 ossimRefPtr<ossimImageHandler> ossimInfo::openImageHandler(const ossimFilename& file) const
 {
-   // Go through new interface that passes a stream around. (drb 10 Nov. 2016)
-   // ossimRefPtr<ossimImageHandler> result = ossimImageHandlerRegistry::instance()->open(file);
-   ossimRefPtr<ossimImageHandler> result = ossimImageHandlerRegistry::instance()->
-      openConnection(file);
-   if ( result.valid() == false )
+   ossimRefPtr<ossimImageHandler> result;
+   if(file.ext().downcase()=="kwl")
+   {
+      std::shared_ptr<ossim::ImageHandlerState> state;
+      ossimKeywordlist kwl;
+      if(kwl.addFile(file))
+      {
+         state = ossim::ImageHandlerStateRegistry::instance()->createState(kwl);
+         if(state)
+         {
+            result = ossimImageHandlerRegistry::instance()->open(state);
+         }
+      }
+   }
+   else
+   {
+      // Go through new interface that passes a stream around. (drb 10 Nov. 2016)
+      // ossimRefPtr<ossimImageHandler> result = ossimImageHandlerRegistry::instance()->open(file);
+      result = ossimImageHandlerRegistry::instance()->
+         openConnection(file);
+   }
+   // only throw an exception if the can-open option
+   // is not specified
+   ossimString canOpenFlag = m_kwl.find("can_open");
+   if ( !result.valid() && !canOpenFlag.toBool())
    {
       std::string errMsg = "ossimInfo::openImage ERROR:\nCould not open: ";
       errMsg += file.string();
diff --git a/src/util/ossimShorelineTool.cpp b/src/util/ossimShorelineTool.cpp
index e2e5f55..4b2d1db 100644
--- a/src/util/ossimShorelineTool.cpp
+++ b/src/util/ossimShorelineTool.cpp
@@ -5,7 +5,7 @@
 //
 //**************************************************************************************************
 
-#include <ossim/base/jsoncpp.h>
+#include <ossim/util/ossimShorelineTool.h>
 #include <ossim/init/ossimInit.h>
 #include <ossim/base/ossimApplicationUsage.h>
 #include <ossim/base/ossimCommon.h>
@@ -27,7 +27,6 @@
 #include <ossim/imaging/ossimErosionFilter.h>
 #include <ossim/imaging/ossimImageHistogramSource.h>
 #include <ossim/ossimVersion.h>
-#include <ossim/util/ossimShorelineTool.h>
 #include <ossim/util/ossimToolRegistry.h>
 #include <fstream>
 
@@ -414,8 +413,11 @@ bool ossimShorelineTool::execute()
    potrace->initialize(potrace_kwl);
 
    status =  potrace->execute();
+
+#if OSSIM_HAS_JSONCPP
    if (status)
       status =  addPropsToJSON();
+#endif
 
    if (status)
       ossimNotify(ossimNotifyLevel_INFO)<<"Wrote vector product to <"<<m_productFilename<<">"<<endl;
@@ -560,6 +562,8 @@ void ossimShorelineTool::autoComputeThreshold()
    cout<<"ossimShorelineUtil::autoComputeThreshold(): Using threshold = "<<m_threshold<<endl;
 }
 
+#if OSSIM_HAS_JSONCPP
+#include <json/json.h>
 bool ossimShorelineTool::addPropsToJSON()
 {
    // Read existing JSON file as output by potrace:
@@ -626,6 +630,6 @@ bool ossimShorelineTool::addPropsToJSON()
 
    return true;
 }
-
+#endif
 
 
diff --git a/src/util/ossimSubImageTool.cpp b/src/util/ossimSubImageTool.cpp
new file mode 100644
index 0000000..e3a7a8f
--- /dev/null
+++ b/src/util/ossimSubImageTool.cpp
@@ -0,0 +1,287 @@
+//**************************************************************************************************
+//
+//     OSSIM Open Source Geospatial Data Processing Library
+//     See top level LICENSE.txt file for license information
+//
+//**************************************************************************************************
+
+#include <ossim/util/ossimSubImageTool.h>
+#include <ossim/base/ossimConstants.h>
+#include <ossim/base/ossimApplicationUsage.h>
+#include <ossim/base/ossimNotify.h>
+#include <ossim/base/ossimException.h>
+#include <ossim/base/ossimString.h>
+#include <ossim/base/ossimKeywordNames.h>
+#include <ossim/imaging/ossimImageHandlerRegistry.h>
+#include <ossim/imaging/ossimImageGeometry.h>
+#include <ossim/projection/ossimRpcSolver.h>
+#include <ossim/base/ossimXmlDocument.h>
+#include <iostream>
+
+using namespace std;
+
+const char* ossimSubImageTool::DESCRIPTION  = "Tool for extracting a sub-image from a full image."
+      " No reprojection is done. Presently, the subimage geometry is represented by an RPC "
+      "replacement model until generic models can support subimage chipping.";
+const char* BBOX_KW = "bbox";
+
+ossimSubImageTool::ossimSubImageTool()
+:  m_geomFormat (OGEOM)
+{
+}
+
+ossimSubImageTool::~ossimSubImageTool()
+{
+}
+
+void ossimSubImageTool::setUsage(ossimArgumentParser& ap)
+{
+   // Add options.
+   ossimApplicationUsage* au = ap.getApplicationUsage();
+   ossimString usageString = ap.getApplicationName();
+   usageString += " subimage [options] <input-image> <output-image>";
+   au->setCommandLineUsage(usageString);
+
+   // Set the command line options:
+   au->setDescription(DESCRIPTION);
+
+   // Base class has its own. Skip the ossimChipProcTool usage as that adds a lot of view-space
+   // specific stuff not used in this tool:
+   ossimTool::setUsage(ap);
+
+   au->addCommandLineOption(
+         "--bbox <ulx> <uly> <lrx> <lry>",
+         "Specify upper-left and lower-right bounds the image rect (in pixels).");
+   au->addCommandLineOption(
+         "-e | --entry <N> ",
+         "For multi image entries which entry do you wish to extract. For list "
+         "of entries use: \"ossim-info -i <your_image>\" ");
+   au->addCommandLineOption(
+         "--geom <format>", "Specifies format of the subimage RPC geometry file."
+         " Possible values are: \"OGEOM\" (OSSIM geometry, default), \"DG\" (DigitalGlobe WV/QB "
+         ".RPB format), \"JSON\" (MSP-style JSON), or \"XML\". Case insensitive.");
+}
+
+bool ossimSubImageTool::initialize(ossimArgumentParser& ap)
+{
+   if (!ossimTool::initialize(ap))
+      return false;
+   if (m_helpRequested)
+      return true;
+
+   string tempString1;
+   ossimArgumentParser::ossimParameter stringParam1(tempString1);
+   string tempString2;
+   ossimArgumentParser::ossimParameter stringParam2(tempString2);
+   string tempString3;
+   ossimArgumentParser::ossimParameter stringParam3(tempString3);
+   string tempString4;
+   ossimArgumentParser::ossimParameter stringParam4(tempString4);
+   double tempDouble1;
+   ossimArgumentParser::ossimParameter doubleParam1(tempDouble1);
+   double tempDouble2;
+   ossimArgumentParser::ossimParameter doubleParam2(tempDouble2);
+   vector<ossimString> paramList;
+
+   ossim_uint32 readerPropIdx = 0;
+   ossim_uint32 writerPropIdx = 0;
+   ostringstream keys;
+
+   if ( ap.read("--bbox", stringParam1, stringParam2, stringParam3, stringParam4))
+   {
+      ostringstream ostr;
+      ostr<<tempString1<<" "<<tempString2<<" "<<tempString3<<" "<<tempString4<<ends;
+      m_kwl.addPair( string(BBOX_KW), ostr.str() );
+   }
+   if ( ap.read("-e", stringParam1) || ap.read("--entry", stringParam1) )
+      m_kwl.addPair( string(ossimKeywordNames::ENTRY_KW), tempString1 );
+
+   if ( ap.read("--geom", stringParam1))
+   {
+      ossimString formatStr (tempString1);
+      formatStr.upcase();
+      if (formatStr == "OGEOM")
+         m_geomFormat = OGEOM;
+      else if (formatStr == "DG")
+         m_geomFormat = DG;
+      else if (formatStr == "JSON")
+         m_geomFormat = JSON;
+      else if (formatStr == "XML")
+         m_geomFormat = XML;
+      else
+      {
+         ostringstream errMsg;
+         errMsg << " ERROR: ossimSubImageTool ["<<__LINE__<<"] Unknown geometry format <"
+               <<formatStr<<"> specified. Aborting." << endl;
+         throw ossimException( errMsg.str() );
+      }
+   }
+   processRemainingArgs(ap);
+
+   return true;
+}
+
+void ossimSubImageTool::initialize(const ossimKeywordlist& kwl)
+{
+   m_productFilename = m_kwl.find(ossimKeywordNames::OUTPUT_FILE_KW);
+
+   // Init chain with handler:
+   ostringstream key;
+   key<<ossimKeywordNames::IMAGE_FILE_KW<<"0";
+   ossimFilename fname = m_kwl.findKey(key.str());
+   ossimRefPtr<ossimImageHandler> handler =
+         ossimImageHandlerRegistry::instance()->open(fname, true, false);
+   if (!handler)
+   {
+      ostringstream errMsg;
+      errMsg<<"ERROR: ossimSubImageTool ["<<__LINE__<<"] Could not open <"<<fname<<">"<<ends;
+      throw ossimException(errMsg.str());
+   }
+
+   // Look for the entry keyand set it:
+   ossim_uint32 entryIndex = 0;
+   ossimString os = m_kwl.find(ossimKeywordNames::ENTRY_KW);
+   if (os)
+      entryIndex = os.toUInt32();
+   if (!handler->setCurrentEntry( entryIndex ))
+   {
+      ostringstream errMsg;
+      errMsg << " ERROR: ossimSubImageTool ["<<__LINE__<<"] Entry " << entryIndex << " out of range!" << endl;
+      throw ossimException( errMsg.str() );
+   }
+   m_procChain->add(handler.get());
+
+   // And finally the bounding rect:
+   ossimString lookup = m_kwl.find(BBOX_KW);
+   lookup.trim();
+   vector<ossimString> substrings = lookup.split(", ", true);
+   if (substrings.size() != 4)
+   {
+      ostringstream errMsg;
+      errMsg << "ossimSubImageTool ["<<__LINE__<<"] Incorrect number of values specified for bbox!";
+      throw( ossimException(errMsg.str()) );
+   }
+
+   int ulx = substrings[0].toInt32();
+   int uly = substrings[1].toInt32();
+   int lrx = substrings[2].toInt32();
+   int lry = substrings[3].toInt32();
+
+   // Check for swap:
+   if ( ulx > lrx )
+   {
+      int tmpF = ulx;
+      ulx = lrx;
+      lrx = tmpF;
+   }
+   if ( uly > lry )
+   {
+      int tmpF = uly;
+      uly = lry;
+      lry = tmpF;
+   }
+
+   // Use of view rect here is same as image space since there is no renderer:
+   m_aoiViewRect.set_ul(ossimIpt(ulx, uly));
+   m_aoiViewRect.set_lr(ossimIpt(lrx, lry));
+   m_needCutRect = true;
+
+   finalizeChain();
+}
+
+bool ossimSubImageTool::execute()
+{
+   // Compute RPC representation of subimage:
+   ossimRefPtr<ossimImageGeometry> inputGeom = m_procChain->getImageGeometry();
+   if (!inputGeom || !inputGeom->getProjection())
+   {
+      ostringstream errMsg;
+      errMsg << " ERROR: ossimSubImageTool ["<<__LINE__<<"] Null projection returned for input "
+            "image!" << endl;
+      throw ossimException( errMsg.str() );
+   }
+
+   ossimRefPtr<ossimProjection> inputProj = inputGeom->getProjection();
+   ossimRefPtr<ossimRpcModel> rpc;
+   ossimRefPtr<ossimRpcSolver> solver = new ossimRpcSolver(false);
+   bool converged = false;
+
+   // If the input projection itself is an RPC, just copy it. No solving required:
+   ossimRpcModel* inputRpc = dynamic_cast<ossimRpcModel*>(inputGeom->getProjection());
+   if (inputRpc)
+      rpc = inputRpc;
+   else
+   {
+      converged = solver->solve(m_aoiViewRect, inputGeom.get());
+      rpc = solver->getRpcModel();
+   }
+
+   // The RPC needs to be shifted in image space so that it will work in the subimage coordinates:
+   rpc->setImageOffset(m_aoiViewRect.ul());
+   m_geom = new ossimImageGeometry(nullptr, rpc.get());
+   m_geom->setImageSize(m_aoiViewRect.size());
+   ossimKeywordlist kwl;
+   m_geom->saveState(kwl);
+
+   bool success = ossimChipProcTool::execute();
+   if (!success)
+      return false;
+
+   // Need to save the subimage RPC data:
+   bool write_ok = false;
+   ossimFilename geomFile (m_productFilename);
+   if (m_geomFormat == OGEOM) // Default case if none specified
+   {
+      geomFile.setExtension("geom");
+      write_ok = kwl.write(geomFile);
+   }
+   else if (m_geomFormat == JSON)
+   {
+#if OSSIM_HAS_JSONCPP
+      geomFile.setExtension("json");
+      ofstream jsonStream (geomFile.string());
+      if (!jsonStream.fail())
+      {
+         // Note that only the model/projection is saved here, not the full ossimImageGeometry that
+         // contains the subimage shift transform. So need to cheat and add the shift to the RPC
+         // line and sample offsets:
+         write_ok = rpc->toJSON(jsonStream);
+         jsonStream.close();
+      }
+#else
+      ostringstream errMsg;
+      errMsg << " ERROR: ossimSubImageTool ["<<__LINE__<<"] JSON geometry output requested but JSON is not "
+            "available in this build! <" << endl;
+      throw ossimException( errMsg.str() );
+#endif
+   }
+   else if (m_geomFormat == DG)
+   {
+      geomFile.setExtension("RPB");
+      ofstream rpbStream (geomFile.string());
+      if (!rpbStream.fail())
+      {
+         write_ok = rpc->toRPB(rpbStream);
+         rpbStream.close();
+      }
+   }
+   else if (m_geomFormat == XML)
+   {
+      geomFile.setExtension("xml");
+      ossimXmlDocument xmlDocument;
+      xmlDocument.fromKwl(kwl);
+      write_ok = xmlDocument.write(geomFile);
+   }
+
+   if (write_ok)
+      ossimNotify(ossimNotifyLevel_INFO) << "Wrote geometry file to <"<<geomFile<<">.\n" << endl;
+   else
+   {
+      ossimNotify(ossimNotifyLevel_FATAL) << "Error encountered writing output RPC geometry file."
+            << std::endl;
+      return false;
+   }
+
+   return true;
+}
+
diff --git a/src/util/ossimToolFactory.cpp b/src/util/ossimToolFactory.cpp
index e8b46a3..5ab8980 100644
--- a/src/util/ossimToolFactory.cpp
+++ b/src/util/ossimToolFactory.cpp
@@ -16,6 +16,7 @@
 #include <ossim/util/ossimToolRegistry.h>
 #include <ossim/util/ossimVerticesFinderTool.h>
 #include <ossim/util/ossimViewshedTool.h>
+#include <ossim/util/ossimSubImageTool.h>
 #if OSSIM_HAS_HDF5
 #include <ossim/hdf5/ossimHdf5Tool.h>
 #endif
@@ -70,6 +71,9 @@ ossimTool* ossimToolFactory::createTool(const std::string& argName) const
    if ((utilName == "bandmerge") || (argName == "ossimBandMergeTool"))
       return new ossimBandMergeTool;
 
+   if ((utilName == "subimage") || (argName == "ossimSubImageTool"))
+      return new ossimSubImageTool;
+
 #if OSSIM_HAS_HDF5
    if ((utilName == "hdf5") || (argName == "ossimHdf5Tool"))
       return new ossimHdf5Tool;
@@ -89,6 +93,7 @@ void ossimToolFactory::getCapabilities(std::map<std::string, std::string>& capab
    capabilities.insert(pair<string, string>("ortho", ossimOrthoTool::DESCRIPTION));
    capabilities.insert(pair<string, string>("vertices", ossimVerticesFinderTool::DESCRIPTION));
    capabilities.insert(pair<string, string>("bandmerge", ossimBandMergeTool::DESCRIPTION));
+   capabilities.insert(pair<string, string>("subimage", ossimSubImageTool::DESCRIPTION));
 #if OSSIM_HAS_HDF5
    capabilities.insert(pair<string, string>("hdf5", ossimHdf5Tool::DESCRIPTION));
 #endif
@@ -112,6 +117,7 @@ void ossimToolFactory::getTypeNameList(vector<ossimString>& typeList) const
    typeList.push_back("ossimOrthoUtil");
    typeList.push_back("ossimVerticesFinderUtil");
    typeList.push_back("ossimBandMergeUtil");
+   typeList.push_back("ossimSubImageTool");
 #if OSSIM_HAS_HDF5
    typeList.push_back("ossimHdf5Tool");
 #endif
diff --git a/src/util/ossimViewshedTool.cpp b/src/util/ossimViewshedTool.cpp
index f6c7485..e5ab9cd 100644
--- a/src/util/ossimViewshedTool.cpp
+++ b/src/util/ossimViewshedTool.cpp
@@ -26,6 +26,7 @@
 #include <ossim/imaging/ossimMemoryImageSource.h>
 #include <ossim/imaging/ossimIndexToRgbLutFilter.h>
 #include <ossim/util/ossimViewshedTool.h>
+#include <ossim/base/Thread.h>
 
 using namespace std;
 
@@ -500,7 +501,7 @@ bool ossimViewshedTool::computeViewshed()
 
    if (m_numThreads > 1)
    {
-      ossimRefPtr<ossimJobQueue> jobQueue = new ossimJobQueue();
+      std::shared_ptr<ossimJobQueue> jobQueue = std::make_shared<ossimJobQueue>();
       for (int sector=0; sector<8; ++sector)
       {
          if (m_radials[sector] == 0)
@@ -508,14 +509,14 @@ bool ossimViewshedTool::computeViewshed()
 
          if (m_threadBySector)
          {
-            SectorProcessorJob* job = new SectorProcessorJob(this, sector, m_halfWindow);
+            std::shared_ptr<SectorProcessorJob> job = std::make_shared<SectorProcessorJob>(this, sector, m_halfWindow);
             jobQueue->add(job, false);
          }
          else
          {
             for (ossim_uint32 r=0; r<=m_halfWindow; ++r)
             {
-               RadialProcessorJob* job = new RadialProcessorJob(this, sector, r, m_halfWindow);
+               std::shared_ptr<RadialProcessorJob> job = std::make_shared<RadialProcessorJob>(this, sector, r, m_halfWindow);
                jobQueue->add(job, false);
             }
          }
@@ -524,12 +525,12 @@ bool ossimViewshedTool::computeViewshed()
       }
 
       ossimNotify(ossimNotifyLevel_INFO) << "\nSubmitting "<<jobQueue->size()<<" jobs..."<<endl;
-      m_jobMtQueue = new ossimJobMultiThreadQueue(jobQueue.get(), m_numThreads);
+      m_jobMtQueue = std::make_shared<ossimJobMultiThreadQueue>(jobQueue, m_numThreads);
 
       // Wait until all radials have been processed before proceeding:
       ossimNotify(ossimNotifyLevel_INFO) << "Waiting for job threads to finish..."<<endl;
       while (m_jobMtQueue->hasJobsToProcess() || m_jobMtQueue->numberOfBusyThreads())
-         OpenThreads::Thread::microSleep(250);
+         ossim::Thread::sleepInMicroSeconds(250);
    }
    else
    {
@@ -870,7 +871,7 @@ bool ossimViewshedTool::writeHorizonProfile()
    return true;
 }
 
-void SectorProcessorJob::start()
+void SectorProcessorJob::run()
 {
    // Loop over all the sector's radials and walk over each one.
    for (ossim_uint32 r=0; r<=m_numRadials; ++r)
@@ -879,12 +880,12 @@ void SectorProcessorJob::start()
    }
 }
 
-void RadialProcessorJob::start()
+void RadialProcessorJob::run()
 {
    RadialProcessor::doRadial(m_vsUtil, m_sector, m_radial);
 }
 
-OpenThreads::ReadWriteMutex RadialProcessor::m_bufMutex;
+std::mutex RadialProcessor::m_bufMutex;
 
 void RadialProcessor::doRadial(ossimViewshedTool* vsUtil,
                                ossim_uint32 sector_idx,
@@ -963,7 +964,6 @@ void RadialProcessor::doRadial(ossimViewshedTool* vsUtil,
       // Check if we passed beyong the visibilty radius, and exit loop if so:
       if (vsUtil->m_displayAsRadar && ((u*u + v*v) >= r2_max))
       {
-         //OpenThreads::ScopedWriteLock lock (m_bufMutex);
          vsUtil->m_outBuffer->setValue(ipt.x, ipt.y, vsUtil->m_overlayValue);
          break;
       }
@@ -984,12 +984,10 @@ void RadialProcessor::doRadial(ossimViewshedTool* vsUtil,
             // point is visible, latch this line-of-sight as the new max elevation angle for this
             // radial, and mark the output pixel as visible:
             radial.elevation = elev_i;
-            //OpenThreads::ScopedWriteLock lock (m_bufMutex);
             vsUtil->m_outBuffer->setValue(ipt.x, ipt.y, vsUtil->m_visibleValue);
          }
          else
          {
-            //OpenThreads::ScopedWriteLock lock (m_bufMutex);
             vsUtil->m_outBuffer->setValue(ipt.x, ipt.y, vsUtil->m_hiddenValue);
          }
       }
diff --git a/test/src/base/ossim-ref-ptr-test.cpp b/test/src/base/ossim-ref-ptr-test.cpp
index 869a237..2be56fe 100644
--- a/test/src/base/ossim-ref-ptr-test.cpp
+++ b/test/src/base/ossim-ref-ptr-test.cpp
@@ -52,6 +52,7 @@ static ossimRefPtr<Obj> getRefPtr()
 int main( /* int argc, char* argv[] */ )
 {
    ossimInit::instance()->initialize();
+   int rtn_status = 0;
 
    Foo* f = new Foo;
 
@@ -85,6 +86,32 @@ int main( /* int argc, char* argv[] */ )
       cout << "getRefPtr rp count(1): " << rp->referenceCount() << endl;
    }
    
-   
-   return 0;
+   // Test boolean operations:
+   ossimRefPtr<Obj> p0;
+   ossimRefPtr<Obj> p1 = new Obj;
+   ossimRefPtr<Obj> p1c = p1;
+   ossimRefPtr<Obj> p2 = new Obj;
+
+   if (p0)
+   {
+      cout<<"bool operator (p) FAILED"<<endl;
+      rtn_status++;
+   }
+   if (!p1)
+   {
+      cout<<"bool operator (!p) FAILED"<<endl;
+      rtn_status++;
+   }
+   if (p1 == p2)
+   {
+      cout<<"bool operator (p1 == p2) FAILED"<<endl;
+      rtn_status++;
+   }
+   if (p1 != p1c)
+   {
+      cout<<"bool operator (p1 != p2) FAILED"<<endl;
+      rtn_status++;
+   }
+
+   return rtn_status;
 }
diff --git a/test/src/base/ossim-string-test.cpp b/test/src/base/ossim-string-test.cpp
index c02849b..32083d8 100644
--- a/test/src/base/ossim-string-test.cpp
+++ b/test/src/base/ossim-string-test.cpp
@@ -258,6 +258,14 @@ void testString()
    {
       std::cout<<"test of const char* == ossimString FAILED\n";
    }
+
+   ossimString s0;
+   ossimString s1 = "foo";
+   if (s0)
+      cout<<"bool operator (s) FAILED"<<endl;
+   if (!s1)
+      cout<<"bool operator (!s) FAILED"<<endl;
+
 }
 
 void testRegularExpression()
diff --git a/test/src/base/ossim-threaded-logfile-test.cpp b/test/src/base/ossim-threaded-logfile-test.cpp
index 93fd6f4..876dedd 100644
--- a/test/src/base/ossim-threaded-logfile-test.cpp
+++ b/test/src/base/ossim-threaded-logfile-test.cpp
@@ -6,12 +6,13 @@
 #include <ossim/base/ossimTimer.h>
 #include <ossim/init/ossimInit.h>
 
-#include <OpenThreads/Mutex>
-#include <OpenThreads/Barrier>
-#include <OpenThreads/Thread>
-OpenThreads::Barrier* startBarrier = 0;
-OpenThreads::Barrier* endBarrier = 0;
-class LogThread : public OpenThreads::Thread
+#include <ossim/base/Thread.h>
+#include <ossim/base/Barrier.h>
+#include <mutex>
+
+std::shared_ptr<ossim::Barrier> startBarrier;
+std::shared_ptr<ossim::Barrier> endBarrier;
+class LogThread : public ossim::Thread
 {
 public:
    LogThread(const ossimString& threadName)
@@ -71,8 +72,8 @@ int main(int argc, char* argv[])
    }
 
    std::vector<LogThread*> threadList(threads);
-   startBarrier = new OpenThreads::Barrier(threads); // include the main thread for synching
-   endBarrier   = new OpenThreads::Barrier(threads+1); //   include main thread for syncing end 
+   startBarrier = std::make_shared<ossim::Barrier>(threads+1); // include the main thread for synching
+   endBarrier   = std::make_shared<ossim::Barrier>(threads+1); // include the main thread for synching
    ossim_uint32 idx = 0;
    for(idx = 0; idx < threads; ++ idx)
    {
@@ -80,6 +81,7 @@ int main(int argc, char* argv[])
       threadList[idx]->setNumberOfStringsToLog(nvalues);
       threadList[idx]->start();
    }
+   startBarrier->block();
    ossimTimer::Timer_t t1 = ossimTimer::instance()->tick();
    // synch all threads to start at the same time
    std::cout << "Number of threads:         " << threads      << "\n";
@@ -88,7 +90,5 @@ int main(int argc, char* argv[])
    std::cout << "All threads finished\n";
    ossimTimer::Timer_t t2 = ossimTimer::instance()->tick();
    std::cout << "Time elapsed:              " << ossimTimer::instance()->delta_s(t1, t2) << " seconds" << "\n";
-   delete startBarrier;
-   delete endBarrier;
    return 0;
 }
diff --git a/test/src/base/ossim-threaded-polyarea2d-test.cpp b/test/src/base/ossim-threaded-polyarea2d-test.cpp
index 13ca783..4f9bf5f 100644
--- a/test/src/base/ossim-threaded-polyarea2d-test.cpp
+++ b/test/src/base/ossim-threaded-polyarea2d-test.cpp
@@ -7,12 +7,13 @@
 #include <ossim/init/ossimInit.h>
 #include <ossim/base/ossimPolyArea2d.h>
 
-#include <OpenThreads/Mutex>
-#include <OpenThreads/Barrier>
-#include <OpenThreads/Thread>
-OpenThreads::Barrier* startBarrier = 0;
-OpenThreads::Barrier* endBarrier = 0;
-class Polyarea2dThread : public OpenThreads::Thread
+#include <ossim/base/Thread.h>
+#include <ossim/base/Barrier.h>
+#include <mutex>
+
+std::shared_ptr<ossim::Barrier> startBarrier;
+std::shared_ptr<ossim::Barrier> endBarrier;
+class Polyarea2dThread : public ossim::Thread
 {
 public:
    Polyarea2dThread(const ossimString& threadName)
@@ -87,8 +88,8 @@ int main(int argc, char* argv[])
    }
 
    std::vector<Polyarea2dThread*> threadList(threads);
-   startBarrier = new OpenThreads::Barrier(threads); // include the main thread for synching
-   endBarrier   = new OpenThreads::Barrier(threads+1); //   include main thread for syncing end 
+   startBarrier = std::make_shared<ossim::Barrier>(threads+1); // include the main thread for synching
+   endBarrier   = std::make_shared<ossim::Barrier>(threads+1); // include the main thread for synching
    ossim_uint32 idx = 0;
    for(idx = 0; idx < threads; ++ idx)
    {
@@ -96,6 +97,7 @@ int main(int argc, char* argv[])
       threadList[idx]->setNumberOfPointsToQuery(nvalues);
       threadList[idx]->start();
    }
+   startBarrier->block();
    ossimTimer::Timer_t t1 = ossimTimer::instance()->tick();
    // synch all threads to start at the same time
    std::cout << "Number of threads:         " << threads      << "\n";
@@ -104,7 +106,5 @@ int main(int argc, char* argv[])
    std::cout << "All threads finished\n";
    ossimTimer::Timer_t t2 = ossimTimer::instance()->tick();
    std::cout << "Time elapsed:              " << ossimTimer::instance()->delta_s(t1, t2) << " seconds" << "\n";
-   delete startBarrier;
-   delete endBarrier;
    return 0;
 }
diff --git a/test/src/elevation/ossim-threaded-elevation-test.cpp b/test/src/elevation/ossim-threaded-elevation-test.cpp
index 543cd0d..60a4e71 100644
--- a/test/src/elevation/ossim-threaded-elevation-test.cpp
+++ b/test/src/elevation/ossim-threaded-elevation-test.cpp
@@ -7,17 +7,17 @@
 #include <ossim/base/ossimArgumentParser.h>
 #include <ossim/base/ossimTimer.h>
 #include <ossim/init/ossimInit.h>
-#include <OpenThreads/Mutex>
-#include <OpenThreads/Barrier>
-#include <OpenThreads/Thread>
+#include <ossim/base/Thread.h>
+#include <ossim/base/Barrier.h>
+#include <mutex>
 
-OpenThreads::Barrier* startBarrier = 0;
-OpenThreads::Barrier* endBarrier = 0;
-OpenThreads::Mutex accumMutex;
+std::shared_ptr<ossim::Barrier> startBarrier;
+std::shared_ptr<ossim::Barrier> endBarrier;
+std::mutex accumMutex;
 ossimRefPtr<ossimDtedElevationDatabase> dtedDatabase = new ossimDtedElevationDatabase;
 double accumH = 0.0;
 
-class ElevationThread : public OpenThreads::Thread
+class ElevationThread : public ossim::Thread
 {
 public:
    ElevationThread(const ossimString& threadName="",
@@ -65,8 +65,12 @@ public:
          {
             h = ossimElevManager::instance()->getHeightAboveEllipsoid(gpt);
          }
+         std::cout << h << "\n";
 #endif
-         hs += h;
+         if(!ossim::isnan(h))
+         {
+            hs += h;
+         }
       }
 
       accumMutex.lock();
@@ -166,8 +170,8 @@ int main(int argc, char* argv[])
   // std::cout << "Loaded database? " << dtedDatabase->loadState(kwl) << std::endl;
    srand(randomSeed);
    std::vector<ElevationThread*> threadList(num_threads);
-   startBarrier = new OpenThreads::Barrier(num_threads); // include the main thread for synching
-   endBarrier = new OpenThreads::Barrier(num_threads+1); //   include main thread for syncing end
+   startBarrier = std::make_shared<ossim::Barrier>(num_threads+1); // include the main thread for synching
+   endBarrier   = std::make_shared<ossim::Barrier>(num_threads+1); // include the main thread for synching
    ossim_uint32 idx = 0;
    for(idx = 0; idx < num_threads; ++ idx)
    {
@@ -175,6 +179,7 @@ int main(int argc, char* argv[])
       threadList[idx]->setNumberOfPointsToQuery(num_posts);
       threadList[idx]->start();
    }
+   startBarrier->block();
    ossimTimer::Timer_t t1 = ossimTimer::instance()->tick();
 
    // synch all threads to start at the same time
@@ -186,7 +191,5 @@ int main(int argc, char* argv[])
    ossimTimer::Timer_t t2 = ossimTimer::instance()->tick();
    std::cout << "Time elapsed:              " << ossimTimer::instance()->delta_s(t1, t2) << " seconds" << "\n";
    std::cout << "mean elevation:              " << accumH/num_threads << "\n";
-   delete startBarrier;
-   delete endBarrier;
    return 0;
 }
diff --git a/test/src/imaging/CMakeLists.txt b/test/src/imaging/CMakeLists.txt
index f477a3c..639cabd 100644
--- a/test/src/imaging/CMakeLists.txt
+++ b/test/src/imaging/CMakeLists.txt
@@ -24,3 +24,5 @@ OSSIM_SETUP_APPLICATION(ossim-single-image-chain-threaded-test INSTALL COMMAND_L
 OSSIM_SETUP_APPLICATION(ossim-threaded-chain-test INSTALL COMMAND_LINE COMPONENT_NAME ossim SOURCE_FILES ossim-threaded-chain-test.cpp)
 OSSIM_SETUP_APPLICATION(ossim-kmeans-filter-test INSTALL COMMAND_LINE COMPONENT_NAME ossim SOURCE_FILES ossim-kmeans-filter-test.cpp)
 OSSIM_SETUP_APPLICATION(ossim-fft-test INSTALL COMMAND_LINE COMPONENT_NAME ossim SOURCE_FILES ossim-fft-test.cpp)
+
+OSSIM_SETUP_APPLICATION(ossim-image-handler-state-test INSTALL COMMAND_LINE COMPONENT_NAME ossim SOURCE_FILES ossim-image-handler-state-test.cpp)
diff --git a/test/src/imaging/ossim-image-handler-state-test.cpp b/test/src/imaging/ossim-image-handler-state-test.cpp
new file mode 100644
index 0000000..5dfa3b2
--- /dev/null
+++ b/test/src/imaging/ossim-image-handler-state-test.cpp
@@ -0,0 +1,185 @@
+//---
+//
+// License: MIT
+//
+// File: ossim-foo.cpp
+//
+// Description: Contains application definition "ossim-foo" app.
+//
+// NOTE:  This is supplied for simple quick test. DO NOT checkin your test to
+//        the svn repository.  Simply edit ossim-foo.cpp and run your test.
+//        After completion you can do a "git checkout -- ossimfoo.cpp" if
+//        you want to keep your working repository up to snuff.
+//
+// $Id$
+//---
+
+// ossim includes:  These are here just to save time/typing...
+#include <ossim/base/ossimApplicationUsage.h>
+#include <ossim/base/ossimArgumentParser.h>
+#include <ossim/base/ossimException.h>
+#include <ossim/base/ossimFilename.h>
+#include <ossim/base/ossimIpt.h>
+#include <ossim/base/ossimIrect.h>
+#include <ossim/base/ossimKeywordlist.h>
+#include <ossim/base/ossimKeywordNames.h>
+#include <ossim/base/ossimTimer.h>
+#include <ossim/base/State.h>
+#include <ossim/imaging/ossimImageHandler.h>
+#include <ossim/imaging/ossimImageHandlerRegistry.h>
+#include <ossim/init/ossimInit.h>
+#include <ossim/support_data/ImageHandlerStateRegistry.h>
+// Put your includes here:
+
+// System includes:
+#include <cmath>
+#include <memory>
+#include <sstream>
+#include <iostream>
+
+int main(int argc, char *argv[])
+{
+   int returnCode = 0;
+   
+   ossimArgumentParser ap(&argc, argv);
+   ossimInit::instance()->addOptions(ap);
+   ossimInit::instance()->initialize(ap);
+   ap.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
+   ap.getApplicationUsage()->addCommandLineOption("--max-time-to-open-state","specify the time in seconds.  Example: 1.234");
+   ap.getApplicationUsage()->addCommandLineOption("--min-speedup","specify the minumum speedup for state open versus normal open.  For min-speedup = 2.5 means that we must be at least 2.5 times faster with the state");
+   ap.getApplicationUsage()->addCommandLineOption("--geom-test","Will enable geometry tests.  Will load the file the with and without the state and make sure the geometry remains the same");
+   std::string ts1;
+   ossimArgumentParser::ossimParameter sp1(ts1);
+
+   try
+   {
+      ossim_float64 maxTimeForStateOpen = -1;
+      ossim_float64 minSpeedup = 0.0;
+      bool geomTestFlag = false;
+   //   argumentParser.getApplicationUsage()->addCommandLineOption("--random-seed", "value to use as the seed for the random elevation post generator");
+      if (ap.argc() == 1 || ap.read("-h") ||
+          ap.read("--help"))
+      {
+         ap.getApplicationUsage()->write(ossimNotify(ossimNotifyLevel_INFO));
+         exit(0);
+      }
+      if(ap.read("--max-time-to-open-state", sp1))     
+      {
+         maxTimeForStateOpen = ossimString(ts1).toFloat64();
+      }
+      if(ap.read("--min-speedup", sp1))     
+      {
+         minSpeedup = ossimString(ts1).toFloat64();
+      }
+      if(ap.read("--geom-test"))
+      {
+         geomTestFlag = true;
+      }
+      if(ap.argc() == 2)
+      {
+
+         ossimTimer::Timer_t t1;
+         ossimTimer::Timer_t t2;         
+         std::shared_ptr<ossim::ImageHandlerState> state;
+         ossim_float64 deltaNoState = 0.0;
+
+         //std::cout << "maxTimeForStateOpen: " << maxTimeForStateOpen << "\n";
+         t1 = ossimTimer::instance()->tick();
+         ossimRefPtr<ossimImageHandler> h = ossimImageHandlerRegistry::instance()->open(ossimFilename(ap[1]));
+         t2 = ossimTimer::instance()->tick();
+         deltaNoState = ossimTimer::instance()->delta_s(t1,t2);
+
+         std::cout << "open-image-delta: " << deltaNoState << "\n"; 
+
+         if(h)
+         {
+            state = h->getState();
+
+            t1 = ossimTimer::instance()->tick();
+            ossimRefPtr<ossimImageHandler> hState  = ossimImageHandlerRegistry::instance()->open(state);
+            t2 = ossimTimer::instance()->tick();
+            
+            if(hState)
+            {
+               ossim_float64 deltaState = ossimTimer::instance()->delta_s(t1,t2);
+               std::cout << "open-image-state-delta: " << deltaState << "\n"; 
+               if(maxTimeForStateOpen > 0.0)
+               {
+                  std::cout << "max-time-to-open-state: " << maxTimeForStateOpen << "\n";
+                  if(deltaState>maxTimeForStateOpen)
+                  {
+                     throw ossimException("Took too long for state open!");
+                  }  
+               }
+               ossim_float64 r = deltaNoState/deltaState;
+
+               if(minSpeedup > 0.0)
+               {
+                  std::cout << "speedup: " << r << "\n";
+                  if(r < minSpeedup)
+                  {
+                     throw ossimException("Took too long for state open!");
+                  }
+               }
+
+               if(geomTestFlag)
+               {
+                  t1 = ossimTimer::instance()->tick();
+                  ossimRefPtr<ossimImageGeometry> geomNoState = h->getImageGeometry();
+                  t2 = ossimTimer::instance()->tick();
+                  std::cout << "geometry-no-state-delta: " << ossimTimer::instance()->delta_s(t1,t2) << "\n";
+                  t1 = ossimTimer::instance()->tick();
+                  ossimRefPtr<ossimImageGeometry> geomState   = hState->getImageGeometry();
+                  t2 = ossimTimer::instance()->tick();
+                  std::cout << "geometry-state-delta: " << ossimTimer::instance()->delta_s(t1,t2) << "\n";
+
+                  if(geomNoState&&geomState)
+                  {
+                     ossimKeywordlist kwl1,kwl2;
+
+                     geomNoState->saveState(kwl1);
+                     geomState->saveState(kwl2);
+
+                     if(kwl1 != kwl2)
+                     {
+                        std::cout << "GEOMETRY from No State Load: \n" << kwl1 << "\n";
+                        std::cout << "GEOMETRY from State Load: \n"    << kwl2 << "\n";
+                        throw ossimException("Geometries are not equal");
+                     }
+                  }
+                  else
+                  {
+                     throw ossimException("Unable to create geometry for geom test");
+                  }
+               }
+            }
+            else
+            {
+               throw ossimException(ossimString("Unable to open image from state")+ ap[1]);
+            }
+         }
+         else
+         {
+            throw ossimException(ossimString("Unable to open file") + ap[1]);
+         }
+      }
+      else
+      {
+         throw ossimException("Image not specified");
+      }
+    // add code
+   }
+   catch(const ossimException& e)
+   {
+      ossimNotify(ossimNotifyLevel_WARN) << e.what() << std::endl;
+      returnCode = 1;
+   }
+   catch( ... )
+   {
+      ossimNotify(ossimNotifyLevel_WARN)
+         << argv[0] << " caught unhandled exception!" << std::endl;
+      returnCode = 1;
+   }
+   
+   return returnCode;
+}
diff --git a/test/src/imaging/ossim-piecewise-remapper-test.cpp b/test/src/imaging/ossim-piecewise-remapper-test.cpp
index b52588f..3a74206 100644
--- a/test/src/imaging/ossim-piecewise-remapper-test.cpp
+++ b/test/src/imaging/ossim-piecewise-remapper-test.cpp
@@ -43,7 +43,7 @@ int main(int argc, char* argv[])
    if (argc < 2)
    {
       cout << argv[0] << "<image_file> <optional_output_file>"
-           << "\nOpens up single image chain and remaps it to the hardcoded parameters."
+           << "\nOpens up single image chain and dumps the state to keyword"
            << " list." << endl;
       return 0;
    }
@@ -72,7 +72,11 @@ int main(int argc, char* argv[])
 
       // ((<min_in> <max_in> <min_out> <max_out>),(<min_in> <max_in> <min_out> <max_out>))
       key = "band0.remap0";
-      val = "(1, 255, 255, 1)";
+      val = "((0, 127, 0, 127), (128, 255, 128, 382))";
+      kwl.addPair(key, val);
+      key = "band0.remap1";
+      val = "((0, 382, 0, 255))";
+      kwl.addPair(key, val);
 
       key = "scalar_type";
       val = "OSSIM_UINT8";
diff --git a/test/src/imaging/ossim-single-image-chain-test.cpp b/test/src/imaging/ossim-single-image-chain-test.cpp
index fbaa2d8..00b0c21 100644
--- a/test/src/imaging/ossim-single-image-chain-test.cpp
+++ b/test/src/imaging/ossim-single-image-chain-test.cpp
@@ -120,7 +120,8 @@ int main(int argc, char* argv[])
    }
 
    // Create a normal chain.
-   sic1 = new ossimSingleImageChain(true,  // addHistogramFlag
+   sic1 = new ossimSingleImageChain(false, // null flip
+                                    true,  // addHistogramFlag
                                     true,  // addResamplerCacheFlag
                                     true,  // addChainCacheFlag
                                     false, // remapToEightBitFlag
diff --git a/test/src/imaging/ossim-threaded-app-tile-cache-test.cpp b/test/src/imaging/ossim-threaded-app-tile-cache-test.cpp
index ec93e5f..07a2b27 100644
--- a/test/src/imaging/ossim-threaded-app-tile-cache-test.cpp
+++ b/test/src/imaging/ossim-threaded-app-tile-cache-test.cpp
@@ -9,12 +9,13 @@
 #include <ossim/init/ossimInit.h>
 #include <ossim/imaging/ossimAppFixedTileCache.h>
 #include <ossim/imaging/ossimImageData.h>
-#include <OpenThreads/Mutex>
-#include <OpenThreads/Barrier>
-#include <OpenThreads/Thread>
-OpenThreads::Barrier* startBarrier = 0;
-OpenThreads::Barrier* endBarrier = 0;
-class TileCacheThread : public OpenThreads::Thread
+#include <ossim/base/Thread.h>
+#include <ossim/base/Barrier.h>
+#include <mutex>
+
+std::shared_ptr<ossim::Barrier> startBarrier;
+std::shared_ptr<ossim::Barrier> endBarrier;
+class TileCacheThread : public ossim::Thread
 {
 public:
    TileCacheThread(const ossimString& threadName="",
@@ -98,8 +99,8 @@ int main(int argc, char* argv[])
       threads = tempString.toUInt32();
    }
    std::vector<TileCacheThread*> threadList(threads);
-   startBarrier = new OpenThreads::Barrier(threads+1); // include the main thread for synching
-   endBarrier = new OpenThreads::Barrier(threads+1); //   include main thread for syncing end 
+   startBarrier = std::make_shared<ossim::Barrier>(threads+1); // include the main thread for synching
+   endBarrier   = std::make_shared<ossim::Barrier>(threads+1); // include the main thread for synching
    ossim_uint32 idx = 0;
    for(idx = 0; idx < threads; ++ idx)
    {
@@ -114,6 +115,5 @@ int main(int argc, char* argv[])
    std::cout << "All threads finished\n";
    ossimTimer::Timer_t t2 = ossimTimer::instance()->tick();
    std::cout << "Time elapsed:              " << ossimTimer::instance()->delta_s(t1, t2) << " seconds" << "\n";
-   delete endBarrier;
    return 0;
 }
diff --git a/test/src/imaging/ossim-threaded-chain-test.cpp b/test/src/imaging/ossim-threaded-chain-test.cpp
index 2bf925c..528b709 100644
--- a/test/src/imaging/ossim-threaded-chain-test.cpp
+++ b/test/src/imaging/ossim-threaded-chain-test.cpp
@@ -95,7 +95,7 @@ int main(int argc, char *argv[])
    
    // Create original chain:
    ossimRefPtr<ossimSingleImageChain> singleImageChain =
-      new ossimSingleImageChain(false, chainCacheEnabled, false, false, false, false);
+      new ossimSingleImageChain(false, false, chainCacheEnabled, false, false, false, false);
    if (!singleImageChain->open(image_file))
    {
       cout<<"\nUnable to open image file at <"<<image_file<<">. Aborting..."<<endl;
diff --git a/test/src/ossim-foo.cpp b/test/src/ossim-foo.cpp
index f8b79b0..6e756f5 100644
--- a/test/src/ossim-foo.cpp
+++ b/test/src/ossim-foo.cpp
@@ -14,6 +14,12 @@
 // $Id$
 //---
 
+// System includes:
+#include <cmath>
+#include <memory>
+#include <sstream>
+#include <iostream>
+
 // ossim includes:  These are here just to save time/typing...
 #include <ossim/base/ossimApplicationUsage.h>
 #include <ossim/base/ossimArgumentParser.h>
@@ -38,6 +44,7 @@
 #include <ossim/base/ossimStdOutProgress.h>
 #include <ossim/base/ossimStreamFactoryRegistry.h>
 #include <ossim/base/ossimStringProperty.h>
+#include <ossim/base/ossimTimer.h>
 #include <ossim/base/ossimTrace.h>
 #include <ossim/base/ossimUrl.h>
 #include <ossim/base/ossimVisitor.h>
@@ -67,6 +74,7 @@
 #include <ossim/imaging/ossimTwoColorView.h>
 #include <ossim/imaging/ossimImageSourceFactoryRegistry.h>
 #include <ossim/imaging/ossimImageHandlerRegistry.h>
+#include <ossim/support_data/ImageHandlerState.h>
 
 #include <ossim/init/ossimInit.h>
 
@@ -80,14 +88,15 @@
 #include <ossim/support_data/ossimSrcRecord.h>
 #include <ossim/support_data/ossimWkt.h>
 
-// Put your includes here:
+#include <ossim/base/Barrier.h>
+#include <ossim/base/Block.h>
+#include <ossim/base/Thread.h>
+#include <ossim/support_data/TiffHandlerState.h>
+#include <ossim/support_data/ImageHandlerStateRegistry.h>
 
-// System includes:
-#include <cmath>
-#include <memory>
-#include <sstream>
-#include <iostream>
-using namespace std;
+// Put your includes here:
+#include<ossim/projection/ossimNitfRpcModel.h>
+#include<ossim/projection/ossimQuickbirdRpcModel.h>
 
 int main(int argc, char *argv[])
 {
@@ -97,9 +106,58 @@ int main(int argc, char *argv[])
    ossimInit::instance()->addOptions(ap);
    ossimInit::instance()->initialize(ap);
 
+   ossimFilename fname (argv[1]);
+
    try
    {
-      // Put your code here.
+      ossimImageHandlerRegistry* handlerReg = ossimImageHandlerRegistry::instance();
+      ossimProjectionFactoryRegistry* projReg = ossimProjectionFactoryRegistry::instance();
+
+      // Open the image and fetch the geometry via the plugin:
+      ossimRefPtr<ossimImageHandler> pluginHandler = handlerReg->open(fname, true, false);
+      ossimRefPtr<ossimImageGeometry> pluginGeom = pluginHandler->getImageGeometry();
+      cout<<"pluginGeom's projection: "<<pluginGeom->getProjection()->getClassName()<<endl;
+
+      // NITF:
+      ossimRefPtr<ossimNitfRpcModel> nitfProj = new ossimNitfRpcModel(fname);
+      ossimRefPtr<ossimImageGeometry> nitfGeom = new ossimImageGeometry(0, nitfProj.get());
+      cout<<"NITF projection: "<<nitfProj->getClassName()<<endl;
+
+      // QB:
+      ossimRefPtr<ossimQuickbirdRpcModel> dgqbProj = new ossimQuickbirdRpcModel();
+      dgqbProj->parseFile(fname);
+      ossimRefPtr<ossimImageGeometry> dgqbGeom = new ossimImageGeometry(0, dgqbProj.get());
+      cout<<"DG/QB projection: "<<dgqbProj->getClassName()<<endl;
+
+      // Establish even image point distribution:
+      ossimIrect imageRect;
+      pluginGeom->getBoundingRect(imageRect);
+      int dx = (imageRect.width()-1)/2;
+      int dy = (imageRect.height()-1)/2;
+      ossimGpt pluginGpt, nitfGpt, dgqbGpt;
+      ossimDpt ip0;
+      double nitfDist, dgqbDist;
+
+      // Compute residual error between models:
+      for (int Y=0; Y<3; Y++)
+      {
+         ip0.y = dy*Y;
+         for (int X=0; X<3; X++)
+         {
+            ip0.x = dx*X;
+            pluginGeom->localToWorld(ip0, 0, pluginGpt);
+
+            nitfGeom->localToWorld(ip0, 0, nitfGpt);
+            nitfDist = pluginGpt.distanceTo(nitfGpt);
+
+            dgqbGeom->localToWorld(ip0, 0, dgqbGpt);
+            dgqbDist = pluginGpt.distanceTo(dgqbGpt);
+
+            cout  <<"\nGround residuals for image point "<<ip0<<":"
+                  <<"\n  NITF: "<<nitfDist<<" m"
+                  <<"\n  DGQB: "<<dgqbDist<<" m"<<endl;
+         }
+      }
    }
    catch(const ossimException& e)
    {
diff --git a/test/src/parallel/ossim-jobqueue-test.cpp b/test/src/parallel/ossim-jobqueue-test.cpp
index e3d7fb3..8507d69 100644
--- a/test/src/parallel/ossim-jobqueue-test.cpp
+++ b/test/src/parallel/ossim-jobqueue-test.cpp
@@ -5,8 +5,9 @@
 #include <ossim/base/ossimArgumentParser.h>
 #include <ossim/base/ossimApplicationUsage.h>
 #include <ossim/init/ossimInit.h>
-#include <OpenThreads/Thread>
 #include <iostream>
+#include <ossim/base/Thread.h>
+
 static const int INITIAL_THREADS = 10;
 static const int INITIAL_JOBS = 20;
 class ossimTestJob : public ossimJob
@@ -17,7 +18,8 @@ public:
    {
       setName(name);
    }
-   virtual void start()
+protected:
+   virtual void run()
    {
    }
 };
@@ -28,15 +30,15 @@ public:
    ossimTestJobCallback()
    {
    }
-   virtual void started(ossimJob* job)
+   virtual void started(std::shared_ptr<ossimJob> job)
    {
       std::cout << "I HAVE STARTED THE Job " << job->name() << "\n";
    }
-   virtual void finished(ossimJob* job)
+   virtual void finished(std::shared_ptr<ossimJob> job)
    {
       std::cout << "I HAVE FINISHED THE Job " << job->name() << "\n";
    }
-   virtual void canceled(ossimJob* job)
+   virtual void canceled(std::shared_ptr<ossimJob> job)
    {
       std::cout << "I HAVE CANCELED THE Job " << job->name() << "\n";
    }
@@ -49,28 +51,27 @@ int main(int argc, char *argv[])
    ossimInit::instance()->addOptions(ap);
    ossimInit::instance()->initialize(ap);
    
-   ossimRefPtr<ossimJobQueue> q = new ossimJobQueue();
-   ossimRefPtr<ossimJobMultiThreadQueue> threadQueue = new ossimJobMultiThreadQueue(q.get(), INITIAL_THREADS);
-   ossimRefPtr<ossimTestJobCallback> callback = new ossimTestJobCallback();
+   std::shared_ptr<ossimJobQueue> q = std::make_shared<ossimJobQueue>();
+   std::shared_ptr<ossimJobMultiThreadQueue> threadQueue = std::make_shared<ossimJobMultiThreadQueue>(q, INITIAL_THREADS);
+   std::shared_ptr<ossimTestJobCallback> callback = std::make_shared<ossimTestJobCallback>();
    ossim_uint32 idx = 0;
    for(idx = 0; idx < INITIAL_JOBS; ++idx)
    {
-      ossimRefPtr<ossimTestJob> job = new ossimTestJob(ossimString::toString(idx+1));
-      job->setCallback(callback.get());
+      std::shared_ptr<ossimTestJob> job = std::make_shared<ossimTestJob>(ossimString::toString(idx+1));
+      job->setCallback(callback);
       job->ready();
-      q->add(job.get());
+      q->add(job);
    }
    
    // FOREVER loop until all jobs are completed.
    while(true)
    {
-      if ( OpenThreads::Thread::microSleep(250) == 0 )
+      ossim::Thread::sleepInMicroSeconds(250);
+      if ( threadQueue->hasJobsToProcess() == false )
       {
-         if ( threadQueue->hasJobsToProcess() == false )
-         {
-            break;
-         }
+         break;
       }
+      ossim::Thread::yieldCurrentThread();
    }
    
    return 0;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/ossim.git



More information about the Pkg-grass-devel mailing list