diff -r -u 20110921/ccp4-6.2.0/src/pointless/ChangeLog 20110923/ccp4-6.2.0/src/pointless/ChangeLog
--- 20110921/ccp4-6.2.0/src/pointless/ChangeLog	2011-09-06 17:49:04.000000000 +0100
+++ 20110923/ccp4-6.2.0/src/pointless/ChangeLog	2011-09-20 17:41:24.000000000 +0100
@@ -1,5 +1,11 @@
 Release notes
 
+1.6.5
+ - Fixed a nasty bug in accessing a potentially deleted
+object in probability calculation (thanks to Charles Ballard) which
+crashed in Windows, also some "uninitialised variable" errors
+found by Clemens Vonrhein
+
 1.6.4
  - Reindexing merged files now deals properly with phase and ABCD columns,
 eg for I2<->C2 or P2 21 21 <-> P21 21 2 conversions
diff -r -u 20110921/ccp4-6.2.0/src/pointless/datatypes.cpp 20110923/ccp4-6.2.0/src/pointless/datatypes.cpp
--- 20110921/ccp4-6.2.0/src/pointless/datatypes.cpp	2010-08-25 17:14:06.000000000 +0100
+++ 20110923/ccp4-6.2.0/src/pointless/datatypes.cpp	2011-09-20 17:41:24.000000000 +0100
@@ -12,6 +12,16 @@
   const double SDcorrection::MINSDFRAC = 0.2;     // minimum SDfac
 
   //--------------------------------------------------------------
+  SDcorrection::SDcorrection() : sdfac(1.0), sdadd(0.0) {ResetRange();}
+  // Reset minimum & maximum
+  //--------------------------------------------------------------
+  SDcorrection::SDcorrection(const double& SDfac,
+			     const double& SDb, const double& SDadd,
+			     const bool& fixSDb)
+    : sdfac(SDfac), sdb(SDb), sdadd(SDadd), fixsdb(fixSDb) {ResetRange();}
+  //--------------------------------------------------------------
+  void SDcorrection::ResetRange() {mincorr = +1.0e10; maxcorr = -mincorr;}
+  //--------------------------------------------------------------
   void SDcorrection::Correct(observation& Observation, const float& Iav) const
   // in-place correction, using Iav as intensity
   {
diff -r -u 20110921/ccp4-6.2.0/src/pointless/datatypes.hh 20110923/ccp4-6.2.0/src/pointless/datatypes.hh
--- 20110921/ccp4-6.2.0/src/pointless/datatypes.hh	2010-08-25 17:14:07.000000000 +0100
+++ 20110923/ccp4-6.2.0/src/pointless/datatypes.hh	2011-09-20 17:41:24.000000000 +0100
@@ -12,16 +12,15 @@
   // sd' = SDfac * Sqrt(sd^2 + SdB * I + (SDadd * I)^2)
   {
   public:
-    SDcorrection() : sdfac(1.0), sdadd(0.0) {}
+    SDcorrection();
     SDcorrection(const double& SDfac, const double& SDb, const double& SDadd,
-		 const bool& fixSDb=false)
-      : sdfac(SDfac), sdb(SDb), sdadd(SDadd), fixsdb(fixSDb) {}
+		 const bool& fixSDb=false);
 
     void FixSDb() {fixsdb = true;}
     void UnFixSDb() {fixsdb = false;}
 
     // Reset minimum & maximum
-    void ResetRange() {mincorr = +1.0e10; maxcorr = -mincorr;}
+    void ResetRange();
 
     // Multiply SDfac by update
     void UpdateFactor(const double& update) {sdfac *= update;}
diff -r -u 20110921/ccp4-6.2.0/src/pointless/hkl_controls.cpp 20110923/ccp4-6.2.0/src/pointless/hkl_controls.cpp
--- 20110921/ccp4-6.2.0/src/pointless/hkl_controls.cpp	2011-09-06 17:49:04.000000000 +0100
+++ 20110923/ccp4-6.2.0/src/pointless/hkl_controls.cpp	2011-09-20 17:41:24.000000000 +0100
@@ -37,6 +37,10 @@
     nrej_reso = 0;
     nrej_mflag = 0;
     inputscale = 1.0;
+    // fraction of maximum resolution to use in test for blank batches
+    nullResolutionfraction = -1.0;
+    // Threshold on proportion of negative reflections
+    nullNegativeReject = -1.0;
   }
   //--------------------------------------------------------------
   void file_select::set_reslimits(const ResoRange& resrange)
diff -r -u 20110921/ccp4-6.2.0/src/pointless/hkl_symmetry.cpp 20110923/ccp4-6.2.0/src/pointless/hkl_symmetry.cpp
--- 20110921/ccp4-6.2.0/src/pointless/hkl_symmetry.cpp	2011-09-06 17:49:04.000000000 +0100
+++ 20110923/ccp4-6.2.0/src/pointless/hkl_symmetry.cpp	2011-09-20 17:41:24.000000000 +0100
@@ -74,7 +74,7 @@
 	lattype = HorR;
       }
       if (!scala::AllowedLatticeType(lattype)) {
-	Message::message(Message_fatal("Illegal lattice type "+lattype));
+	Message::message(Message_fatal(clipper::String("Illegal lattice type ")+lattype));
       }
       sname = StringUtil::Trim(sname.substr(1));
       std::string lt = std::string(1,lattype);
@@ -1026,7 +1026,8 @@
       return ((-hkl.h()+hkl.k()+hkl.l())%3 == 0);	  
     } else {
       Message::message
-	(Message_fatal("hkl_symmetry::LatticePresent: unrecognised lattice "+LatType));
+	(Message_fatal(clipper::String("hkl_symmetry::LatticePresent: unrecognised lattice ")
+		       +LatType));
     }
     return false;  // dummy, never gets here
   }
diff -r -u 20110921/ccp4-6.2.0/src/pointless/intensitystatistics.cpp 20110923/ccp4-6.2.0/src/pointless/intensitystatistics.cpp
--- 20110921/ccp4-6.2.0/src/pointless/intensitystatistics.cpp	2011-09-06 17:50:02.000000000 +0100
+++ 20110923/ccp4-6.2.0/src/pointless/intensitystatistics.cpp	2011-09-20 17:41:24.000000000 +0100
@@ -89,8 +89,8 @@
     // Probability
     double mcent = 0.968;
     double macen = 0.736;
-    DM_2sqrt *DMcentric = new DM_2sqrt(macen, mcent);
-    double pcentro = ProbBiassed(TotE2minus1, SD_E2m1, mcent, *DMcentric);
+    DM_2sqrt DMcentric(macen, mcent);
+    double pcentro = ProbBiassed(TotE2minus1, SD_E2m1, mcent, DMcentric);
 
 
     //    double dc = Max(mcent - TotE2minus1, 0.0)/SD_E2m1;
diff -r -u 20110921/ccp4-6.2.0/src/pointless/normalise.cpp 20110923/ccp4-6.2.0/src/pointless/normalise.cpp
--- 20110921/ccp4-6.2.0/src/pointless/normalise.cpp	2011-05-09 10:25:11.000000000 +0100
+++ 20110923/ccp4-6.2.0/src/pointless/normalise.cpp	2011-09-20 17:41:24.000000000 +0100
@@ -46,6 +46,15 @@
     return sum_time/double(N);
   }
   //--------------------------------------------------------------
+  BfactorModel::BfactorModel()
+    : valid(false), lnC0(0.0), B0(0.0), B(0.0),
+      time0(0.0),  dtime(0.0), nparam(3) {}
+  //--------------------------------------------------------------
+    // Constant = true for B constant with time
+  BfactorModel::BfactorModel(const bool& Constant)
+    : valid(false), lnC0(0.0), B0(0.0), B(0.0),
+      time0(0.0),  dtime(0.0) {
+    Setup(Constant);}
   //--------------------------------------------------------------
   void BfactorModel::Setup(const bool& Constant,
 			   const double& Time0) {
@@ -159,7 +168,11 @@
 	  double mnI    = sums_st[ir](is,ib).MeanI();
 	  double mnSSqr = sums_st[ir](is,ib).MeanSSqr();
 	  double mnTime = sums_st[ir](is,ib).MeanTime(); // from start
-	  DTime = Max(DTime, sums_st[ir](is,ib).MaxTime());// maximum time from start of run
+	  //^
+	  //	  std::cout << "Maxtime " << ir <<" "<<is<<" "<<ib
+	  //		    <<" " << sums_st[ir](is,ib).MaxTime() <<"\n";
+	  //^-
+	  DTime = Max(DTime, sums_st[ir](is,ib).MaxTime());// maximum time
 	  if (mnI > 0.001) {
 	    // Measurement vector = (1 s2 [s2*t])
 	    mv = Bfactors[ir].MeasurementVector(mnSSqr, mnTime);
@@ -174,12 +187,12 @@
       } else {
 	Bfactors[ir].Invalid();
       }
-      DTime -= Time0;
+      DTime -= Time0;                // maximum time from start of run
       avgtime[ir] = 0.5*DTime;       // average time for run (relative)
       Bfactors[ir].DTime() = DTime;  // store maximum time for run
       //^
       //      std::cout << "run, time0, dtime " << ir << " "
-      //      		<< Time0 << " " << DTime << "\n";
+      //		<< Time0 << " " << DTime << "\n";
     }   // end loop runs
     // + + + + + + + + + + + + 
 
@@ -526,7 +539,8 @@
 	      sums_st[irun](rbin,ib).add(this_obs.kI(), sSqr, this_obs.time());
 	      numobs++;
 	      //^
-	      //	      std::cout << "sums_st[irun](rbin,ib) " << irun <<" "<< rbin <<" "<< ib <<" "
+	      //	      std::cout << "sums_st[irun](rbin,ib) " << irun <<" "<< rbin <<" "<< ib 
+	      //			<<" time " << this_obs.time() <<" "
 	      //			<< this_obs.kI() <<"\n"; //^-
 	    }
 	  }
diff -r -u 20110921/ccp4-6.2.0/src/pointless/normalise.hh 20110923/ccp4-6.2.0/src/pointless/normalise.hh
--- 20110921/ccp4-6.2.0/src/pointless/normalise.hh	2011-05-09 10:25:12.000000000 +0100
+++ 20110923/ccp4-6.2.0/src/pointless/normalise.hh	2011-09-20 17:41:24.000000000 +0100
@@ -19,13 +19,12 @@
   class BinSums {
   public:
     BinSums(const Rtype& Time0=0.0)
-      : sum_I(0.0), sum_sSqr(0.0), N(0), sum_time(0.0),
-	max_time(0.0)
-    {time0=Time0;}  // construct & zero
+      : sum_I(0.0), sum_sSqr(0.0), N(0), sum_time(0.0)
+    {time0=Time0;max_time=Time0;}  // construct & zero
 
     void clear(const Rtype& Time0=0.0)
     {sum_I=0.0;sum_sSqr=0.0;N=0;sum_time=0.0;
-      time0=Time0;max_time=0.0;}
+      time0=Time0;max_time=Time0;}
 
     // Add in I, s^2, time
     void add(const Rtype& I, const Rtype& sSqr, const Rtype& Time=0.0);
@@ -77,11 +76,9 @@
     //
     // Three parameters: c0 (determinated as ln(c0)); B0; B
   public:
-    BfactorModel()
-      : valid(false), time0(0.0),  dtime(0.0), nparam(3) {}
+    BfactorModel();
     // Constant = true for B constant with time
-    BfactorModel(const bool& Constant) : valid(false), dtime(0.0) {
-      Setup(Constant);}
+    BfactorModel(const bool& Constant);
     
     // Constant = true for B constant with time
     void Setup(const bool& Constant, const double& Time0=0.0);
diff -r -u 20110921/ccp4-6.2.0/src/pointless/pgscore.cpp 20110923/ccp4-6.2.0/src/pointless/pgscore.cpp
--- 20110921/ccp4-6.2.0/src/pointless/pgscore.cpp	2011-09-06 17:50:02.000000000 +0100
+++ 20110923/ccp4-6.2.0/src/pointless/pgscore.cpp	2011-09-20 17:41:24.000000000 +0100
@@ -112,19 +112,23 @@
     if (NAveragedZCCfor == 0 &&  NAveragedZCCagainst == 0) return;
 
     IntgrtProb IP1;
-    if (Close<double>(exponent, 2.0)) {  
-      DM_2sqrt *DM = new DM_2sqrt(0.0,CCTrueScore); // Model for CC- if true, most likely 0.0
+    MeanModelBase* pDM = NULL; // pointer to base function
+
+    if (Close<double>(exponent, 2.0)) {
+      // Model for CC- if true, most likely 0.0
+      pDM = new DM_2sqrt(0.0,CCTrueScore);
+
       //DM_2sqrt DM(0.0,1.0); // Model for CC- if true, most likely 0.0
       //    DM_lin  DM(0.0,CCTrueScore);
       //    DM_cubic  DM(0.0,CCTrueScore);
       //    DM_cubicsu  DM(0.0,CCTrueScore);
       //    DM_1minusmSq  DM(0.0,CCTrueScore);
       //    DM_1minusmCu  DM(0.0,CCTrueScore);
-      IP1.init(*DM);
+      IP1.init(*pDM);
     } else {
-      DM_power *DM = new DM_power(0.0,CCTrueScore);
-      DM->SetPower(exponent);
-      IP1.init(*DM);
+      pDM = new DM_power(0.0,CCTrueScore);
+      pDM->SetPower(exponent);
+      IP1.init(*pDM);
     }
 
     const bool DEBUG = false;
@@ -176,6 +180,8 @@
       }
     }
 
+    if(pDM != NULL) {delete pDM;} // clean up
+
     likelihood = exp(PLfor+PLagainst);
     //^
     if (DEBUG) {
diff -r -u 20110921/ccp4-6.2.0/src/pointless/pointless.cpp 20110923/ccp4-6.2.0/src/pointless/pointless.cpp
--- 20110921/ccp4-6.2.0/src/pointless/pointless.cpp	2011-09-06 17:49:04.000000000 +0100
+++ 20110923/ccp4-6.2.0/src/pointless/pointless.cpp	2011-09-20 17:41:24.000000000 +0100
@@ -2380,7 +2380,7 @@
   CCP4::ccp4fyp(argc, argv);
 
   CCP4::ccp4ProgramName (PROGRAM_NAME.c_str());
-  std::string rcsdate = "$Date: 2011/09/06 16:49:04 $";
+  std::string rcsdate = "$Date: 2011/09/20 16:41:24 $";
   CCP4::ccp4RCSDate     (rcsdate.c_str());
   CCP4::ccp4_prog_vers(PROGRAM_VERSION);
   CCP4::ccp4_banner();
diff -r -u 20110921/ccp4-6.2.0/src/pointless/pointless.html 20110923/ccp4-6.2.0/src/pointless/pointless.html
--- 20110921/ccp4-6.2.0/src/pointless/pointless.html	2011-09-06 17:49:04.000000000 +0100
+++ 20110923/ccp4-6.2.0/src/pointless/pointless.html	2011-09-20 17:41:24.000000000 +0100
@@ -24,6 +24,7 @@
 
 
 
+
   <meta http-equiv="CONTENT-TYPE" content="text/html; charset=utf-8"><title>CCP4 Program Suite: pointless</title>
   
   <meta name="GENERATOR" content="NeoOffice 2.2  (Unix)">
@@ -956,7 +957,12 @@
 <p><br>
 </p>
 <h2><a name="release_notes"></a>Release notes</h2>
+<h3>1.6.5</h3>Fixed a nasty bug in accessing a potentially deleted
+object in probability calculation (thanks to Charles Ballard) which
+crashed in Windows, also some&nbsp; "uninitialised variable" errors
+found by Clemens Vonrhein<br>
 <h3>1.6.4</h3>
+
 Reindexing merged files now deals properly with phase and ABCD columns,
 eg for I2&lt;-&gt;C2 or&nbsp; P2 21 21 &lt;-&gt; P21 21 2 conversions<br>
 Improved/fixed detection of new space group after reindexing<br>
diff -r -u 20110921/ccp4-6.2.0/src/pointless/probfunctions.cpp 20110923/ccp4-6.2.0/src/pointless/probfunctions.cpp
--- 20110921/ccp4-6.2.0/src/pointless/probfunctions.cpp	2011-09-06 17:50:02.000000000 +0100
+++ 20110923/ccp4-6.2.0/src/pointless/probfunctions.cpp	2011-09-20 17:41:24.000000000 +0100
@@ -12,7 +12,6 @@
   // Gaussian probability density function
   // returns p = (1/(sd*sqrt(twopi))) exp (-1/2 z^2)
   //   where z = (val-mean)/sd
-  //
 {
   if (sd <= 0.0)
     clipper::Message::message(clipper::Message_fatal
diff -r -u 20110921/ccp4-6.2.0/src/pointless/probfunctions.hh 20110923/ccp4-6.2.0/src/pointless/probfunctions.hh
--- 20110921/ccp4-6.2.0/src/pointless/probfunctions.hh	2011-09-06 17:50:02.000000000 +0100
+++ 20110923/ccp4-6.2.0/src/pointless/probfunctions.hh	2011-09-20 17:41:24.000000000 +0100
@@ -63,6 +63,8 @@
     double HighProb() const {return High;}
     double LowProb() const {return Low;}
 
+    virtual void SetPower(const double& power) {} // dummy
+
   protected:
     // Returns v mapped on to range 0->1
     double nmap(const double& v) const
@@ -153,7 +155,6 @@
   {
   public:
     IntgrtProb() : nd(10000) {}
-	~IntgrtProb() { delete DMeanModel; }
 
     // Note that this stores a pointer to the external function
     // which therefore must continue to exist while this class
diff -r -u 20110921/ccp4-6.2.0/src/pointless/scsignificance.cpp 20110923/ccp4-6.2.0/src/pointless/scsignificance.cpp
--- 20110921/ccp4-6.2.0/src/pointless/scsignificance.cpp	2011-09-06 17:50:02.000000000 +0100
+++ 20110923/ccp4-6.2.0/src/pointless/scsignificance.cpp	2011-09-20 17:41:24.000000000 +0100
@@ -37,7 +37,7 @@
   //  P(S|score)/[P(S|score) + P(!S|score)]
   //  E(score|S) = TrueScore  (eg 1.0 for correlation coefficient)
   //  E(score|!S) is in range 0.0 to TrueScore
-  
+  //
   //  Returns = 0.0 if SDUnrelSC = 0.0
   //          = 1.0 if SDUnrelSC < 0
   {
@@ -45,20 +45,23 @@
     if (SDUnrelSC <= 0.0) return 0.0;
 
     IntgrtProb IP;
+    MeanModelBase* pDM = NULL; // pointer to base function
 
     if (Close<double>(exponent, 2.0)) {
-      DM_2sqrt *DM = new DM_2sqrt(0.0,truescore); // Model for CC- if true, most likely 0.0
+      // Model for CC- if true, most likely 0.0
+      pDM = new DM_2sqrt(0.0,truescore);
+
       //    DM_2sqrt  DM(0.0,1.0); // Model for CC- if true, most likely 0.0
       //    DM_lin  DM(0.0,1.0);
       //    DM_cubic  DM(0.0,1.0);
       //    DM_cubicsu  DM(0.0,1.0);
       //    DM_1minusmSq  DM(0.0,1.0);
       //    DM_1minusmCu  DM(0.0,1.0);
-      IP.init(*DM);
+      IP.init(*pDM);
     } else {
-      DM_power *DM = new DM_power(0.0,truescore);
-      DM->SetPower(exponent);
-      IP.init(*DM);
+      pDM = new DM_power(0.0,truescore);
+      pDM->SetPower(exponent);
+      IP.init(*pDM);
     }
 
     double PS, PnotS;
@@ -76,6 +79,7 @@
     //    	      << SDrelSC << " " << truescore << " " << PS << " " << PnotS << " "
     //    	      << PS/(PS+PnotS) << "\n";
     //^-
+    if(pDM != NULL) {delete pDM;} // clean up
 
     return PS/(PS+PnotS);  // Normalise
   }
diff -r -u 20110921/ccp4-6.2.0/src/pointless/version.hh 20110923/ccp4-6.2.0/src/pointless/version.hh
--- 20110921/ccp4-6.2.0/src/pointless/version.hh	2011-09-06 17:49:04.000000000 +0100
+++ 20110923/ccp4-6.2.0/src/pointless/version.hh	2011-09-20 17:41:24.000000000 +0100
@@ -4,9 +4,9 @@
 #define PROGRAM_VERSION_HEADER
 
 #define PROGRAM_NAME     std::string("POINTLESS")
-#define PROGRAM_VERSION  "1.6.4"
-#define PROGRAM_DATE     "17th August 2011"
-#define PROGRAM_DATE2    "2011/08/17"
+#define PROGRAM_VERSION  "1.6.5"
+#define PROGRAM_DATE     "20th September 2011"
+#define PROGRAM_DATE2    "2011/09/20"
 #define PROGRAM_EXPIRES  bool(false)
 #define EXPIRE_DAY       int(1)
 #define EXPIRE_MONTH     int(1)
