Index: Damkjer/PointProcessing/SpatialAnalyzer/spanalyze.m
===================================================================
--- Damkjer/PointProcessing/SpatialAnalyzer/spanalyze.m	(revision 6)
+++ Damkjer/PointProcessing/SpatialAnalyzer/spanalyze.m	(revision 7)
@@ -1,3 +1,3 @@
-%%
+%
 % [CLASSES] = SPANALYZE(QUERIES, DATABASE, ...)
 %
@@ -72,5 +72,18 @@
 
    if (isempty(userParams.counts) && isempty(userParams.steps))
-      [covs,bias,inty]=fastcov(cellfun(@(x) QUERIES(:,x)',NN,'UniformOutput',false));
+      cells=cell(1,length(NN));
+      
+      for n=1:length(NN)
+         cells{n}=QUERIES(:,NN{n})';
+      end
+ 
+%      covs=cell(1,length(cells));
+%      
+%      parfor n=1:length(cells)
+%         covs{n}=cov(cells{n}');
+%      end
+      
+%      [covs,bias,inty]=fastcov(cellfun(@(x) QUERIES(:,x)',NN,'UniformOutput',false));
+      [covs,bias,inty]=fastcov(cells);
    elseif (~isempty(userParams.counts))
       tempfeats=zeros(dimensions,size(NN,1));
@@ -187,7 +200,11 @@
 %    cellfun(@(x) disp(x),covs);
 
+   rad=userParams.radius;
+
+   [V,D]=par_eig(covs);
+   
    for nbr=1:size(NN,1)
       % skip underconstrained (possible with radius searches)
-      if (length(NN{nbr})<5 || any(any(isnan(covs{nbr}))))
+      if (rad > 0 && (length(NN{nbr})<5 || any(any(isnan(covs{nbr})))))
          continue;
       end
@@ -195,14 +212,21 @@
 %       maxnbrs=max(maxnbrs,length(NN{nbr}));
       
-      [V,D]=eig(covs{nbr});
-      [~,index]=min(diag(D));
+%      [V,D]=eig(covs{nbr});
+%      [~,index]=min(diag(D));
+%      [~,index]=min(D{nbr});
 %       norms(:,elem+nbr-1)=abs(V(:,index)) .* sqrt(D(index, index));
-      norms(:,elem+nbr-1)=abs(V(:,index));
-
+%      norms(:,elem+nbr-1)=abs(V(:,index));
+%      norms(:,elem+nbr-1)=abs(V{nbr}(:,index));
+
+      A=V{nbr};
+      norms(:,elem+nbr-1)=abs(A(:,end));
+      
       % Define features as eigenvalues
       % feats(:,elem+nbr-1)=sort(diag(D),'descend');
 
       % Define features as singular values
-      feats(:,elem+nbr-1)=sqrt(sort(diag(D),'descend'));
+%      feats(:,elem+nbr-1)=sqrt(sort(diag(D),'descend'));
+%      feats(:,elem+nbr-1)=sqrt(sort(D{nbr},'descend'));
+      feats(:,elem+nbr-1)=sqrt(D{nbr});
 
       biases(elem+nbr-1)=bias{nbr};
@@ -351,5 +375,5 @@
 end
 
-%%
+%
 % PARSEINPUTS    Support function to parse inputs into userParams structure
 function [userParams] = parseInputs(varargin)
Index: Damkjer/Util/FileIO/GeoKey/GeoKey.m
===================================================================
--- Damkjer/Util/FileIO/GeoKey/GeoKey.m	(revision 6)
+++ Damkjer/Util/FileIO/GeoKey/GeoKey.m	(revision 7)
@@ -17,8 +17,11 @@
 %    None.
 %
-% Other m-files required:
+% Toolbox requirements:
 %    None.
 %
-% MAT-files required:
+% Script requirements:
+%    None.
+%
+% Data requirements:
 %    None.
 %
Index: Damkjer/Util/FileIO/GeoKey/geoKeyFactory.m
===================================================================
--- Damkjer/Util/FileIO/GeoKey/geoKeyFactory.m	(revision 6)
+++ Damkjer/Util/FileIO/GeoKey/geoKeyFactory.m	(revision 7)
@@ -24,5 +24,8 @@
 %    vlr  - A specialized LAS File VLR Specification object
 %
-% Other m-files required:
+% Toolbox requirements:
+%    None.
+%
+% Script requirements:
 %    GTModelTypeGeoKey.m
 %    GTRasterTypeGeoKey.m
@@ -71,5 +74,5 @@
 %    VerticalCitationGeoKey.m
 %
-% MAT-files required:
+% Data requirements:
 %    None.
 %
Index: Damkjer/Util/FileIO/LasFile/LasFile.m
===================================================================
--- Damkjer/Util/FileIO/LasFile/LasFile.m	(revision 6)
+++ Damkjer/Util/FileIO/LasFile/LasFile.m	(revision 7)
@@ -12,21 +12,21 @@
 %
 % Properties:
-%    publicHeader      - The LAS File Public Header Block
-%    vlrs              - The LAS File VLRs
-%    intensity         - The Pulse Return Magnitude
-%    returnNumber      - The Pulse Return Number
-%    numberOfReturns   - The Pulse Number of Returns
-%    scanDirection     - The Pulse Scan Direction
-%    edgeOfFlightLine  - Edge of Flight Line Flag
-%    classification    - The Pulse Category Classification
-%    synthetic         - The Synthetic Point Flag
-%    keyPoint          - The Key Point Flag
-%    withheld          - The Withheld Point Flag
-%    scanAngleRank     - The Pulse Scan Angle Rank
-%    userData          - The User Data Field
-%    pointSourceID     - The Point Source ID
-%    points            - The Pulse X, Y, and Z Coordinates
-%    gpsTime           - The Pulse GPS Time
-%    color             - The Point Color
+%    publicHeader      - The LAS File Public Header Block.
+%    vlrs              - The LAS File VLRs.
+%    intensity         - The Pulse Return Magnitude.
+%    returnNumber      - The Pulse Return Number.
+%    numberOfReturns   - The Pulse Number of Returns.
+%    scanDirection     - The Pulse Scan Direction.
+%    edgeOfFlightLine  - Edge of Flight Line Flag.
+%    classification    - The Pulse Category Classification.
+%    synthetic         - The Synthetic Point Flag.
+%    keyPoint          - The Key Point Flag.
+%    withheld          - The Withheld Point Flag.
+%    scanAngleRank     - The Pulse Scan Angle Rank.
+%    userData          - The User Data Field.
+%    pointSourceID     - The Point Source ID.
+%    points            - The Pulse X, Y, and Z Coordinates.
+%    gpsTime           - The Pulse GPS Time.
+%    color             - The Point Color.
 %
 % Methods:
@@ -296,5 +296,5 @@
          if (size(pointData,1) ~= 3)
             error('LasFile:DimensionMismatch',...
-               'Points must have 3 coordinates');
+                  'Points must have 3 coordinates');
          end
          
@@ -302,30 +302,42 @@
          
          if (size(lasFile.pPoints,2) > nPoints)
-            lasFile.intensity=lasFile.intensity(:,1:nPoints);
-            lasFile.returnNumber=lasFile.returnNumber(:,1:nPoints);
-            lasFile.numberOfReturns=lasFile.numberOfReturns(:,1:nPoints);
-            lasFile.scanDirection=lasFile.scanDirection(:,1:nPoints);
-            lasFile.edgeOfFlightLine=lasFile.edgeOfFlightLine(:,1:nPoints);
-            lasFile.classification=lasFile.classification(:,1:nPoints);
-            lasFile.synthetic=lasFile.synthetic(:,1:nPoints);
-            lasFile.keyPoint=lasFile.keyPoint(:,1:nPoints);
-            lasFile.withheld=lasFile.withheld(:,1:nPoints);
-            lasFile.scanAngleRank=lasFile.scanAngleRank(:,1:nPoints);
-            lasFile.userData=lasFile.userData(:,1:nPoints);
-            lasFile.pointSourceID=lasFile.pointSourceID(:,1:nPoints);
+            lasFile.intensity        = lasFile.intensity(:,1:nPoints);
+            lasFile.returnNumber     = lasFile.returnNumber(:,1:nPoints);
+            lasFile.numberOfReturns  = lasFile.numberOfReturns(:,1:nPoints);
+            lasFile.scanDirection    = lasFile.scanDirection(:,1:nPoints);
+            lasFile.edgeOfFlightLine = lasFile.edgeOfFlightLine(:,1:nPoints);
+            lasFile.classification   = lasFile.classification(:,1:nPoints);
+            lasFile.synthetic        = lasFile.synthetic(:,1:nPoints);
+            lasFile.keyPoint         = lasFile.keyPoint(:,1:nPoints);
+            lasFile.withheld         = lasFile.withheld(:,1:nPoints);
+            lasFile.scanAngleRank    = lasFile.scanAngleRank(:,1:nPoints);
+            lasFile.userData         = lasFile.userData(:,1:nPoints);
+            lasFile.pointSourceID    = lasFile.pointSourceID(:,1:nPoints);
          else
             addPoints = nPoints-size(lasFile.pPoints,2);
-            lasFile.intensity=[lasFile.intensity zeros(1,addPoints,'uint16')];
-            lasFile.returnNumber=[lasFile.returnNumber zeros(1,addPoints,'uint8')];
-            lasFile.numberOfReturns=[lasFile.numberOfReturns zeros(1,addPoints,'uint8')];
-            lasFile.scanDirection=[lasFile.scanDirection false(1,addPoints)];
-            lasFile.edgeOfFlightLine=[lasFile.edgeOfFlightLine false(1,addPoints)];
-            lasFile.classification=[lasFile.classification zeros(1,addPoints,'uint8')];
-            lasFile.synthetic=[lasFile.synthetic false(1,addPoints)];
-            lasFile.keyPoint=[lasFile.keyPoint false(1,addPoints)];
-            lasFile.withheld=[lasFile.withheld false(1,addPoints)];
-            lasFile.scanAngleRank=[lasFile.scanAngleRank zeros(1,addPoints,'int8')];
-            lasFile.userData=[lasFile.userData zeros(1,addPoints,'uint8')];
-            lasFile.pointSourceID=[lasFile.pointSourceID zeros(1,addPoints,'uint16')];
+            lasFile.intensity = ...
+               [lasFile.intensity zeros(1,addPoints,'uint16')];
+            lasFile.returnNumber = ...
+               [lasFile.returnNumber zeros(1,addPoints,'uint8')];
+            lasFile.numberOfReturns = ...
+               [lasFile.numberOfReturns zeros(1,addPoints,'uint8')];
+            lasFile.scanDirection = ...
+               [lasFile.scanDirection false(1,addPoints)];
+            lasFile.edgeOfFlightLine = ...
+               [lasFile.edgeOfFlightLine false(1,addPoints)];
+            lasFile.classification = ...
+               [lasFile.classification zeros(1,addPoints,'uint8')];
+            lasFile.synthetic = ...
+               [lasFile.synthetic false(1,addPoints)];
+            lasFile.keyPoint = ...
+               [lasFile.keyPoint false(1,addPoints)];
+            lasFile.withheld = ...
+               [lasFile.withheld false(1,addPoints)];
+            lasFile.scanAngleRank = ...
+               [lasFile.scanAngleRank zeros(1,addPoints,'int8')];
+            lasFile.userData = ...
+               [lasFile.userData zeros(1,addPoints,'uint8')];
+            lasFile.pointSourceID = ...
+               [lasFile.pointSourceID zeros(1,addPoints,'uint16')];
          end
          
@@ -350,9 +362,9 @@
          lasFile.publicHeader.zOffset = minZ+0.5*(maxZ-minZ);
          lasFile.publicHeader.xScaleFactor = (maxX-minX)/...
-            double(intmax('uint32')-1);
+                                             double(intmax('uint32')-1);
          lasFile.publicHeader.yScaleFactor = (maxY-minY)/...
-            double(intmax('uint32')-1);
+                                             double(intmax('uint32')-1);
          lasFile.publicHeader.zScaleFactor = (maxZ-minZ)/...
-            double(intmax('uint32')-1);
+                                             double(intmax('uint32')-1);
       end
       
@@ -362,5 +374,5 @@
          if (size(timeData,2) ~= lasFile.publicHeader.nPoints)
             error('LasFile:DimensionMismatch',...
-               'GPS Time Data must have an entry for each point');
+                  'GPS Time Data must have an entry for each point');
          end
          
@@ -382,15 +394,15 @@
          if (~strcmp(class(colorData),'uint16'))
             error('LasFile:DataTypeMismatch',...
-               'Color data must be of type uint16');
+                  'Color data must be of type uint16');
          end
          
          if (size(colorData,1) ~= 3)
             error('LasFile:DimensionMismatch',...
-               'Color data must have 3 coordinates');
+                  'Color data must have 3 coordinates');
          end
          
          if (size(colorData,2) ~= lasFile.publicHeader.nPoints)
             error('LasFile:DimensionMismatch',...
-               'Color data must have an entry for each point');
+                  'Color data must have an entry for each point');
          end
          
@@ -422,5 +434,5 @@
          else
             error('LasFile:InitError',...
-               'Unknown argument initializer');
+                  'Unknown argument initializer');
          end
          
@@ -443,59 +455,57 @@
          % Un-Pack data from uint8 for fast reading.
          fseek(fid, lasFile.publicHeader.offsetToPointData, 'bof');
-         temp = reshape(fread(fid,...
-            double(lasFile.publicHeader.pointDataRecordLength)*...
-            lasFile.publicHeader.nPoints,...
-            'uint8=>uint8'),...
-            lasFile.publicHeader.pointDataRecordLength,...
-            lasFile.publicHeader.nPoints);
+         temp = reshape(...
+                   fread(...
+                      fid,...
+                      double(lasFile.publicHeader.pointDataRecordLength)*...
+                      lasFile.publicHeader.nPoints,...
+                      'uint8=>uint8'),...
+                   lasFile.publicHeader.pointDataRecordLength,...
+                   lasFile.publicHeader.nPoints);
          fclose(fid);
          
-         offsets = diag([...
-            lasFile.publicHeader.xOffset,...
-            lasFile.publicHeader.yOffset,...
-            lasFile.publicHeader.zOffset]);
-         
-         scales = diag([...
-            lasFile.publicHeader.xScaleFactor,...
-            lasFile.publicHeader.yScaleFactor,...
-            lasFile.publicHeader.zScaleFactor]);
-         
-         tempPoints = temp(1:12,:);
-         tempInt = temp(13:14,:);
-         tempPtInfo = temp(15,:);
+         offsets = diag([lasFile.publicHeader.xOffset,...
+                         lasFile.publicHeader.yOffset,...
+                         lasFile.publicHeader.zOffset]);
+         
+         scales = diag([lasFile.publicHeader.xScaleFactor,...
+                        lasFile.publicHeader.yScaleFactor,...
+                        lasFile.publicHeader.zScaleFactor]);
+         
+         tempPoints  = temp(1:12,:);
+         tempInt     = temp(13:14,:);
+         tempPtInfo  = temp(15,:);
          tempPtClass = temp(16,:);
-         tempSARank = temp(17,:);
-         tempUData = temp(18,:);
-         tempSrcID = temp(19:20,:);
-         
-         lasFile.pPoints = double(...
-            reshape(typecast(tempPoints(:),'int32'),...
-            3,lasFile.publicHeader.nPoints));
+         tempSARank  = temp(17,:);
+         tempUData   = temp(18,:);
+         tempSrcID   = temp(19:20,:);
+         
+         lasFile.pPoints = double(reshape(typecast(tempPoints(:),'int32'),...
+                                  3,lasFile.publicHeader.nPoints));
          
          lasFile.pPoints = scales*lasFile.pPoints+...
-            offsets*ones(size(lasFile.pPoints));
+                           offsets*ones(size(lasFile.pPoints));
          
          lasFile.intensity=reshape(typecast(tempInt(:),'uint16'),...
-            1,lasFile.publicHeader.nPoints);
-         
-         lasFile.returnNumber=bitand(tempPtInfo,7);
-         lasFile.numberOfReturns=bitand(bitshift(tempPtInfo,-3),7);
-         lasFile.scanDirection=logical(bitget(tempPtInfo,7));
-         lasFile.edgeOfFlightLine=logical(bitget(tempPtInfo,8));
-         
-         lasFile.withheld=logical(bitget(tempPtClass,8));
-         lasFile.keyPoint=logical(bitget(tempPtClass,7));
-         lasFile.synthetic=logical(bitget(tempPtClass,6));
-         lasFile.classification=bitand(tempPtClass,31);
+                                   1,lasFile.publicHeader.nPoints);
+         
+         lasFile.returnNumber     = bitand(tempPtInfo,7);
+         lasFile.numberOfReturns  = bitand(bitshift(tempPtInfo,-3),7);
+         lasFile.scanDirection    = logical(bitget(tempPtInfo,7));
+         lasFile.edgeOfFlightLine = logical(bitget(tempPtInfo,8));
+         
+         lasFile.withheld       = logical(bitget(tempPtClass,8));
+         lasFile.keyPoint       = logical(bitget(tempPtClass,7));
+         lasFile.synthetic      = logical(bitget(tempPtClass,6));
+         lasFile.classification = bitand(tempPtClass,31);
          
          lasFile.scanAngleRank=reshape(typecast(tempSARank(:),...
-            'int8'),1,lasFile.publicHeader.nPoints);
+                                       'int8'),1,lasFile.publicHeader.nPoints);
          
          lasFile.userData=reshape(typecast(tempUData(:),'uint8'),...
-            1,lasFile.publicHeader.nPoints);
-         
-         lasFile.pointSourceID=reshape(typecast(tempSrcID(:),...
-            'uint16'),...
-            1,lasFile.publicHeader.nPoints);
+                                  1,lasFile.publicHeader.nPoints);
+         
+         lasFile.pointSourceID=reshape(typecast(tempSrcID(:),'uint16'),...
+                                       1,lasFile.publicHeader.nPoints);
          
          switch lasFile.publicHeader.pointDataFormatID
@@ -503,24 +513,20 @@
                tempGps = temp(21:28,:);
                
-               lasFile.pGpsTime=reshape(typecast(tempGps(:),...
-                  'double'),...
-                  1,lasFile.publicHeader.nPoints);
+               lasFile.pGpsTime=reshape(typecast(tempGps(:),'double'),...
+                                        1,lasFile.publicHeader.nPoints);
             case 2
                tempColor = temp(21:26,:);
                
-               lasFile.pColor = reshape(...
-                  typecast(tempColor(:),'uint16'),...
-                  3,lasFile.publicHeader.nPoints);
+               lasFile.pColor = reshape(typecast(tempColor(:),'uint16'),...
+                                        3,lasFile.publicHeader.nPoints);
             case 3
-               tempGps = temp(21:28,:);
+               tempGps   = temp(21:28,:);
                tempColor = temp(29:34,:);
                
-               lasFile.pGpsTime=reshape(typecast(tempGps(:),...
-                  'double'),...
-                  1,lasFile.publicHeader.nPoints);
-               
-               lasFile.pColor = reshape(...
-                  typecast(tempColor(:),'uint16'),...
-                  3,lasFile.publicHeader.nPoints);
+               lasFile.pGpsTime=reshape(typecast(tempGps(:),'double'),...
+                                        1,lasFile.publicHeader.nPoints);
+               
+               lasFile.pColor = reshape(typecast(tempColor(:),'uint16'),...
+                                        3,lasFile.publicHeader.nPoints);
          end
          
@@ -552,5 +558,5 @@
          else
             error('LasFile:InitError',...
-               'Unknown argument initializer');
+                  'Unknown argument initializer');
          end
          
@@ -562,60 +568,58 @@
          
          % Pack data to uint8 for fast writing.
-         offs=diag([...
-            lasFile.publicHeader.xOffset,...
-            lasFile.publicHeader.yOffset,...
-            lasFile.publicHeader.zOffset]);
-         
-         invSF=diag([...
-            1/lasFile.publicHeader.xScaleFactor,...
-            1/lasFile.publicHeader.yScaleFactor,...
-            1/lasFile.publicHeader.zScaleFactor]);
+         offs=diag([lasFile.publicHeader.xOffset,...
+                    lasFile.publicHeader.yOffset,...
+                    lasFile.publicHeader.zOffset]);
+         
+         invSF=diag([1/lasFile.publicHeader.xScaleFactor,...
+                     1/lasFile.publicHeader.yScaleFactor,...
+                     1/lasFile.publicHeader.zScaleFactor]);
          
          outPoints=int32(invSF*(lasFile.pPoints-...
-            offs*ones(size(lasFile.pPoints))));
+                                offs*ones(size(lasFile.pPoints))));
          
          uintPoints = reshape(typecast(outPoints(:),'uint8'),...
-            12,lasFile.publicHeader.nPoints);
+                              12,lasFile.publicHeader.nPoints);
          
          uintInt = reshape(typecast(lasFile.intensity(:),'uint8'),...
-            2,lasFile.publicHeader.nPoints);
-         
-         ptInfo=bitand(lasFile.returnNumber,7);
-         ptInfo=bitor(bitshift(bitand(lasFile.numberOfReturns,7),3),ptInfo);
-         ptInfo=bitset(ptInfo,7,lasFile.scanDirection);
-         ptInfo=bitset(ptInfo,8,lasFile.edgeOfFlightLine);
-         
-         ptClass=bitand(lasFile.classification,31);
-         ptClass=bitset(ptClass,6,lasFile.synthetic);
-         ptClass=bitset(ptClass,7,lasFile.keyPoint);
-         ptClass=bitset(ptClass,8,lasFile.withheld);
+                           2,lasFile.publicHeader.nPoints);
+         
+         ptInfo = bitand(lasFile.returnNumber,7);
+         ptInfo = bitor(bitshift(bitand(lasFile.numberOfReturns,7),3),ptInfo);
+         ptInfo = bitset(ptInfo,7,lasFile.scanDirection);
+         ptInfo = bitset(ptInfo,8,lasFile.edgeOfFlightLine);
+         
+         ptClass = bitand(lasFile.classification,31);
+         ptClass = bitset(ptClass,6,lasFile.synthetic);
+         ptClass = bitset(ptClass,7,lasFile.keyPoint);
+         ptClass = bitset(ptClass,8,lasFile.withheld);
          
          uintSA = reshape(typecast(lasFile.scanAngleRank(:),'uint8'),...
-            1,lasFile.publicHeader.nPoints);
+                          1,lasFile.publicHeader.nPoints);
          
          uintID = reshape(typecast(lasFile.pointSourceID(:),'uint8'),...
-            2,lasFile.publicHeader.nPoints);
+                          2,lasFile.publicHeader.nPoints);
          
          switch lasFile.publicHeader.pointDataFormatID
             case 0
                temp = [uintPoints;...
-                  uintInt;...
-                  ptInfo;...
-                  ptClass;...
-                  uintSA;...
-                  lasFile.userData;...
-                  uintID];
+                       uintInt;...
+                       ptInfo;...
+                       ptClass;...
+                       uintSA;...
+                       lasFile.userData;...
+                       uintID];
             case 1
                uintGPS = reshape(typecast(lasFile.pGpsTime(:),'uint8'),...
-                  8,lasFile.publicHeader.nPoints);
+                                 8,lasFile.publicHeader.nPoints);
                
                temp = [uintPoints;...
-                  uintInt;...
-                  ptInfo;...
-                  ptClass;...
-                  uintSA;...
-                  lasFile.userData;...
-                  uintID;...
-                  uintGPS];
+                       uintInt;...
+                       ptInfo;...
+                       ptClass;...
+                       uintSA;...
+                       lasFile.userData;...
+                       uintID;...
+                       uintGPS];
             case 2
                uintColor = reshape(typecast(lasFile.pColor(:),'uint8'),...
@@ -623,27 +627,27 @@
                
                temp = [uintPoints;...
-                  uintInt;...
-                  ptInfo;...
-                  ptClass;...
-                  uintSA;...
-                  lasFile.userData;...
-                  uintID;...
-                  uintColor];
+                       uintInt;...
+                       ptInfo;...
+                       ptClass;...
+                       uintSA;...
+                       lasFile.userData;...
+                       uintID;...
+                       uintColor];
             case 3
                uintGPS = reshape(typecast(lasFile.pGpsTime(:),'uint8'),...
-                  8,lasFile.publicHeader.nPoints);
+                                 8,lasFile.publicHeader.nPoints);
                
                uintColor = reshape(typecast(lasFile.pColor(:),'uint8'),...
-                  6,lasFile.publicHeader.nPoints);
+                                   6,lasFile.publicHeader.nPoints);
                
                temp = [uintPoints;...
-                  uintInt;...
-                  ptInfo;...
-                  ptClass;...
-                  uintSA;...
-                  lasFile.userData;...
-                  uintID;...
-                  uintGPS;...
-                  uintColor];
+                       uintInt;...
+                       ptInfo;...
+                       ptClass;...
+                       uintSA;...
+                       lasFile.userData;...
+                       uintID;...
+                       uintGPS;...
+                       uintColor];
          end
          
Index: Damkjer/Util/FileIO/LasFile/LasPublicHeader.m
===================================================================
--- Damkjer/Util/FileIO/LasFile/LasPublicHeader.m	(revision 6)
+++ Damkjer/Util/FileIO/LasFile/LasPublicHeader.m	(revision 7)
@@ -54,8 +54,11 @@
 %                                            to a given location.
 %
-% Other m-files required:
+% Toolbox requirements:
 %    None.
 %
-% MAT-files required:
+% Script requirements:
+%    None.
+%
+% Data requirements:
 %    None.
 %
Index: Damkjer/Util/FileIO/LasFile/LasVlr.m
===================================================================
--- Damkjer/Util/FileIO/LasFile/LasVlr.m	(revision 6)
+++ Damkjer/Util/FileIO/LasFile/LasVlr.m	(revision 7)
@@ -22,8 +22,11 @@
 %             saveTo(location)  - Save LAS VLR to a given location.
 %
-% Other m-files required:
-%    None.
-%
-% MAT-files required:
+% Toolbox requirements:
+%    None.
+%
+% Script requirements:
+%    None.
+%
+% Data requirements:
 %    None.
 %
@@ -146,5 +149,5 @@
                      fread(fid,1,'uint16=>uint16');
                      this(i).userID = ...
-                        sscanf(char(fread(fid,16,'uchar=>uchar')'),'%c');
+                        deblank(sscanf(char(fread(fid,16,'uchar=>uchar')'),'%c'));
                      this(i).recordID = ...
                         fread(fid,1,'uint16=>uint16');
@@ -152,5 +155,5 @@
                         fread(fid,1,'uint16=>uint16');
                      this(i).description = ...
-                        sscanf(char(fread(fid,32,'uchar=>uchar')'),'%c');
+                        deblank(sscanf(char(fread(fid,32,'uchar=>uchar')'),'%c'));
                      this(i).data = fread(fid,...
                         this(i).recordLengthAfterHeader,'uint8=>uint8');
Index: Damkjer/Util/FileIO/LasFile/LasfProjGeoAsciiParamsTagVLR.m
===================================================================
--- Damkjer/Util/FileIO/LasFile/LasfProjGeoAsciiParamsTagVLR.m	(revision 6)
+++ Damkjer/Util/FileIO/LasFile/LasfProjGeoAsciiParamsTagVLR.m	(revision 7)
@@ -25,5 +25,8 @@
 %                                                       location.
 %
-% Other m-files required:
+% Toolbox requirements:
+%    None.
+%
+% Script requirements:
 %    LasVlr.m
 %
Index: Damkjer/Util/FileIO/LasFile/LasfProjGeoDoubleParamsTagVLR.m
===================================================================
--- Damkjer/Util/FileIO/LasFile/LasfProjGeoDoubleParamsTagVLR.m	(revision 6)
+++ Damkjer/Util/FileIO/LasFile/LasfProjGeoDoubleParamsTagVLR.m	(revision 7)
@@ -24,8 +24,11 @@
 %                                                        location.
 %
-% Other m-files required:
+% Toolbox requirements:
+%    None.
+%
+% Script requirements:
 %    LasVlr.m
 %
-% MAT-files required:
+% Data requirements:
 %    None.
 %
Index: Damkjer/Util/FileIO/LasFile/LasfProjGeoKeyDirectoryTagVLR.m
===================================================================
--- Damkjer/Util/FileIO/LasFile/LasfProjGeoKeyDirectoryTagVLR.m	(revision 6)
+++ Damkjer/Util/FileIO/LasFile/LasfProjGeoKeyDirectoryTagVLR.m	(revision 7)
@@ -29,9 +29,12 @@
 %                                                        location.
 %
-% Other m-files required:
+% Toolbox requirements:
+%    None.
+%
+% Script requirements:
 %    LasVlr.m
 %    geoKeyFactory.m
 %
-% MAT-files required:
+% Data requirements:
 %    None.
 %
Index: Damkjer/Util/FileIO/LasFile/LasfSpecClassificationVLR.m
===================================================================
--- Damkjer/Util/FileIO/LasFile/LasfSpecClassificationVLR.m	(revision 6)
+++ Damkjer/Util/FileIO/LasFile/LasfSpecClassificationVLR.m	(revision 7)
@@ -24,8 +24,11 @@
 %                                                    location.
 %
-% Other m-files required:
+% Toolbox requirements:
+%    None.
+%
+% Script requirements:
 %    LasVlr.m
 %
-% MAT-files required:
+% Data requirements:
 %    None.
 %
Index: Damkjer/Util/FileIO/LasFile/lasVlrFactory.m
===================================================================
--- Damkjer/Util/FileIO/LasFile/lasVlrFactory.m	(revision 6)
+++ Damkjer/Util/FileIO/LasFile/lasVlrFactory.m	(revision 7)
@@ -20,10 +20,13 @@
 %    vlr  - A specialized LAS VLR object
 %
-% Other m-files required:
+% Toolbox requirements:
+%    None.
+%
+% Script requirements:
 %    LasVlr.m
 %    lasfProjVlrFactory.m
 %    lasfSpecVlrFactory.m
 %
-% MAT-files required:
+% Data requirements:
 %    None.
 %
@@ -48,4 +51,5 @@
 
 function [vlr] = lasVlrFactory(vlrHeader)
+
 switch vlrHeader.userID
    case 'LASF_Projection'
Index: Damkjer/Util/FileIO/LasFile/lasfProjVlrFactory.m
===================================================================
--- Damkjer/Util/FileIO/LasFile/lasfProjVlrFactory.m	(revision 6)
+++ Damkjer/Util/FileIO/LasFile/lasfProjVlrFactory.m	(revision 7)
@@ -21,5 +21,8 @@
 %    vlr  - A specialized LAS File VLR Projection object
 %
-% Other m-files required:
+% Toolbox requirements:
+%    None.
+%
+% Script requirements:
 %    LasVlr.m
 %    LasfProjGeoKeyDirectoryTagVLR.m
@@ -27,5 +30,5 @@
 %    LasfProjGeoAsciiParamsTagVLR.m
 %
-% MAT-files required:
+% Data requirements:
 %    None.
 %
Index: Damkjer/Util/FileIO/LasFile/lasfSpecVlrFactory.m
===================================================================
--- Damkjer/Util/FileIO/LasFile/lasfSpecVlrFactory.m	(revision 6)
+++ Damkjer/Util/FileIO/LasFile/lasfSpecVlrFactory.m	(revision 7)
@@ -21,9 +21,12 @@
 %    vlr  - A specialized LAS File VLR Specification object
 %
-% Other m-files required:
+% Toolbox requirements:
+%    None.
+%
+% Script requirements:
 %    LasVlr.m
 %    LasfSpecClassification.m
 %
-% MAT-files required:
+% Data requirements:
 %    None.
 %
Index: Damkjer/Util/MATLAB/ClassHandle.cpp
===================================================================
--- Damkjer/Util/MATLAB/ClassHandle.cpp	(revision 6)
+++ Damkjer/Util/MATLAB/ClassHandle.cpp	(revision 7)
@@ -1,3 +1,3 @@
-//*************************************************************************
+//*****************************************************************************
 // FILE:        ClassHandle.cpp
 //
@@ -22,5 +22,5 @@
 //               Initial Coding.
 //<
-//*************************************************************************
+//*****************************************************************************
 
 #include "ClassHandle.h"
@@ -28,11 +28,12 @@
 #include <typeinfo>
 
-#include "mex.h"
+namespace Damkjer
+{
 
 #define CLASS_HANDLE_SIGNATURE 0xfacade01
 
-//*************************************************************************
+//*****************************************************************************
 // ClassHandle::ClassHandle
-//*************************************************************************
+//*****************************************************************************
 template<typename BASE>
 inline ClassHandle<BASE>::ClassHandle(BASE* pointer)
@@ -41,9 +42,10 @@
    , theSignature(CLASS_HANDLE_SIGNATURE)
 {
+   mexLock();
 }
 
-//*************************************************************************
+//*****************************************************************************
 // ClassHandle::~ClassHandle
-//*************************************************************************
+//*****************************************************************************
 template<typename BASE>
 inline ClassHandle<BASE>::~ClassHandle()
@@ -52,9 +54,11 @@
    thePointer = 0;
    theSignature = 0;
+
+   mexUnlock();
 }
 
-//*************************************************************************
+//*****************************************************************************
 // ClassHandle::isValid
-//*************************************************************************
+//*****************************************************************************
 template<typename BASE>
 inline bool ClassHandle<BASE>::isValid() const
@@ -63,2 +67,4 @@
            theName == typeid(BASE).name());
 }
+
+}
Index: Damkjer/Util/MATLAB/ClassHandle.h
===================================================================
--- Damkjer/Util/MATLAB/ClassHandle.h	(revision 6)
+++ Damkjer/Util/MATLAB/ClassHandle.h	(revision 7)
@@ -1,3 +1,3 @@
-//*************************************************************************
+//*****************************************************************************
 // FILE:        ClassHandle.h
 //
@@ -21,6 +21,8 @@
 //> 2012-OCT-08  K. Damkjer
 //               Initial Coding.
+//> 2013-JUN-24  K. Damkjer
+//               Clarified Error ID.
 //<
-//*************************************************************************
+//*****************************************************************************
 #ifndef ClassHandle_HEADER
 #define ClassHandle_HEADER
@@ -36,13 +38,27 @@
 #include <string>
 
-#ifdef _CHAR16T
-#define CHAR16_T
+// Fix "wide char" definition for older versions of MATLAB. This must be placed
+// after other includes and before the mex.h include.
+#if MATLAB_MAJOR <= 7 && MATLAB_MINOR <= 10 && defined(_CHAR16T)
+   #define CHAR16_T
 #endif
 
 #include "mex.h"
 
+namespace Damkjer
+{
+//*****************************************************************************
+// FUNCTION: ptrAsMat
+//*****************************************************************************
 template<typename BASE>
 mxArray* ptrAsMat(BASE*);
+//> This function reinterprets the pointer to the base object as a MEX index
+//  and encapsulates the result in a MATLAB matrix object to persist between
+//  MEX function calls.
+//<
 
+//*****************************************************************************
+// CLASS: ClassHandle
+//*****************************************************************************
 template<typename BASE>
 class ClassHandle
@@ -50,16 +66,29 @@
 public:
    ~ClassHandle();
-
+   //> The destructor. This method is also responsible for invoking mexUnock to
+   //  allow calling MEX files to be cleared after memory management tasks have
+   //  completed.
+   //<
+   
    const BASE& obj() const { return *thePointer; }
+   //> This method returns the object encapsulated by the ClassWrapper.
+   //<
    
    bool isValid() const;
+   //> This method returns true if and only if the ClassHandle object passes
+   //  validity checks. This method prevents the arbitrary reinterpretation of
+   //  non-ClassWrapper objects.
+   //<
 
    friend mxArray* ptrAsMat<BASE>(BASE*);
 
 private:
-   // We want to force objects to be created using the ptrAsMat named
-   // constructor idiom. This also forces ClassHandles to be allocated on
-   // the heap instead of on the stack.
    ClassHandle(BASE*);
+   //> We want to force objects to be created using the ptrAsMat named
+   //  constructor idiom. This also forces ClassHandles to be allocated on
+   //  the heap instead of on the stack. This method is responsible for 
+   //  invoking mexLock to prevent MATLAB from arbitrarily clearing memory 
+   //  managed by the wrapper.
+   //<
 
    // Explicitly disable "default" constructors.
@@ -69,11 +98,19 @@
 
    BASE* thePointer;
+   //> The pointer to the encapsulated object.
+   //<
+   
    std::string theName;
+   //> The type ID of the base type. Used for validation.
+   //<
+   
    uint32_T theSignature;
+   //> The file signature. Used for validation.
+   //<
 };
 
-//*************************************************************************
-// Function: ptrAsMat
-//*************************************************************************
+//*****************************************************************************
+// FUNCTION: ptrAsMat
+//*****************************************************************************
 template<typename BASE>
 mxArray* ptrAsMat(BASE* ptr)
@@ -85,7 +122,7 @@
 }
 
-//*************************************************************************
+//*****************************************************************************
 // FUNCTION: matAsObj
-//*************************************************************************
+//*****************************************************************************
 template<typename BASE>
 const BASE& matAsObj(const mxArray* mat)
@@ -95,5 +132,5 @@
        mxIsComplex(mat))
    {
-      mexErrMsgIdAndTxt("Damkjer:matAsPtr:invalidHandle",
+      mexErrMsgIdAndTxt("Damkjer:matAsObj:invalidHandle",
                         "Input must be real-valued index-class scalar.");
    }
@@ -104,5 +141,5 @@
    if (!(handle->isValid()))
    {
-      mexErrMsgIdAndTxt("Damkjer:matAsPtr:invalidHandle",
+      mexErrMsgIdAndTxt("Damkjer:matAsObj:invalidHandle",
                         "Handle not valid.");
    }
@@ -111,7 +148,7 @@
 }
 
-//*************************************************************************
+//*****************************************************************************
 // FUNCTION: destroyHandleTo
-//*************************************************************************
+//*****************************************************************************
 template<typename BASE>
 void destroyHandleTo(const mxArray* mat)
@@ -121,5 +158,5 @@
        mxIsComplex(mat))
    {
-      mexErrMsgIdAndTxt("Damkjer:matAsPtr:invalidHandle",
+      mexErrMsgIdAndTxt("Damkjer:destroyHandleTo:invalidHandle",
                         "Input must be real-valued index-class scalar.");
    }
@@ -130,9 +167,10 @@
    if (!(handle->isValid()))
    {
-      mexErrMsgIdAndTxt("Damkjer:matAsPtr:invalidHandle",
+      mexErrMsgIdAndTxt("Damkjer:destroyHandleTo:invalidHandle",
                         "Handle not valid.");
    }
 
-   delete handle;
+   delete handle;   
+}
 }
 
Index: Damkjer/Util/Math/fastcenter.cpp
===================================================================
--- Damkjer/Util/Math/fastcenter.cpp	(revision 3)
+++ Damkjer/Util/Math/fastcenter.cpp	(revision 7)
@@ -21,6 +21,6 @@
 #include <vector>
 
-#ifdef _CHAR16T
-#define CHAR16_T
+#if MATLAB_MAJOR <= 7 && MATLAB_MINOR <= 10 && defined(_CHAR16T)
+   #define CHAR16_T
 #endif
 
Index: Damkjer/Util/Math/fastcoeffvar.cpp
===================================================================
--- Damkjer/Util/Math/fastcoeffvar.cpp	(revision 3)
+++ Damkjer/Util/Math/fastcoeffvar.cpp	(revision 7)
@@ -21,6 +21,6 @@
 #include <vector>
 
-#ifdef _CHAR16T
-#define CHAR16_T
+#if MATLAB_MAJOR <= 7 && MATLAB_MINOR <= 10 && defined(_CHAR16T)
+   #define CHAR16_T
 #endif
 
Index: Damkjer/Util/Math/fastcov.cpp
===================================================================
--- Damkjer/Util/Math/fastcov.cpp	(revision 6)
+++ Damkjer/Util/Math/fastcov.cpp	(revision 7)
@@ -22,6 +22,6 @@
 #include <sstream>
 
-#ifdef _CHAR16T
-#define CHAR16_T
+#if MATLAB_MAJOR <= 7 && MATLAB_MINOR <= 10 && defined(_CHAR16T)
+   #define CHAR16_T
 #endif
 
@@ -124,5 +124,6 @@
       for (mwSize n1 = Ns[cellp]; n1 --> 0;)
       {
-         for (mwSize n2 = Ns[cellp]; n2 --> 0;)
+//         for (mwSize n2 = Ns[cellp]; n2 --> 0;)
+         for (mwSize n2 = Ns[cellp]; n2 --> n1;)
          {
             cov_vals[cellp][n2 + Ns[cellp] * n1] = 0;
@@ -143,4 +144,7 @@
                // End comment.
             }
+
+            cov_vals[cellp][n1 + Ns[cellp] * n2] =
+                                           cov_vals[cellp][n2 + Ns[cellp] * n1];
          }
       }
Index: Damkjer/Util/Math/makeMath.m
===================================================================
--- Damkjer/Util/Math/makeMath.m	(revision 6)
+++ Damkjer/Util/Math/makeMath.m	(revision 7)
@@ -23,4 +23,12 @@
 
 command = 'mex -largeArrayDims -D_USE_MATH_DEFINES';
+
+matlab_ver = regexp(version, '[. ]', 'split');
+command = [command...
+           ' -DMATLAB_MAJOR=' matlab_ver{1}...
+           ' -DMATLAB_MINOR=' matlab_ver{2}...
+           ' -DMATLAB_REVIS=' matlab_ver{3}...
+           ' -DMATLAB_BUILD=' matlab_ver{4}...
+           ' -DMATLAB_REL=' matlab_ver{5}(2:end-1)];
 
 flags = {'verbose', 'debug', 'warnings', 'parallel'};
@@ -75,8 +83,11 @@
 
 [path,~,~]=fileparts(mfilename('fullpath'));
-command = [command options ' -I' path '/../../.. -outdir ' path ' ' path '/'];
+command = [command options ' -I' fullfile(path,'..','..','..')...
+           ' -I' fullfile(path,'..','..','includes','eigen')...
+           ' -outdir ' path ' ' path '/'];
 
 eval([command 'fastcov.cpp']);
 eval([command 'fastcenter.cpp']);
+eval([command 'par_eig.cpp']);
 
 end
Index: Damkjer/Util/SpatialIndexing/Metrics/Metrics.h
===================================================================
--- Damkjer/Util/SpatialIndexing/Metrics/Metrics.h	(revision 0)
+++ Damkjer/Util/SpatialIndexing/Metrics/Metrics.h	(revision 7)
@@ -1,3 +1,3 @@
-//*************************************************************************
+//*****************************************************************************
 // FILE:        Metrics.h
 //
@@ -12,5 +12,5 @@
 //               Initial Coding.
 //<
-//*************************************************************************
+//*****************************************************************************
 
 #ifndef Metrics_HEADER
@@ -19,15 +19,21 @@
 #include <cmath>
 
+namespace Damkjer
+{
+
+//*****************************************************************************
+// FUNCTION: euclidean
+//*****************************************************************************
 template<typename CONTAINER>
 double euclidean(const CONTAINER& a,
                  const CONTAINER& b)
 {
-    double sum=0;
+    double sum = 0;
     
-    for (typename CONTAINER::const_iterator ai=a.begin(), bi=b.begin();
-         ai!=a.end()&&bi!=b.end();
-         ++ai,++bi)
+    for (typename CONTAINER::const_iterator ai = a.begin(), bi = b.begin();
+         ai != a.end() && bi != b.end();
+         ++ai, ++bi)
     {
-        sum+=(*ai-*bi)*(*ai-*bi);
+        sum += (*ai - *bi) * (*ai - *bi);
     }
     
@@ -35,3 +41,63 @@
 }
 
+//*****************************************************************************
+// FUNCTION: manhattan
+//*****************************************************************************
+template<typename CONTAINER>
+double manhattan(const CONTAINER& a,
+                 const CONTAINER& b)
+{
+    double sum = 0;
+    
+    for (typename CONTAINER::const_iterator ai = a.begin(), bi = b.begin();
+         ai != a.end() && bi != b.end();
+         ++ai, ++bi)
+    {
+        sum += fabs(*ai - *bi);
+    }
+    
+    return sum;
+}
+
+//*****************************************************************************
+// FUNCTION: maximum
+//*****************************************************************************
+template<typename CONTAINER>
+double maximum(const CONTAINER& a,
+               const CONTAINER& b)
+{
+    double my_max = 0;
+    
+    for (typename CONTAINER::const_iterator ai = a.begin(), bi = b.begin();
+         ai != a.end() && bi != b.end();
+         ++ai, ++bi)
+    {
+       double temp = fabs(*ai - *bi)
+       my_max = (temp > my_max) ? temp : my_max;
+    }
+    
+    return my_max;
+}
+
+//*****************************************************************************
+// FUNCTION: pNorm
+//*****************************************************************************
+// template<typename CONTAINER>
+// double pNorm(const CONTAINER& a,
+//              const CONTAINER& b)
+// {
+//    double sum = 0;
+//    
+//    for (typename CONTAINER::const_iterator ai = a.begin(), bi = b.begin();
+//         ai != a.end() && bi != b.end();
+//         ++ai, ++bi)
+//    {
+//       sum += pow((*ai - *bi), theP);
+//    }
+//    
+//    return pow(sum, 1./theP);
+// }
+
+}
+
 #endif
Index: Damkjer/Util/SpatialIndexing/VpTree/VpTree.cpp
===================================================================
--- Damkjer/Util/SpatialIndexing/VpTree/VpTree.cpp	(revision 0)
+++ Damkjer/Util/SpatialIndexing/VpTree/VpTree.cpp	(revision 7)
@@ -1,3 +1,3 @@
-//*************************************************************************
+//*****************************************************************************
 // FILE:        VpTree.cpp
 //
@@ -15,5 +15,5 @@
 //               Initial Coding.
 //<
-//*************************************************************************
+//*****************************************************************************
 
 #ifdef _OPENMP
@@ -26,7 +26,10 @@
 #include <iostream>
 
-//*************************************************************************
+namespace Damkjer
+{
+
+//*****************************************************************************
 // CLASS: VpTree::Node
-//*************************************************************************
+//*****************************************************************************
 template<typename T,
          double (*DISTANCE)(const T&, const T&)>
@@ -67,7 +70,7 @@
 };
 
-//*************************************************************************
+//*****************************************************************************
 // CLASS: VpTree::Internal
-//*************************************************************************
+//*****************************************************************************
 template<typename T,
          double (*DISTANCE)(const T&, const T&)>
@@ -133,7 +136,7 @@
 };
 
-//*************************************************************************
+//*****************************************************************************
 // CLASS: VpTree::Leaf
-//*************************************************************************
+//*****************************************************************************
 template<typename T,
          double (*DISTANCE)(const T&, const T&)>
@@ -179,7 +182,7 @@
 };
 
-//*************************************************************************
+//*****************************************************************************
 // CLASS: VpTree::Item
-//*************************************************************************
+//*****************************************************************************
 template<typename T,
          double (*DISTANCE)(const T&, const T&)>
@@ -213,7 +216,7 @@
 };
 
-//*************************************************************************
-// CLASS: VpTree::ResultsCandidate
-//*************************************************************************
+//*****************************************************************************
+// VpTree::ResultsCandidate
+//*****************************************************************************
 template<typename T,
          double (*DISTANCE)(const T&, const T&)>
@@ -244,7 +247,7 @@
 };
 
-//*************************************************************************
+//*****************************************************************************
 // VpTree::VpTree
-//*************************************************************************
+//*****************************************************************************
 template<typename T,
          double (*DISTANCE)(const T&, const T&)>
@@ -256,12 +259,12 @@
 }
 
-//*************************************************************************
+//*****************************************************************************
 // VpTree::VpTree
-//*************************************************************************
+//*****************************************************************************
 template<typename T,
          double (*DISTANCE)(const T&, const T&)>
 template<typename CONTAINER>
 inline VpTree<T, DISTANCE>::VpTree(const CONTAINER& elems,
-                                       const std::size_t& leafCapacity)
+                                   const std::size_t& leafCapacity)
    : theRoot(0)
    , theItems(elems.size())
@@ -283,7 +286,7 @@
 }
                 
-//*************************************************************************
+//*****************************************************************************
 // VpTree::~VpTree
-//*************************************************************************
+//*****************************************************************************
 template<typename T,
          double (*DISTANCE)(const T&, const T&)>
@@ -294,7 +297,7 @@
 }
 
-//*************************************************************************
+//*****************************************************************************
 // VpTree::Node::Node
-//*************************************************************************
+//*****************************************************************************
 template<typename T,
          double (*DISTANCE)(const T&, const T&)>
@@ -304,7 +307,7 @@
 }
 
-//*************************************************************************
+//*****************************************************************************
 // VpTree::Node::Node
-//*************************************************************************
+//*****************************************************************************
 template<typename T,
          double (*DISTANCE)(const T&, const T&)>
@@ -314,7 +317,7 @@
 }
 
-//*************************************************************************
+//*****************************************************************************
 // VpTree::Node::~Node
-//*************************************************************************
+//*****************************************************************************
 template<typename T,
          double (*DISTANCE)(const T&, const T&)>
@@ -324,7 +327,7 @@
 }
 
-//*************************************************************************
+//*****************************************************************************
 // VpTree::Internal::Internal
-//*************************************************************************
+//*****************************************************************************
 template<typename T,
          double (*DISTANCE)(const T&, const T&)>
@@ -341,7 +344,7 @@
 }
 
-//*************************************************************************
+//*****************************************************************************
 // VpTree::Internal::Internal
-//*************************************************************************
+//*****************************************************************************
 template<typename T,
          double (*DISTANCE)(const T&, const T&)>
@@ -358,7 +361,7 @@
 }
 
-//*************************************************************************
+//*****************************************************************************
 // VpTree::Internal::~Internal
-//*************************************************************************
+//*****************************************************************************
 template<typename T,
          double (*DISTANCE)(const T&, const T&)>
@@ -371,7 +374,7 @@
 }
 
-//*************************************************************************
+//*****************************************************************************
 // VpTree::Leaf::Leaf
-//*************************************************************************
+//*****************************************************************************
 template<typename T,
          double (*DISTANCE)(const T&, const T&)>
@@ -383,7 +386,7 @@
 }
 
-//*************************************************************************
+//*****************************************************************************
 // VpTree::Leaf::Leaf
-//*************************************************************************
+//*****************************************************************************
 template<typename T,
          double (*DISTANCE)(const T&, const T&)>
@@ -397,7 +400,7 @@
 }
 
-//*************************************************************************
+//*****************************************************************************
 // VpTree::Item::Item
-//*************************************************************************
+//*****************************************************************************
 template<typename T,
          double (*DISTANCE)(const T&, const T&)>
@@ -409,7 +412,7 @@
 }
 
-//*************************************************************************
+//*****************************************************************************
 // VpTree::Item::operator<
-//*************************************************************************
+//*****************************************************************************
 template<typename T,
          double (*DISTANCE)(const T&, const T&)>
@@ -419,7 +422,7 @@
 }
 
-//*************************************************************************
+//*****************************************************************************
 // VpTree::ResultsCandidate::ResultsCandidate
-//*************************************************************************
+//*****************************************************************************
 template<typename T,
          double (*DISTANCE)(const T&, const T&)>
@@ -432,7 +435,7 @@
 }
 
-//*************************************************************************
+//*****************************************************************************
 // VpTree::ResultsCandidate::operator<
-//*************************************************************************
+//*****************************************************************************
 template<typename T,
          double (*DISTANCE)(const T&, const T&)>
@@ -443,7 +446,7 @@
 }
 
-//*************************************************************************
+//*****************************************************************************
 // VpTree::randomSample
-//*************************************************************************
+//*****************************************************************************
 template<typename T,
          double (*DISTANCE)(const T&, const T&)>
@@ -505,7 +508,7 @@
 }
                                 
-//*************************************************************************
+//*****************************************************************************
 // VpTree::selectVp
-//*************************************************************************
+//*****************************************************************************
 template<typename T,
          double (*DISTANCE)(const T&, const T&)>
@@ -578,7 +581,7 @@
 }
 
-//*************************************************************************
+//*****************************************************************************
 // VpTree::makeTree
-//*************************************************************************
+//*****************************************************************************
 template<typename T,
          double (*DISTANCE)(const T&, const T&)>
@@ -677,7 +680,7 @@
 }
 
-//*************************************************************************
+//*****************************************************************************
 // VpTree::knn
-//*************************************************************************
+//*****************************************************************************
 template<typename T,
          double (*DISTANCE)(const T&, const T&)>
@@ -708,7 +711,7 @@
 }
 
-//*************************************************************************
+//*****************************************************************************
 // VpTree::Internal::knn
-//*************************************************************************
+//*****************************************************************************
 template<typename T,
          double (*DISTANCE)(const T&, const T&)>
@@ -786,7 +789,7 @@
 }
 
-//*************************************************************************
+//*****************************************************************************
 // VpTree::Leaf::knn
-//*************************************************************************
+//*****************************************************************************
 template<typename T,
          double (*DISTANCE)(const T&, const T&)>
@@ -824,7 +827,7 @@
 }
 
-//*************************************************************************
+//*****************************************************************************
 // VpTree::rnn
-//*************************************************************************
+//*****************************************************************************
 template<typename T,
          double (*DISTANCE)(const T&, const T&)>
@@ -853,7 +856,7 @@
 }
 
-//*************************************************************************
+//*****************************************************************************
 // VpTree::Internal::rnn
-//*************************************************************************
+//*****************************************************************************
 template<typename T,
          double (*DISTANCE)(const T&, const T&)>
@@ -915,7 +918,7 @@
 }
 
-//*************************************************************************
+//*****************************************************************************
 // Leaf::rnn
-//*************************************************************************
+//*****************************************************************************
 template<typename T,
          double (*DISTANCE)(const T&, const T&)>
@@ -940,2 +943,4 @@
    }
 }
+
+}
Index: Damkjer/Util/SpatialIndexing/VpTree/VpTree.h
===================================================================
--- Damkjer/Util/SpatialIndexing/VpTree/VpTree.h	(revision 0)
+++ Damkjer/Util/SpatialIndexing/VpTree/VpTree.h	(revision 7)
@@ -1,3 +1,3 @@
-//*************************************************************************
+//*****************************************************************************
 // FILE:        VpTree.h
 //
@@ -48,5 +48,5 @@
 //               Initial Coding.
 //<
-//*************************************************************************
+//*****************************************************************************
 
 #ifndef VpTree_HEADER
@@ -69,7 +69,10 @@
 #include <limits>
 
-//*************************************************************************
+namespace Damkjer
+{
+
+//*****************************************************************************
 // CLASS: VpTree
-//*************************************************************************
+//*****************************************************************************
 EXPORT template<typename T = std::vector<double>,
          double (*DISTANCE)(const T&, const T&) = euclidean<T> >
@@ -89,5 +92,5 @@
       //> Free resources allocated by this tree.
       //<
-    
+   
    std::pair<std::deque<std::size_t>, std::deque<double> > knn(
            const T&,
@@ -97,5 +100,5 @@
       //  indices of and distances to the k nearest neighbors.
       //<
-    
+   
    std::pair<std::deque<std::size_t>, std::deque<double> > rnn(
            const T&,
@@ -172,4 +175,6 @@
 };
 
+}
+
 #if defined(MAKE_DEPENDING) || defined(TEMPLATE_INCLUSION)
 #include "VpTree.cpp"
Index: Damkjer/Util/SpatialIndexing/VpTree/VpTree.m
===================================================================
--- Damkjer/Util/SpatialIndexing/VpTree/VpTree.m	(revision 0)
+++ Damkjer/Util/SpatialIndexing/VpTree/VpTree.m	(revision 7)
@@ -1,7 +1,39 @@
-% File:  VpTree.m
+% VpTree   Vantage Point Tree spatial indexing data structure
 %
-% Description: This MATLAB class represents a simple vantage-point tree.
+% File:
+%    VpTree.m
 %
-% Limitations: See VpTree.h for complete description of limitations.
+% Description:
+%    This MATLAB class represents a simple vantage-point tree.
+%
+% Limitations:
+%    See VpTree.h for complete description of limitations.
+%
+% Properties:
+%    theTree  - Brief description
+%
+% Methods:
+%        [tree] = VpTree(varargin)                 - Brief description
+%                 delete(tree)                     - Brief description
+%    [idx,dist] = knn(this, queries, k, varargin)  - Brief description
+%    [idx,dist] = rnn(this, data, radius)          - Brief description
+%
+% Toolbox requirements:
+%    None.
+%
+% Script requirements:
+%    None.
+%
+% Data requirements:
+%    None.
+%
+% References:
+%    None.
+%
+% See Also:
+%    None.
+%
+
+% Copyright (C)  2012 Kristian L. Damkjer.
 %
 % Software History:
@@ -11,95 +43,92 @@
 
 classdef (Sealed = true) VpTree < handle
-    
-    properties (Hidden=true, Access = private)
-        theTree
-    end
-    
-    methods
-        function this = VpTree(varargin)
-            % This function builds the index structure for the database.
+   
+   properties (Hidden=true, Access = private)
+      theTree
+      theCleanUpObj
+   end
+   
+   methods
+      function this = VpTree(varargin)
+         % This function builds the index structure for the database.
+         
+         if (nargin ~= 1)
+            error('VpTree:InvalidArgumentList',...
+                  'VpTree must be constructed with a set of observations');
+         end
+         
+         this.theTree = VpTreeAPI('create', varargin{1});
+      end
+
+      function delete(this)
+         % This function frees memory on delete (clear) of the VpTree.
+         VpTreeAPI('destroy', this.theTree);
+      end
+      
+      function [idx,dist] = knn(this, queries, k, varargin)
+         % Perform a k-nearest neighbor search on the database with the
+         % set of queries.
+         
+         userParams = struct('limit', realmax);
+         
+         % Parse the Property/Value pairs
+         if rem(length(varargin), 2) ~= 0
+            error('Damkjer:PropertyValueNotPair', ...
+                  ['Additional arguments must take the form of'...
+                   'Property/Value pairs']);
+         end
+         
+         propertyNames = {'limit'};
+         
+         while ~isempty(varargin)
+            property = varargin{1};
+            value    = varargin{2};
             
-            if (nargin ~= 1)
-                error('VpTree:InvalidArgumentList',...
-                  'VpTree must be constructed with a set of observations');
-            end
-
-            this.theTree=newVpTree(varargin{1});
-        end
-
-        function delete(this)
-            % This function frees memory on delete (clear) of the VpTree.            
-            deleteVpTree(this.theTree);
-        end
-
-        function [idx,dist]=knn(this, queries, k, varargin)
-            % Perform a k-nearest neighbor search on the database with the 
-            % set of queries.
+            % If the property has been supplied in a shortened form,
+            % lengthen it
+            iProperty = find(strncmpi(property, propertyNames, ...
+                                      length(property)));
             
-            userParams = struct('limit', realmax);
-            
-            % Parse the Property/Value pairs
-            if rem(length(varargin), 2) ~= 0
-                error('Damkjer:PropertyValueNotPair', ...
-                    ['Additional arguments must take the form of'...
-                     'Property/Value pairs']);
+            if isempty(iProperty)
+               error('Damkjer:InvalidProperty', 'Invalid Property');
+            elseif length(iProperty) > 1
+               error('Damkjer:AmbiguousProperty', ...
+                     'Supplied shortened property name is ambiguous');
             end
             
-            propertyNames = {'limit'};
+            property = propertyNames{iProperty};
             
-            while ~isempty(varargin)
-                property = varargin{1};
-                value    = varargin{2};
-                
-                % If the property has been supplied in a shortened form,
-                % lengthen it
-                iProperty = find(strncmpi(property, propertyNames, length(property)));
-                
-                if isempty(iProperty)
-                    error('Damkjer:InvalidProperty', 'Invalid Property');
-                elseif length(iProperty) > 1
-                    error('Damkjer:AmbiguousProperty', ...
-                          'Supplied shortened property name is ambiguous');
-                end
-                
-                property = propertyNames{iProperty};
-                
-                switch property
-                    case 'limit'
-                        if (isscalar(value) && ...
-                                isnumeric(value) && ...
-                                isreal(value) && ...
-                                value > 0)
-                            userParams.limit = value;
-                        else
-                            error('Damkjer:InvalidLimit', ...
-                                ['Limit must be a real valued '...
-                                 'positive scalar']);
-                        end
-                end
-                
-                varargin(1:2) = [];
+            switch property
+               case 'limit'
+                  if (isscalar(value) && isnumeric(value) && ...
+                      isreal(value) && value > 0)
+                     userParams.limit = value;
+                  else
+                     error('Damkjer:InvalidLimit', ...
+                           'Limit must be a real valued positive scalar');
+                  end
             end
-
-            if (nargout == 1)
-                idx=kannVpTree(this.theTree, queries, k,...
-                                 userParams.limit);
-            else
-                [idx,dist]=kannVpTree(this.theTree, queries, k,...
-                    userParams.limit);
-            end
-        end
-
-        function [idx,dist]=rnn(this, data, radius)
-            % Perform a fixed-radius nearest neighbor search on the
-            % database with the set of queries.
             
-            if (nargout == 1)
-                idx=frannVpTree(this.theTree, data, radius);
-            else
-                [idx,dist]=frannVpTree(this.theTree, data, radius);
-            end
-        end
-    end    
+            varargin(1:2) = [];
+         end
+         
+         if (nargout == 1)
+             idx = VpTreeAPI('search_kann', this.theTree, queries, k, userParams.limit);
+         else
+             [idx,dist] = VpTreeAPI('search_kann', this.theTree, queries, k, userParams.limit);
+         end
+      end
+      
+      function [idx,dist] = rnn(this, queries, radius)
+         % Perform a fixed-radius nearest neighbor search on the
+         % database with the set of queries.
+         
+         if (nargout == 1)
+             idx = VpTreeAPI('search_frann', this.theTree, queries, radius);
+         else
+             [idx,dist] = VpTreeAPI('search_frann', this.theTree, queries, radius);
+         end
+      end
+   end
 end
 
Index: Damkjer/Util/SpatialIndexing/VpTree/makeVpTree.m
===================================================================
--- Damkjer/Util/SpatialIndexing/VpTree/makeVpTree.m	(revision 6)
+++ Damkjer/Util/SpatialIndexing/VpTree/makeVpTree.m	(revision 7)
@@ -1,26 +1,64 @@
-%%
-% MAKEVPTREE(...)
+% makeVpTree   Build VpTree spatial indexing library MEX functions and classes.
 %
-% Build VpTree spatial indexing library MEX functions and classes.
+% File:
+%    makeVpTree.m
 %
-% OPTIONS:
+% Description:
+%    This MATLAB function provides an simplified interface for building the
+%    VpTree C++ and MEX files.
 %
-%   Variable options may be provided as shortcuts as long as they resolve
-%   to a unique option.
+% Limitations:
+%    Assumes mex -setup has been successfully run.
 %
-%   Make options are as follows:
+% Synopsis:
+%    makeVpTree(options...)
 %
-%   'debug'   : Compile with debug flags and fully populated symbol table.
+% Inputs:
+%   Option strings may be provided as abbreviations as long as they resolve to
+%   a unique option.
 %
-%   'parallel': Enable OpenMP pragmas for multi-threaded computing.
+%   'debug'     - Compile with debug flags and fully populated symbol table.
+%   'parallel'  - Enable OpenMP pragmas for multi-threaded computing.
+%   'verbose'   - Provide verbose output while compiling.
+%   'warnings'  - Provide compiler warning output for production-ready code.
+%                 Implies 'verbose'.
 %
-%   'verbose' : Provide verbose output while compiling.
+% Outputs:
+%    None.
 %
-%   'warnings': Provide compiler warning output for production-ready code.
-%               Implies 'verbose'.
+% Toolbox requirements:
+%    None.
 %
+% Script requirements:
+%    None.
+%
+% Data requirements:
+%    None.
+%
+% References:
+%    None.
+%
+% See Also:
+%    VpTree
+%
+
+% Software History:
+%    2012-AUG-29   K. Damkjer
+%       Initial Coding.
+%    2013-JUN-17   K. Damkjer
+%       Additional Commenting.
+%
+
 function makeVpTree(varargin)
 
 command = 'mex -largeArrayDims -DTEMPLATE_INCLUSION';
+
+matlab_ver = regexp(version, '[. ]', 'split');
+command = [command...
+           ' -DMATLAB_MAJOR=' matlab_ver{1}...
+           ' -DMATLAB_MINOR=' matlab_ver{2}...
+           ' -DMATLAB_REVIS=' matlab_ver{3}...
+           ' -DMATLAB_BUILD=' matlab_ver{4}...
+           ' -DMATLAB_REL=' matlab_ver{5}(2:end-1)];
 
 flags = {'verbose', 'debug', 'warnings', 'parallel'};
@@ -29,15 +67,16 @@
 while ~isempty(varargin)
    flag = varargin{1};
+
    % If the property has been supplied in a shortened form, lengthen it
    iFlag = find(strncmpi(flag, flags, length(flag)));
    
    if isempty(iFlag)
+      % Pass through any arguments we don't recognize
       options = strcat(options, ' ', flag);
       
-      % Pass through any arguments we don't recognize, alternatively escalate
-      % to an error.
-%       error('Damkjer:makeVpsTree:InvalidFlag', ['Invalid Flag: ' flag]);
+      % Alternatively, escalate to an error.
+      %error('Damkjer:makeVpTree:InvalidFlag', ['Invalid Flag: ' flag]);
    elseif length(iFlag) > 1
-      error('Damkjer:makeVpsTree:AmbiguousFlag', ...
+      error('Damkjer:makeVpTree:AmbiguousFlag', ...
             ['Supplied shortened flag is ambiguous: ' flag]);
    else
@@ -45,40 +84,38 @@
       
       switch flag
-         case 'verbose'
-            command = strcat(command, ' -v');
-         case 'debug'
-            command = strcat(command, ' -g');
-         case 'parallel'
-            if (ispc)
-               command = strcat(command, ' COMPFLAGS="$COMPFLAGS /openmp"');
-            else
-               command = strcat(command, ' CFLAGS="\$CFLAGS -fopenmp"',...
-                                         ' CXXFLAGS="\$CXXFLAGS -fopenmp"',...
-                                         ' LDFLAGS="\$LDFLAGS -fopenmp"');
-            end
-         case 'warnings'
-            if (ispc)
-               command = strcat(command, ' -v COMPFLAGS="$COMPFLAGS -W3"');
-            else
-               command = strcat(command, ' -v',...
-                                         ' CFLAGS="\$CFLAGS -Wall -Wextra"',...
-                                         ' CXXFLAGS="\$CXXFLAGS -Wall -Wextra"');
-            end
-         otherwise
-            error('Damkjer:makeVpsTree:NotImplementedFlag', ...
-                  ['Flag recognized, but not supported (oops): ' flag]);
-      end % switch property
+      case 'verbose'
+         command = strcat(command, ' -v');
+      case 'debug'
+         command = strcat(command, ' -g');
+      case 'parallel'
+         if (ispc)
+            command = strcat(command, ' COMPFLAGS="$COMPFLAGS /openmp"');
+         else
+            command = strcat(command, ' CFLAGS="\$CFLAGS -fopenmp"',...
+                                      ' CXXFLAGS="\$CXXFLAGS -fopenmp"',...
+                                      ' LDFLAGS="\$LDFLAGS -fopenmp"');
+         end
+      case 'warnings'
+         if (ispc)
+            command = strcat(command, ' -v COMPFLAGS="$COMPFLAGS -W3"');
+         else
+            command = strcat(command, ' -v',...
+                                      ' CFLAGS="\$CFLAGS -Wall -Wextra"',...
+                                      ' CXXFLAGS="\$CXXFLAGS -Wall -Wextra"');
+         end
+      otherwise
+         error('Damkjer:makeVpTree:NotImplementedFlag', ...
+               ['Flag recognized, but not supported: ' flag]);
+      end
    end
    
    varargin(1) = [];
-end % while
+end
 
 [path,~,~]=fileparts(mfilename('fullpath'));
-command = [command options ' -I' path '/../../.. -outdir ' path ' ' path '/'];
+command = [command options ' -I' fullfile(path,'..','..','..')...
+           ' -outdir ' path ' ' path '/'];
 
-eval([command 'newVpTree.cpp']);
-eval([command 'deleteVpTree.cpp']);
-eval([command 'frannVpTree.cpp']);
-eval([command 'kannVpTree.cpp']);
+eval([command 'VpTreeAPI.cpp']);
 
 end
Index: Damkjer/Util/Widgets/timebar.m
===================================================================
--- Damkjer/Util/Widgets/timebar.m	(revision 6)
+++ Damkjer/Util/Widgets/timebar.m	(revision 7)
@@ -57,11 +57,11 @@
 
 % Construct total string
-tmsg=timeString(total);
+tmsg = timeString(total);
 
 % Construct elapsed string
-emsg=timeString(elapsed);
+emsg = timeString(elapsed);
 
 % Construct total string
-rmsg=timeString(remain);
+rmsg = timeString(remain);
 
 % Construct waitbar message
@@ -81,9 +81,9 @@
 function [message] = timeString(seconds)
    if (seconds > 7200)
-      message=[num2str(floor(seconds/3600)) 'h'];
+      message = [num2str(floor(seconds/3600)) 'h'];
    elseif (seconds > 120)
-      message=[num2str(floor(seconds/60)) 'm'];
+      message = [num2str(floor(seconds/60)) 'm'];
    else
-      message=[num2str(seconds) 's'];
+      message = [num2str(seconds) 's'];
    end
 end
