diff --git a/src/CLASS2/Install.csh b/src/CLASS2/Install.csh
index 2a9e23653f852046bb97f8a1e7b324b475c5509b..a6559638d62ecbbe657fe2b1ba74e3c1972b8b67 100644
--- a/src/CLASS2/Install.csh
+++ b/src/CLASS2/Install.csh
@@ -1,7 +1,5 @@
 # Install/unInstall package classes in LAMMPS
 
-# pair_lj_class2_coul_long.h must always be in src
-
 if ($1 == 1) then
 
   cp style_class2.h ..
@@ -22,7 +20,7 @@ if ($1 == 1) then
 
   cp pair_lj_class2.h ..
   cp pair_lj_class2_coul_cut.h ..
-#  cp pair_lj_class2_coul_long.h ..
+  cp pair_lj_class2_coul_long.h ..
 
 else if ($1 == 0) then
 
@@ -45,6 +43,6 @@ else if ($1 == 0) then
 
   rm ../pair_lj_class2.h
   rm ../pair_lj_class2_coul_cut.h
-#  rm ../pair_lj_class2_coul_long.h
+  rm ../pair_lj_class2_coul_long.h
 
 endif
diff --git a/src/CLASS2/angle_class2.cpp b/src/CLASS2/angle_class2.cpp
index 8267c9951f7608e057b0dcee31d2f347857e0559..7c9bd2918bab5ca825c5d56fd8405564725f992b 100644
--- a/src/CLASS2/angle_class2.cpp
+++ b/src/CLASS2/angle_class2.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -26,11 +26,15 @@
 #include "memory.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define SMALL 0.001
 
-/* ----------------------------------------------------------------------
-   free all arrays 
-------------------------------------------------------------------------- */
+/* ---------------------------------------------------------------------- */
+
+AngleClass2::AngleClass2(LAMMPS *lmp) : Angle(lmp) {}
+
+/* ---------------------------------------------------------------------- */
 
 AngleClass2::~AngleClass2()
 {
diff --git a/src/CLASS2/angle_class2.h b/src/CLASS2/angle_class2.h
index f5a36a3dc8438865e0dae6ff4c7687750f77a01f..c5a811517766ced09e50d362aa7f2b94de34ce02 100644
--- a/src/CLASS2/angle_class2.h
+++ b/src/CLASS2/angle_class2.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -17,9 +17,11 @@
 #include "stdio.h"
 #include "angle.h"
 
+namespace LAMMPS_NS {
+
 class AngleClass2 : public Angle {
  public:
-  AngleClass2() {}
+  AngleClass2(class LAMMPS *);
   ~AngleClass2();
   void compute(int, int);
   void coeff(int, int, char **);
@@ -36,4 +38,6 @@ class AngleClass2 : public Angle {
   void allocate();
 };
 
+}
+
 #endif
diff --git a/src/CLASS2/bond_class2.cpp b/src/CLASS2/bond_class2.cpp
index 326e14ea24fb7717899d5fc449c01980b29339d6..2327421ade84711e22ad4fe31290765dffbbfd1b 100644
--- a/src/CLASS2/bond_class2.cpp
+++ b/src/CLASS2/bond_class2.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -26,9 +26,13 @@
 #include "memory.h"
 #include "error.h"
 
-/* ----------------------------------------------------------------------
-   free all arrays 
-------------------------------------------------------------------------- */
+using namespace LAMMPS_NS;
+
+/* ---------------------------------------------------------------------- */
+
+BondClass2::BondClass2(LAMMPS *lmp) : Bond(lmp) {}
+
+/* ---------------------------------------------------------------------- */
 
 BondClass2::~BondClass2()
 {
diff --git a/src/CLASS2/bond_class2.h b/src/CLASS2/bond_class2.h
index fe250a3104795582fde7c2406a8cbbafbfe3e364..015ac4792cc59b37c7511b8e9dbbeafefad66eef 100644
--- a/src/CLASS2/bond_class2.h
+++ b/src/CLASS2/bond_class2.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -17,9 +17,11 @@
 #include "stdio.h"
 #include "bond.h"
 
+namespace LAMMPS_NS {
+
 class BondClass2 : public Bond {
  public:
-  BondClass2() {}
+  BondClass2(class LAMMPS *);
   ~BondClass2();
   void compute(int, int);
   void coeff(int, char **);
@@ -34,4 +36,6 @@ class BondClass2 : public Bond {
   void allocate();
 };
 
+}
+
 #endif
diff --git a/src/CLASS2/dihedral_class2.cpp b/src/CLASS2/dihedral_class2.cpp
index 09c38609dd7cd034a47c74e70fe123c19ad71b2e..6936ef9ed1a0c1cb1c6e2092143065e87b01cfb9 100644
--- a/src/CLASS2/dihedral_class2.cpp
+++ b/src/CLASS2/dihedral_class2.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -27,24 +27,22 @@
 #include "memory.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define MIN(A,B) ((A) < (B)) ? (A) : (B)
 #define MAX(A,B) ((A) > (B)) ? (A) : (B)
 
 #define TOLERANCE 0.05
 #define SMALL     0.0000001
 
-/* ----------------------------------------------------------------------
-   set all global defaults 
-------------------------------------------------------------------------- */
+/* ---------------------------------------------------------------------- */
 
-DihedralClass2::DihedralClass2()
+DihedralClass2::DihedralClass2(LAMMPS *lmp) : Dihedral(lmp)
 {
   PI = 4.0*atan(1.0);
 }
 
-/* ----------------------------------------------------------------------
-   free all arrays 
-------------------------------------------------------------------------- */
+/* ---------------------------------------------------------------------- */
 
 DihedralClass2::~DihedralClass2()
 {
diff --git a/src/CLASS2/dihedral_class2.h b/src/CLASS2/dihedral_class2.h
index 7a38262665a4186c730e3bddbe1c3decc7db0fde..c5cb4aea647dbbe0e039b3100dfde9e127070446 100644
--- a/src/CLASS2/dihedral_class2.h
+++ b/src/CLASS2/dihedral_class2.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -17,9 +17,11 @@
 #include "stdio.h"
 #include "dihedral.h"
 
+namespace LAMMPS_NS {
+
 class DihedralClass2 : public Dihedral {
  public:
-  DihedralClass2();
+  DihedralClass2(class LAMMPS *);
   ~DihedralClass2();
   void compute(int, int);
   void coeff(int, int, char **);
@@ -43,4 +45,6 @@ class DihedralClass2 : public Dihedral {
   void allocate();
 };
 
+}
+
 #endif
diff --git a/src/CLASS2/improper_class2.cpp b/src/CLASS2/improper_class2.cpp
index c1530a2e5043c00a2184f84febaed6354538561d..b7091b0220442b6290f2b87871d526572056ed45 100644
--- a/src/CLASS2/improper_class2.cpp
+++ b/src/CLASS2/improper_class2.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -27,20 +27,18 @@
 #include "memory.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define SMALL 0.001
 
-/* ----------------------------------------------------------------------
-   set all global defaults 
-------------------------------------------------------------------------- */
+/* ---------------------------------------------------------------------- */
 
-ImproperClass2::ImproperClass2()
+ImproperClass2::ImproperClass2(LAMMPS *lmp) : Improper(lmp)
 {
   PI = 4.0*atan(1.0);
 }
 
-/* ----------------------------------------------------------------------
-   free all arrays 
-------------------------------------------------------------------------- */
+/* ---------------------------------------------------------------------- */
 
 ImproperClass2::~ImproperClass2()
 {
diff --git a/src/CLASS2/improper_class2.h b/src/CLASS2/improper_class2.h
index fa7521aef4e187bebc07dc7111229a3f280881f5..bc953187862fb2b069d6259cb367f8a20b55d61a 100644
--- a/src/CLASS2/improper_class2.h
+++ b/src/CLASS2/improper_class2.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -17,9 +17,11 @@
 #include "stdio.h"
 #include "improper.h"
 
+namespace LAMMPS_NS {
+
 class ImproperClass2 : public Improper {
  public:
-  ImproperClass2();
+  ImproperClass2(class LAMMPS *);
   ~ImproperClass2();
   void compute(int, int);
   void coeff(int, int, char **);
@@ -38,4 +40,6 @@ class ImproperClass2 : public Improper {
   double dot(double *, double *);
 };
 
+}
+
 #endif
diff --git a/src/CLASS2/pair_lj_class2.cpp b/src/CLASS2/pair_lj_class2.cpp
index 4564ec2a8353ce0abda7230fe28083c032bdc94d..093a6947fd16d9dd624f805050f3cfe7de496f24 100644
--- a/src/CLASS2/pair_lj_class2.cpp
+++ b/src/CLASS2/pair_lj_class2.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -23,12 +23,16 @@
 #include "neighbor.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define MIN(a,b) ((a) < (b) ? (a) : (b))
 #define MAX(a,b) ((a) > (b) ? (a) : (b))
 
-/* ----------------------------------------------------------------------
-   free all arrays 
-------------------------------------------------------------------------- */
+/* ---------------------------------------------------------------------- */
+
+PairLJClass2::PairLJClass2(LAMMPS *lmp) : Pair(lmp) {}
+
+/* ---------------------------------------------------------------------- */
 
 PairLJClass2::~PairLJClass2()
 {
diff --git a/src/CLASS2/pair_lj_class2.h b/src/CLASS2/pair_lj_class2.h
index 00db7754eedfa251451b90af608fc59a076a708a..ebe787bd14df97e9ef5c98069a49c04f37f748f6 100644
--- a/src/CLASS2/pair_lj_class2.h
+++ b/src/CLASS2/pair_lj_class2.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,9 +16,11 @@
 
 #include "pair.h"
 
+namespace LAMMPS_NS {
+
 class PairLJClass2 : public Pair {
  public:
-  PairLJClass2() {}
+  PairLJClass2(class LAMMPS *);
   ~PairLJClass2();
   void compute(int, int);
   void settings(int, char **);
@@ -39,4 +41,6 @@ class PairLJClass2 : public Pair {
   void allocate();
 };
 
+}
+
 #endif
diff --git a/src/CLASS2/pair_lj_class2_coul_cut.cpp b/src/CLASS2/pair_lj_class2_coul_cut.cpp
index 78e1d649ae00fc3dd4e21d691fe40568db801622..7a8bf0b5b0489d5b71385b4980b81999a995d8ef 100644
--- a/src/CLASS2/pair_lj_class2_coul_cut.cpp
+++ b/src/CLASS2/pair_lj_class2_coul_cut.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -23,12 +23,16 @@
 #include "neighbor.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define MIN(a,b) ((a) < (b) ? (a) : (b))
 #define MAX(a,b) ((a) > (b) ? (a) : (b))
 
-/* ----------------------------------------------------------------------
-   free all arrays 
-------------------------------------------------------------------------- */
+/* ---------------------------------------------------------------------- */
+
+PairLJClass2CoulCut::PairLJClass2CoulCut(LAMMPS *lmp) : Pair(lmp) {}
+
+/* ---------------------------------------------------------------------- */
 
 PairLJClass2CoulCut::~PairLJClass2CoulCut()
 {
@@ -333,7 +337,7 @@ void PairLJClass2CoulCut::init_style()
 {
   // require an atom style with charge defined
 
-  if (atom->charge_allow == 0)
+  if (atom->q == NULL)
     error->all("Must use charged atom style with this pair style");
 }
 
diff --git a/src/CLASS2/pair_lj_class2_coul_cut.h b/src/CLASS2/pair_lj_class2_coul_cut.h
index f7475703a02bc64309d703cde7cc54e3ba0adb8e..776410363c5cc3b0b97bba92c16de19914676801 100644
--- a/src/CLASS2/pair_lj_class2_coul_cut.h
+++ b/src/CLASS2/pair_lj_class2_coul_cut.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,9 +16,11 @@
 
 #include "pair.h"
 
+namespace LAMMPS_NS {
+
 class PairLJClass2CoulCut : public Pair {
  public:
-  PairLJClass2CoulCut() {}
+  PairLJClass2CoulCut(class LAMMPS *);
   ~PairLJClass2CoulCut();
   void compute(int, int);
   void settings(int, char **);
@@ -41,4 +43,6 @@ class PairLJClass2CoulCut : public Pair {
   void allocate();
 };
 
+}
+
 #endif
diff --git a/src/CLASS2/pair_lj_class2_coul_long.cpp b/src/CLASS2/pair_lj_class2_coul_long.cpp
index 2e540745a81a6327f132e983bbbd100fe1e54922..004c8b3640fb580e178996fee1b5f085ef4f4446 100644
--- a/src/CLASS2/pair_lj_class2_coul_long.cpp
+++ b/src/CLASS2/pair_lj_class2_coul_long.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -25,6 +25,8 @@
 #include "neighbor.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define MIN(a,b) ((a) < (b) ? (a) : (b))
 #define MAX(a,b) ((a) > (b) ? (a) : (b))
 
@@ -36,9 +38,11 @@
 #define A4       -1.453152027
 #define A5        1.061405429
 
-/* ----------------------------------------------------------------------
-   free all arrays 
-------------------------------------------------------------------------- */
+/* ---------------------------------------------------------------------- */
+
+PairLJClass2CoulLong::PairLJClass2CoulLong(LAMMPS *lmp) : Pair(lmp) {}
+
+/* ---------------------------------------------------------------------- */
 
 PairLJClass2CoulLong::~PairLJClass2CoulLong()
 {
@@ -339,7 +343,7 @@ void PairLJClass2CoulLong::init_style()
 {
   // require an atom style with charge defined
 
-  if (atom->charge_allow == 0)
+  if (atom->q == NULL)
     error->all("Must use charged atom style with this pair style");
 
   cut_coulsq = cut_coul * cut_coul;
@@ -474,3 +478,10 @@ void PairLJClass2CoulLong::single(int i, int j, int itype, int jtype,
     } else one.eng_vdwl = 0.0;
   }
 }
+
+/* ---------------------------------------------------------------------- */
+
+void PairLJClass2CoulLong::extract_long(double *p_cut_coul)
+{
+  *p_cut_coul = cut_coul;
+}
diff --git a/src/CLASS2/style_class2.h b/src/CLASS2/style_class2.h
index 517070d25f468e8dda6dbfa60986e7e985eb4350..3ba9b32df4fa05caf64ba29c329fbeb06ebf26cc 100644
--- a/src/CLASS2/style_class2.h
+++ b/src/CLASS2/style_class2.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
diff --git a/src/DPD/Install.csh b/src/DPD/Install.csh
index 1c5a909e8d970b8a87e11e6ae47cacd49cb8931b..60f1e346f5f6686740b2400ccdee836891267a82 100644
--- a/src/DPD/Install.csh
+++ b/src/DPD/Install.csh
@@ -4,10 +4,10 @@ if ($1 == 1) then
 
   cp style_dpd.h ..
 
-  cp atom_dpd.cpp ..
+  cp atom_vec_dpd.cpp ..
   cp pair_dpd.cpp ..
 
-  cp atom_dpd.h ..
+  cp atom_vec_dpd.h ..
   cp pair_dpd.h ..
 
 else if ($1 == 0) then
@@ -15,10 +15,10 @@ else if ($1 == 0) then
   rm ../style_dpd.h
   touch ../style_dpd.h
 
-  rm ../atom_dpd.cpp
+  rm ../atom_vec_dpd.cpp
   rm ../pair_dpd.cpp
 
-  rm ../atom_dpd.h
+  rm ../atom_vec_dpd.h
   rm ../pair_dpd.h
 
 endif
diff --git a/src/DPD/atom_dpd.cpp b/src/DPD/atom_dpd.cpp
deleted file mode 100644
index 867fb93239b27ec390c94409fa34ad35a55193da..0000000000000000000000000000000000000000
--- a/src/DPD/atom_dpd.cpp
+++ /dev/null
@@ -1,236 +0,0 @@
-/* ----------------------------------------------------------------------
-   LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
-
-   Copyright (2003) Sandia Corporation.  Under the terms of Contract
-   DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
-   certain rights in this software.  This software is distributed under 
-   the GNU General Public License.
-
-   See the README file in the top-level LAMMPS directory.
-------------------------------------------------------------------------- */
-
-#include "atom_dpd.h"
-#include "domain.h"
-#include "modify.h"
-#include "fix.h"
-
-/* ---------------------------------------------------------------------- */
-
-AtomDPD::AtomDPD(int narg, char **arg) : Atom(narg, arg) {}
-
-/* ---------------------------------------------------------------------- */
-
-void AtomDPD::copy(int i, int j)
-{
-  tag[j] = tag[i];
-  type[j] = type[i];
-  mask[j] = mask[i];
-  image[j] = image[i];
-  x[j][0] = x[i][0];
-  x[j][1] = x[i][1];
-  x[j][2] = x[i][2];
-  v[j][0] = v[i][0];
-  v[j][1] = v[i][1];
-  v[j][2] = v[i][2];
-
-  if (nextra_grow)
-    for (int iextra = 0; iextra < nextra_grow; iextra++) 
-      modify->fix[extra_grow[iextra]]->copy_arrays(i,j);
-}
-
-/* ---------------------------------------------------------------------- */
-
-void AtomDPD::pack_comm(int n, int *list, double *buf, int *pbc_flags)
-{
-  int i,j,m;
-
-  m = 0;
-  if (pbc_flags[0] == 0) {
-    for (i = 0; i < n; i++) {
-      j = list[i];
-      buf[m++] = x[j][0];
-      buf[m++] = x[j][1];
-      buf[m++] = x[j][2];
-      buf[m++] = v[j][0];
-      buf[m++] = v[j][1];
-      buf[m++] = v[j][2];
-    }
-  } else {
-    double xprd = domain->xprd;
-    double yprd = domain->yprd;
-    double zprd = domain->zprd;
-    for (i = 0; i < n; i++) {
-      j = list[i];
-      buf[m++] = x[j][0] + pbc_flags[1]*xprd;
-      buf[m++] = x[j][1] + pbc_flags[2]*yprd;
-      buf[m++] = x[j][2] + pbc_flags[3]*zprd;
-      buf[m++] = v[j][0];
-      buf[m++] = v[j][1];
-      buf[m++] = v[j][2];
-    }
-  }
-}
-
-/* ---------------------------------------------------------------------- */
-
-void AtomDPD::unpack_comm(int n, int first, double *buf)
-{
-  int i,m,last;
-
-  m = 0;
-  last = first + n;
-  for (i = first; i < last; i++) {
-    x[i][0] = buf[m++];
-    x[i][1] = buf[m++];
-    x[i][2] = buf[m++];
-    v[i][0] = buf[m++];
-    v[i][1] = buf[m++];
-    v[i][2] = buf[m++];
-  }
-}
-
-/* ---------------------------------------------------------------------- */
-
-void AtomDPD::pack_reverse(int n, int first, double *buf)
-{
-  int i,m,last;
-
-  m = 0;
-  last = first + n;
-  for (i = first; i < last; i++) {
-    buf[m++] = f[i][0];
-    buf[m++] = f[i][1];
-    buf[m++] = f[i][2];
-  }
-}
-
-/* ---------------------------------------------------------------------- */
-
-void AtomDPD::unpack_reverse(int n, int *list, double *buf)
-{
-  int i,j,m;
-
-  m = 0;
-  for (i = 0; i < n; i++) {
-    j = list[i];
-    f[j][0] += buf[m++];
-    f[j][1] += buf[m++];
-    f[j][2] += buf[m++];
-  }
-}
-
-/* ---------------------------------------------------------------------- */
-
-void AtomDPD::pack_border(int n, int *list, double *buf, int *pbc_flags)
-{
-  int i,j,m;
-
-  m = 0;
-  if (pbc_flags[0] == 0) {
-    for (i = 0; i < n; i++) {
-      j = list[i];
-      buf[m++] = x[j][0];
-      buf[m++] = x[j][1];
-      buf[m++] = x[j][2];
-      buf[m++] = tag[j];
-      buf[m++] = type[j];
-      buf[m++] = mask[j];
-      buf[m++] = v[j][0];
-      buf[m++] = v[j][1];
-      buf[m++] = v[j][2];
-    }
-  } else {
-    double xprd = domain->xprd;
-    double yprd = domain->yprd;
-    double zprd = domain->zprd;
-    for (i = 0; i < n; i++) {
-      j = list[i];
-      buf[m++] = x[j][0] + pbc_flags[1]*xprd;
-      buf[m++] = x[j][1] + pbc_flags[2]*yprd;
-      buf[m++] = x[j][2] + pbc_flags[3]*zprd;
-      buf[m++] = tag[j];
-      buf[m++] = type[j];
-      buf[m++] = mask[j];
-      buf[m++] = v[j][0];
-      buf[m++] = v[j][1];
-      buf[m++] = v[j][2];
-    }
-  }
-}
-
-/* ---------------------------------------------------------------------- */
-
-void AtomDPD::unpack_border(int n, int first, double *buf)
-{
-  int i,m,last;
-
-  m = 0;
-  last = first + n;
-  for (i = first; i < last; i++) {
-    if (i == nmax) grow(0);
-    x[i][0] = buf[m++];
-    x[i][1] = buf[m++];
-    x[i][2] = buf[m++];
-    tag[i] = static_cast<int> (buf[m++]);
-    type[i] = static_cast<int> (buf[m++]);
-    mask[i] = static_cast<int> (buf[m++]);
-    v[i][0] = buf[m++];
-    v[i][1] = buf[m++];
-    v[i][2] = buf[m++];
-  }
-}
-
-/* ----------------------------------------------------------------------
-   pack all atom quantities for shipping to another proc
-   xyz must be 1st 3 values, so that comm::exchange can test on them 
-------------------------------------------------------------------------- */
-
-int AtomDPD::pack_exchange(int i, double *buf)
-{
-  int m = 1;
-  buf[m++] = x[i][0];
-  buf[m++] = x[i][1];
-  buf[m++] = x[i][2];
-  buf[m++] = v[i][0];
-  buf[m++] = v[i][1];
-  buf[m++] = v[i][2];
-  buf[m++] = tag[i];
-  buf[m++] = type[i];
-  buf[m++] = mask[i];
-  buf[m++] = image[i];
-
-  if (nextra_grow)
-    for (int iextra = 0; iextra < nextra_grow; iextra++) 
-      m += modify->fix[extra_grow[iextra]]->pack_exchange(i,&buf[m]);
-
-  buf[0] = m;
-  return m;
-}
-
-/* ---------------------------------------------------------------------- */
-
-int AtomDPD::unpack_exchange(double *buf)
-{
-  if (nlocal == nmax) grow(0);
-
-  int m = 1;
-  x[nlocal][0] = buf[m++];
-  x[nlocal][1] = buf[m++];
-  x[nlocal][2] = buf[m++];
-  v[nlocal][0] = buf[m++];
-  v[nlocal][1] = buf[m++];
-  v[nlocal][2] = buf[m++];
-  tag[nlocal] = static_cast<int> (buf[m++]);
-  type[nlocal] = static_cast<int> (buf[m++]);
-  mask[nlocal] = static_cast<int> (buf[m++]);
-  image[nlocal] = static_cast<int> (buf[m++]);
-
-  if (nextra_grow)
-    for (int iextra = 0; iextra < nextra_grow; iextra++) 
-      m += modify->fix[extra_grow[iextra]]->unpack_exchange(nlocal,&buf[m]);
-
-  nlocal++;
-  return m;
-}
diff --git a/src/DPD/atom_dpd.h b/src/DPD/atom_dpd.h
deleted file mode 100644
index 30af38bd302dbded1c8cef3bb474e86375ffa282..0000000000000000000000000000000000000000
--- a/src/DPD/atom_dpd.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/* ----------------------------------------------------------------------
-   LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
-
-   Copyright (2003) Sandia Corporation.  Under the terms of Contract
-   DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
-   certain rights in this software.  This software is distributed under 
-   the GNU General Public License.
-
-   See the README file in the top-level LAMMPS directory.
-------------------------------------------------------------------------- */
-
-#ifndef ATOM_DPD_H
-#define ATOM_DPD_H
-
-#include "atom.h"
-
-class AtomDPD : public Atom {
- public:
-  AtomDPD(int, char **);
-  ~AtomDPD() {}
-  void copy(int, int);
-  void pack_comm(int, int *, double *, int *);
-  void unpack_comm(int, int, double *);
-  void pack_reverse(int, int, double *);
-  void unpack_reverse(int, int *, double *);
-  void pack_border(int, int *, double *, int *);
-  void unpack_border(int, int, double *);
-  int pack_exchange(int, double *);
-  int unpack_exchange(double *);
-};
-
-#endif
diff --git a/src/DPD/pair_dpd.cpp b/src/DPD/pair_dpd.cpp
index 7dbfee4212162103ad7aaa2c65927a1c16169e5a..0c226a756382f60ea32bde0011967ca471fd27b9 100644
--- a/src/DPD/pair_dpd.cpp
+++ b/src/DPD/pair_dpd.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -28,6 +28,8 @@
 #include "neighbor.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define MIN(a,b) ((a) < (b) ? (a) : (b))
 #define MAX(a,b) ((a) > (b) ? (a) : (b))
 
@@ -35,14 +37,12 @@
 
 /* ---------------------------------------------------------------------- */
 
-PairDPD::PairDPD()
+PairDPD::PairDPD(LAMMPS *lmp) : Pair(lmp)
 {
   random = NULL;
 }
 
-/* ----------------------------------------------------------------------
-   free all arrays 
-------------------------------------------------------------------------- */
+/* ---------------------------------------------------------------------- */
 
 PairDPD::~PairDPD()
 {
@@ -208,7 +208,7 @@ void PairDPD::settings(int narg, char **arg)
   if (seed <= 0 || seed > 900000000)
     error->all("Illegal fix pair_style command");
   if (random) delete random;
-  random = new RanMars(seed + comm->me);
+  random = new RanMars(lmp,seed + comm->me);
 
   // reset cutoffs that have been explicitly set
 
@@ -372,7 +372,7 @@ void PairDPD::read_restart_settings(FILE *fp)
   // same seed that pair_style command initially specified
 
   if (random) delete random;
-  random = new RanMars(seed + comm->me);
+  random = new RanMars(lmp,seed + comm->me);
 }
 
 /* ---------------------------------------------------------------------- */
@@ -381,15 +381,7 @@ void PairDPD::single(int i, int j, int itype, int jtype, double rsq,
 		     double factor_coul, double factor_dpd, int eflag,
 		     One &one)
 {
-  double r,rinv,dot,wd,randnum,phi;
-
-  double delx = atom->x[i][0] - atom->x[j][0];
-  double dely = atom->x[i][1] - atom->x[j][1];
-  double delz = atom->x[i][2] - atom->x[j][2];
-  double delvx = atom->v[i][0] - atom->v[j][0];
-  double delvy = atom->v[i][1] - atom->v[j][1];
-  double delvz = atom->v[i][2] - atom->v[j][2];
-  double dtinvsqrt = 1.0/sqrt(update->dt);
+  double r,rinv,wd,phi;
 
   r = sqrt(rsq);
   if (r < EPSILON) {
@@ -399,9 +391,7 @@ void PairDPD::single(int i, int j, int itype, int jtype, double rsq,
   }
 
   rinv = 1.0/r;
-  dot = delx*delvx + dely*delvy + delz*delvz;
   wd = 1.0 - r/cut[itype][jtype];
-  randnum = random->gaussian();
 
   one.fforce = a0[itype][jtype]*wd * factor_dpd*rinv;
   
diff --git a/src/DPD/pair_dpd.h b/src/DPD/pair_dpd.h
index a5c106bcf7518cb6f22960c0e182852ddf00d614..0ede50cbf4b4216684459f71f148d4e545cf8ad3 100644
--- a/src/DPD/pair_dpd.h
+++ b/src/DPD/pair_dpd.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,11 +16,11 @@
 
 #include "pair.h"
 
-class RanMars;
+namespace LAMMPS_NS {
 
 class PairDPD : public Pair {
  public:
-  PairDPD();
+  PairDPD(class LAMMPS *);
   ~PairDPD();
   void compute(int, int);
   void settings(int, char **);
@@ -39,9 +39,11 @@ class PairDPD : public Pair {
   double **cut;
   double **a0,**gamma;
   double **sigma;
-  RanMars *random;
+  class RanMars *random;
 
   void allocate();
 };
 
+}
+
 #endif
diff --git a/src/DPD/style_dpd.h b/src/DPD/style_dpd.h
index 0b5d131f2f0e63bac92ed16dfad8f01ad8d1dc87..8ce617c0c2c997f3335db727ec2c565f6f218c22 100644
--- a/src/DPD/style_dpd.h
+++ b/src/DPD/style_dpd.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -12,11 +12,11 @@
 ------------------------------------------------------------------------- */
 
 #ifdef AtomInclude
-#include "atom_dpd.h"
+#include "atom_vec_dpd.h"
 #endif
 
 #ifdef AtomClass
-AtomStyle(dpd,AtomDPD)
+AtomStyle(dpd,AtomVecDPD)
 #endif
 
 #ifdef PairInclude
diff --git a/src/GRANULAR/Install.csh b/src/GRANULAR/Install.csh
index ccc65ca90f75486315afaddc1fa3e15de683845c..4eb06edcea9d8c23b2d340d3ee59812f2e61d419 100644
--- a/src/GRANULAR/Install.csh
+++ b/src/GRANULAR/Install.csh
@@ -1,28 +1,24 @@
 # Install/unInstall package classes in LAMMPS
 
-# fix_shear_history.h must always be in src
-
 if ($1 == 1) then
 
   cp style_granular.h ..
 
-  cp atom_granular.cpp ..
+  cp atom_vec_granular.cpp ..
   cp fix_freeze.cpp ..
   cp fix_gran_diag.cpp ..
   cp fix_nve_gran.cpp ..
   cp fix_pour.cpp ..
-  cp fix_shear_history.cpp ..
   cp fix_wall_gran.cpp ..
   cp pair_gran_hertzian.cpp ..
   cp pair_gran_history.cpp ..
   cp pair_gran_no_history.cpp ..
 
-  cp atom_granular.h ..
+  cp atom_vec_granular.h ..
   cp fix_freeze.h ..
   cp fix_gran_diag.h ..
   cp fix_nve_gran.h ..
   cp fix_pour.h ..
-#  cp fix_shear_history.h ..
   cp fix_wall_gran.h ..
   cp pair_gran_hertzian.h ..
   cp pair_gran_history.h ..
@@ -33,23 +29,21 @@ else if ($1 == 0) then
   rm ../style_granular.h
   touch ../style_granular.h
 
-  rm ../atom_granular.cpp
+  rm ../atom_vec_granular.cpp
   rm ../fix_freeze.cpp
   rm ../fix_gran_diag.cpp
   rm ../fix_nve_gran.cpp
   rm ../fix_pour.cpp
-  rm ../fix_shear_history.cpp
   rm ../fix_wall_gran.cpp
   rm ../pair_gran_hertzian.cpp
   rm ../pair_gran_history.cpp
   rm ../pair_gran_no_history.cpp
 
-  rm ../atom_granular.h
+  rm ../atom_vec_granular.h
   rm ../fix_freeze.h
   rm ../fix_gran_diag.h
   rm ../fix_nve_gran.h
   rm ../fix_pour.h
-#  rm ../fix_shear_history.h
   rm ../fix_wall_gran.h
   rm ../pair_gran_hertzian.h
   rm ../pair_gran_history.h
diff --git a/src/GRANULAR/atom_granular.cpp b/src/GRANULAR/atom_granular.cpp
deleted file mode 100644
index 6d183dc9fc4158d9cc9499b16fc3babac12996e5..0000000000000000000000000000000000000000
--- a/src/GRANULAR/atom_granular.cpp
+++ /dev/null
@@ -1,322 +0,0 @@
-/* ----------------------------------------------------------------------
-   LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
-
-   Copyright (2003) Sandia Corporation.  Under the terms of Contract
-   DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
-   certain rights in this software.  This software is distributed under 
-   the GNU General Public License.
-
-   See the README file in the top-level LAMMPS directory.
-------------------------------------------------------------------------- */
-
-#include "string.h"
-#include "atom_granular.h"
-#include "domain.h"
-#include "modify.h"
-#include "fix.h"
-
-/* ---------------------------------------------------------------------- */
-
-AtomGranular::AtomGranular(int narg, char **arg) : Atom(narg, arg) {}
-
-/* ---------------------------------------------------------------------- */
-
-void AtomGranular::copy(int i, int j)
-{
-  tag[j] = tag[i];
-  type[j] = type[i];
-  mask[j] = mask[i];
-  image[j] = image[i];
-  x[j][0] = x[i][0];
-  x[j][1] = x[i][1];
-  x[j][2] = x[i][2];
-  v[j][0] = v[i][0];
-  v[j][1] = v[i][1];
-  v[j][2] = v[i][2];
-  phix[j][0] = phix[i][0];
-  phix[j][1] = phix[i][1];
-  phix[j][2] = phix[i][2];
-  phiv[j][0] = phiv[i][0];
-  phiv[j][1] = phiv[i][1];
-  phiv[j][2] = phiv[i][2];
-  radius[j] = radius[i];
-  density[j] = density[i];
-  rmass[j] = rmass[i];
-
-  if (nextra_grow)
-    for (int iextra = 0; iextra < nextra_grow; iextra++) 
-      modify->fix[extra_grow[iextra]]->copy_arrays(i,j);
-}
-
-/* ---------------------------------------------------------------------- */
-
-void AtomGranular::pack_comm(int n, int *list, double *buf, int *pbc_flags)
-{
-  int i,j,m;
-
-  m = 0;
-  if (pbc_flags[0] == 0) {
-    for (i = 0; i < n; i++) {
-      j = list[i];
-      buf[m++] = x[j][0];
-      buf[m++] = x[j][1];
-      buf[m++] = x[j][2];
-      buf[m++] = v[j][0];
-      buf[m++] = v[j][1];
-      buf[m++] = v[j][2];
-      buf[m++] = phiv[j][0];
-      buf[m++] = phiv[j][1];
-      buf[m++] = phiv[j][2];
-    }
-  } else {
-    double xprd = domain->xprd;
-    double yprd = domain->yprd;
-    double zprd = domain->zprd;
-    for (i = 0; i < n; i++) {
-      j = list[i];
-      buf[m++] = x[j][0] + pbc_flags[1]*xprd;
-      buf[m++] = x[j][1] + pbc_flags[2]*yprd;
-      buf[m++] = x[j][2] + pbc_flags[3]*zprd;
-      buf[m++] = v[j][0];
-      buf[m++] = v[j][1];
-      buf[m++] = v[j][2];
-      buf[m++] = phiv[j][0];
-      buf[m++] = phiv[j][1];
-      buf[m++] = phiv[j][2];
-    }
-  }
-}
-
-/* ---------------------------------------------------------------------- */
-
-void AtomGranular::unpack_comm(int n, int first, double *buf)
-{
-  int i,m,last;
-
-  m = 0;
-  last = first + n;
-  for (i = first; i < last; i++) {
-    x[i][0] = buf[m++];
-    x[i][1] = buf[m++];
-    x[i][2] = buf[m++];
-    v[i][0] = buf[m++];
-    v[i][1] = buf[m++];
-    v[i][2] = buf[m++];
-    phiv[i][0] = buf[m++];
-    phiv[i][1] = buf[m++];
-    phiv[i][2] = buf[m++];
-  }
-}
-
-/* ---------------------------------------------------------------------- */
-
-void AtomGranular::pack_reverse(int n, int first, double *buf)
-{
-  int i,m,last;
-
-  m = 0;
-  last = first + n;
-  for (i = first; i < last; i++) {
-    buf[m++] = f[i][0];
-    buf[m++] = f[i][1];
-    buf[m++] = f[i][2];
-    buf[m++] = phia[i][0];
-    buf[m++] = phia[i][1];
-    buf[m++] = phia[i][2];
-  }
-}
-
-/* ---------------------------------------------------------------------- */
-
-void AtomGranular::unpack_reverse(int n, int *list, double *buf)
-{
-  int i,j,m;
-
-  m = 0;
-  for (i = 0; i < n; i++) {
-    j = list[i];
-    f[j][0] += buf[m++];
-    f[j][1] += buf[m++];
-    f[j][2] += buf[m++];
-    phia[j][0] += buf[m++];
-    phia[j][1] += buf[m++];
-    phia[j][2] += buf[m++];
-  }
-}
-
-/* ---------------------------------------------------------------------- */
-
-void AtomGranular::pack_border(int n, int *list, double *buf, int *pbc_flags)
-{
-  int i,j,m;
-
-  m = 0;
-  if (pbc_flags[0] == 0) {
-    for (i = 0; i < n; i++) {
-      j = list[i];
-      buf[m++] = x[j][0];
-      buf[m++] = x[j][1];
-      buf[m++] = x[j][2];
-      buf[m++] = tag[j];
-      buf[m++] = type[j];
-      buf[m++] = mask[j];
-      buf[m++] = v[j][0];
-      buf[m++] = v[j][1];
-      buf[m++] = v[j][2];
-      buf[m++] = phiv[j][0];
-      buf[m++] = phiv[j][1];
-      buf[m++] = phiv[j][2];
-      buf[m++] = radius[j];
-      buf[m++] = rmass[j];
-    }
-  } else {
-    double xprd = domain->xprd;
-    double yprd = domain->yprd;
-    double zprd = domain->zprd;
-    for (i = 0; i < n; i++) {
-      j = list[i];
-      buf[m++] = x[j][0] + pbc_flags[1]*xprd;
-      buf[m++] = x[j][1] + pbc_flags[2]*yprd;
-      buf[m++] = x[j][2] + pbc_flags[3]*zprd;
-      buf[m++] = tag[j];
-      buf[m++] = type[j];
-      buf[m++] = mask[j];
-      buf[m++] = v[j][0];
-      buf[m++] = v[j][1];
-      buf[m++] = v[j][2];
-      buf[m++] = phiv[j][0];
-      buf[m++] = phiv[j][1];
-      buf[m++] = phiv[j][2];
-      buf[m++] = radius[j];
-      buf[m++] = rmass[j];
-    }
-  }
-}
-
-/* ---------------------------------------------------------------------- */
-
-void AtomGranular::unpack_border(int n, int first, double *buf)
-{
-  int i,m,last;
-
-  m = 0;
-  last = first + n;
-  for (i = first; i < last; i++) {
-    if (i == nmax) grow(0);
-    x[i][0] = buf[m++];
-    x[i][1] = buf[m++];
-    x[i][2] = buf[m++];
-    tag[i] = static_cast<int> (buf[m++]);
-    type[i] = static_cast<int> (buf[m++]);
-    mask[i] = static_cast<int> (buf[m++]);
-    v[i][0] = buf[m++];
-    v[i][1] = buf[m++];
-    v[i][2] = buf[m++];
-    phiv[i][0] = buf[m++];
-    phiv[i][1] = buf[m++];
-    phiv[i][2] = buf[m++];
-    radius[i] = buf[m++];
-    rmass[i] = buf[m++];
-  }
-}
-
-/* ----------------------------------------------------------------------
-   pack all atom quantities for shipping to another proc
-   xyz must be 1st 3 values, so that comm::exchange can test on them
-------------------------------------------------------------------------- */
-
-int AtomGranular::pack_exchange(int i, double *buf)
-{
-  int m = 1;
-  buf[m++] = x[i][0];
-  buf[m++] = x[i][1];
-  buf[m++] = x[i][2];
-  buf[m++] = v[i][0];
-  buf[m++] = v[i][1];
-  buf[m++] = v[i][2];
-  buf[m++] = phix[i][0];
-  buf[m++] = phix[i][1];
-  buf[m++] = phix[i][2];
-  buf[m++] = phiv[i][0];
-  buf[m++] = phiv[i][1];
-  buf[m++] = phiv[i][2];
-  buf[m++] = radius[i];
-  buf[m++] = density[i];
-  buf[m++] = rmass[i];
-  buf[m++] = tag[i];
-  buf[m++] = type[i];
-  buf[m++] = mask[i];
-  buf[m++] = image[i];
-
-  if (nextra_grow)
-    for (int iextra = 0; iextra < nextra_grow; iextra++) 
-      m += modify->fix[extra_grow[iextra]]->pack_exchange(i,&buf[m]);
-
-  buf[0] = m;
-  return m;
-}
-
-/* ---------------------------------------------------------------------- */
-
-int AtomGranular::unpack_exchange(double *buf)
-{
-  if (nlocal == nmax) grow(0);
-
-  int m = 1;
-  x[nlocal][0] = buf[m++];
-  x[nlocal][1] = buf[m++];
-  x[nlocal][2] = buf[m++];
-  v[nlocal][0] = buf[m++];
-  v[nlocal][1] = buf[m++];
-  v[nlocal][2] = buf[m++];
-  phix[nlocal][0] = buf[m++];
-  phix[nlocal][1] = buf[m++];
-  phix[nlocal][2] = buf[m++];
-  phiv[nlocal][0] = buf[m++];
-  phiv[nlocal][1] = buf[m++];
-  phiv[nlocal][2] = buf[m++];
-  radius[nlocal] = buf[m++];
-  density[nlocal] = buf[m++];
-  rmass[nlocal] = buf[m++];
-  tag[nlocal] = static_cast<int> (buf[m++]);
-  type[nlocal] = static_cast<int> (buf[m++]);
-  mask[nlocal] = static_cast<int> (buf[m++]);
-  image[nlocal] = static_cast<int> (buf[m++]);
-
-  if (nextra_grow)
-    for (int iextra = 0; iextra < nextra_grow; iextra++) 
-      m += modify->fix[extra_grow[iextra]]->unpack_exchange(nlocal,&buf[m]);
-
-  nlocal++;
-  return m;
-}
-
-/* ----------------------------------------------------------------------
-   unpack vels & phis specific to granular data file
-------------------------------------------------------------------------- */
-
-void AtomGranular::unpack_vels(int n, char *buf)
-{
-  int m,tagtmp;
-  double vxtmp,vytmp,vztmp,phivxtmp,phivytmp,phivztmp;
-  char *next;
-
-  for (int i = 0; i < n; i++) {
-    next = strchr(buf,'\n');
-    *next = '\0';
-    sscanf(buf,"%d %lg %lg %lg %lg %lg %lg",
-	   &tagtmp,&vxtmp,&vytmp,&vztmp,
-	   &phivxtmp,&phivytmp,&phivztmp);
-    if ((m = map(tagtmp)) >= 0) {
-      v[m][0] = vxtmp;
-      v[m][1] = vytmp;
-      v[m][2] = vztmp;
-      phiv[m][0] = phivxtmp;
-      phiv[m][1] = phivytmp;
-      phiv[m][2] = phivztmp;
-    }
-    buf = next + 1;
-  }
-}
diff --git a/src/GRANULAR/atom_granular.h b/src/GRANULAR/atom_granular.h
deleted file mode 100644
index 04a84f56e7d47806294bc7a6f756e5ae6b916a5e..0000000000000000000000000000000000000000
--- a/src/GRANULAR/atom_granular.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/* ----------------------------------------------------------------------
-   LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
-
-   Copyright (2003) Sandia Corporation.  Under the terms of Contract
-   DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
-   certain rights in this software.  This software is distributed under 
-   the GNU General Public License.
-
-   See the README file in the top-level LAMMPS directory.
-------------------------------------------------------------------------- */
-
-#ifndef ATOM_GRANULAR_H
-#define ATOM_GRANULAR_H
-
-#include "atom.h"
-
-class AtomGranular : public Atom {
- public:
-  AtomGranular(int, char **);
-  ~AtomGranular() {}
-  void copy(int, int);
-  void pack_comm(int, int *, double *, int *);
-  void unpack_comm(int, int, double *);
-  void pack_reverse(int, int, double *);
-  void unpack_reverse(int, int *, double *);
-  void pack_border(int, int *, double *, int *);
-  void unpack_border(int, int, double *);
-  int pack_exchange(int, double *);
-  int unpack_exchange(double *);
-
-  void unpack_vels(int, char *);
-};
-
-#endif
diff --git a/src/GRANULAR/fix_freeze.cpp b/src/GRANULAR/fix_freeze.cpp
index 0d146eb88c4facb48ab8f236dc64ced8f101b885..b264fe66bcbc5a8688ea8194b478d0a8d799fba8 100644
--- a/src/GRANULAR/fix_freeze.cpp
+++ b/src/GRANULAR/fix_freeze.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -18,9 +18,12 @@
 #include "comm.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 /* ---------------------------------------------------------------------- */
 
-FixFreeze::FixFreeze(int narg, char **arg) : Fix(narg, arg)
+FixFreeze::FixFreeze(LAMMPS *lmp, int narg, char **arg) :
+  Fix(lmp, narg, arg)
 {
   if (narg != 3) error->all("Illegal fix freeze command");
 
diff --git a/src/GRANULAR/fix_freeze.h b/src/GRANULAR/fix_freeze.h
index b2985c76960609e9d32f3ba920667dc00c7da8f2..e23d3ca0059a5e704c09ed0b0995f3ee5cbe9db2 100644
--- a/src/GRANULAR/fix_freeze.h
+++ b/src/GRANULAR/fix_freeze.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,14 +16,17 @@
 
 #include "fix.h"
 
+namespace LAMMPS_NS {
+
 class FixFreeze : public Fix {
  public:
-  FixFreeze(int, char **);
-  ~FixFreeze() {}
+  FixFreeze(class LAMMPS *, int, char **);
   int setmask();
   void init();
   void setup();
   void post_force(int);
 };
 
+}
+
 #endif
diff --git a/src/GRANULAR/fix_gran_diag.cpp b/src/GRANULAR/fix_gran_diag.cpp
index 1c5a32ffdc74493d791ea090b5df57cf26d65cd4..8c69d69d66ac0fe0de646dc660e8a28c6aa48078 100644
--- a/src/GRANULAR/fix_gran_diag.cpp
+++ b/src/GRANULAR/fix_gran_diag.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -17,28 +17,29 @@
 
 #include "math.h"
 #include "stdlib.h"
+#include "string.h"
 #include "fix_gran_diag.h"
 #include "update.h"
 #include "force.h"
-#include "pair_gran_no_history.h"
-#include "pair_gran_history.h"
-#include "pair_gran_hertzian.h"
+#include "pair.h"
 #include "atom.h"
 #include "neighbor.h"
+#include "modify.h"
 #include "comm.h"
 #include "domain.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define MIN(a,b) ((a) < (b) ? (a) : (b))
 #define MAX(a,b) ((a) > (b) ? (a) : (b))
 
-#define NO_HISTORY 1
-#define HISTORY    2
-#define HERTZIAN   3
+enum{NO_HISTORY,HISTORY,HERTZIAN};
 
 /* ---------------------------------------------------------------------- */
 
-FixGranDiag::FixGranDiag(int narg, char **arg) : Fix(narg, arg)
+FixGranDiag::FixGranDiag(LAMMPS *lmp, int narg, char **arg) :
+  Fix(lmp, narg, arg)
 {
   if (narg != 6) error->all("Illegal fix gran/diag command");
   nevery = atoi(arg[3]);
@@ -112,37 +113,38 @@ int FixGranDiag::setmask()
 
 void FixGranDiag::init()
 {
+  // insure use of granular pair_style
+  // set local values from Pair values
+
+  Pair *pair = force->pair_match("gran");
+  if (pair == NULL)
+    error->all("Fix gran/diag is incompatible with Pair style");
+  int dampflag;
+  double gamman;
+  pair->extract_gran(&xkk,&gamman,&xmu,&dampflag);
+
+  // same initialization as in pair_gran_history::init_style()
+
+  xkkt = xkk * 2.0/7.0;
   dt = update->dt;
+  double gammas = 0.5*gamman;
+  if (dampflag == 0) gammas = 0.0;
+  gamman_dl = gamman/dt;
+  gammas_dl = gammas/dt;
+
+  // set pairstyle from granular pair style
+
+  if (force->pair_match("gran/no_history")) pairstyle = NO_HISTORY;
+  else if (force->pair_match("gran/history")) pairstyle = HISTORY;
+  else if (force->pair_match("gran/hertzian")) pairstyle = HERTZIAN;
+
+  // check for freeze Fix and set freeze_group_bit
 
-  // set constants from pair style
-
-  Pair *anypair;
-  if (anypair = force->pair_match("gran/no_history")) {
-    pairstyle = NO_HISTORY;
-    xkk = ((PairGranNoHistory *) anypair)->xkk;
-    xkkt = ((PairGranNoHistory *) anypair)->xkkt;
-    xmu = ((PairGranNoHistory *) anypair)->xmu;
-    gamman_dl = ((PairGranNoHistory *) anypair)->gamman_dl;
-    gammas_dl = ((PairGranNoHistory *) anypair)->gammas_dl;
-    freeze_group_bit = ((PairGranNoHistory *) anypair)->freeze_group_bit;
-  } else if (anypair = force->pair_match("gran/history")) {
-    pairstyle = HISTORY;
-    xkk = ((PairGranHistory *) anypair)->xkk;
-    xkkt = ((PairGranHistory *) anypair)->xkkt;
-    xmu = ((PairGranHistory *) anypair)->xmu;
-    gamman_dl = ((PairGranHistory *) anypair)->gamman_dl;
-    gammas_dl = ((PairGranHistory *) anypair)->gammas_dl;
-    freeze_group_bit = ((PairGranNoHistory *) anypair)->freeze_group_bit;
-  } else if (anypair = force->pair_match("gran/hertzian")) {
-    pairstyle = HERTZIAN;
-    xkk = ((PairGranHertzian *) anypair)->xkk;
-    xkkt = ((PairGranHertzian *) anypair)->xkkt;
-    xmu = ((PairGranHertzian *) anypair)->xmu;
-    gamman_dl = ((PairGranHertzian *) anypair)->gamman_dl;
-    gammas_dl = ((PairGranHertzian *) anypair)->gammas_dl;
-    freeze_group_bit = ((PairGranNoHistory *) anypair)->freeze_group_bit;
-  } else
-    error->all("Must use fix gran/diag with granular pair style");
+  int i;
+  for (i = 0; i < modify->nfix; i++)
+    if (strcmp(modify->fix[i]->style,"freeze") == 0) break;
+  if (i < modify->nfix) freeze_group_bit = modify->fix[i]->groupbit;
+  else freeze_group_bit = 0;
 }
 
 /* ---------------------------------------------------------------------- */
diff --git a/src/GRANULAR/fix_gran_diag.h b/src/GRANULAR/fix_gran_diag.h
index 970e076552ee10218ffd4cba17a72e597fedb113..394df97ed829275d0f986349fc42a3884eddfdc6 100644
--- a/src/GRANULAR/fix_gran_diag.h
+++ b/src/GRANULAR/fix_gran_diag.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -17,9 +17,11 @@
 #include "stdio.h"
 #include "fix.h"
 
+namespace LAMMPS_NS {
+
 class FixGranDiag : public Fix {
  public:
-  FixGranDiag(int, char **);
+  FixGranDiag(class LAMMPS *, int, char **);
   ~FixGranDiag();
   int setmask();
   void init();
@@ -50,4 +52,6 @@ class FixGranDiag : public Fix {
   void stress_hertzian();
 };
 
+}
+
 #endif
diff --git a/src/GRANULAR/fix_nve_gran.cpp b/src/GRANULAR/fix_nve_gran.cpp
index 24e09d51d2f48358909c7d629c763c5a1d335275..f98a9626adaf0a651c33bf9976308d9e1f6f38ac 100644
--- a/src/GRANULAR/fix_nve_gran.cpp
+++ b/src/GRANULAR/fix_nve_gran.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -19,6 +19,8 @@
 #include "force.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 // moments of inertia for sphere and disk
 
 #define INERTIA3D 0.4
@@ -26,7 +28,8 @@
 
 /* ---------------------------------------------------------------------- */
 
-FixNVEGran::FixNVEGran(int narg, char **arg) : Fix(narg, arg)
+FixNVEGran::FixNVEGran(LAMMPS *lmp, int narg, char **arg) :
+  Fix(lmp, narg, arg)
 {
   if (narg != 3) error->all("Illegal fix nve/gran command");
 
diff --git a/src/GRANULAR/fix_nve_gran.h b/src/GRANULAR/fix_nve_gran.h
index 2da678aa94ba059477eae89146651853d000dfe3..0dc4eaaf7190635591dbac378edeb31b9535a33d 100644
--- a/src/GRANULAR/fix_nve_gran.h
+++ b/src/GRANULAR/fix_nve_gran.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,10 +16,11 @@
 
 #include "fix.h"
 
+namespace LAMMPS_NS {
+
 class FixNVEGran : public Fix {
  public:
-  FixNVEGran(int, char **);
-  ~FixNVEGran() {}
+  FixNVEGran(class LAMMPS *, int, char **);
   int setmask();
   void init();
   void initial_integrate();
@@ -29,4 +30,6 @@ class FixNVEGran : public Fix {
   double dtv,dtf,dtfphi;
 };
 
+}
+
 #endif
diff --git a/src/GRANULAR/fix_pour.cpp b/src/GRANULAR/fix_pour.cpp
index 775b58005aac3d77ef8e694b73428076fc977e87..843b85be94b74127a2b9afcdaeb5fe0f38bc3172 100644
--- a/src/GRANULAR/fix_pour.cpp
+++ b/src/GRANULAR/fix_pour.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,6 +16,7 @@
 #include "string.h"
 #include "fix_pour.h"
 #include "atom.h"
+#include "atom_vec.h"
 #include "force.h"
 #include "update.h"
 #include "comm.h"
@@ -30,11 +31,14 @@
 #include "memory.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define EPSILON 0.001
 
 /* ---------------------------------------------------------------------- */
 
-FixPour::FixPour(int narg, char **arg) : Fix(narg, arg)
+FixPour::FixPour(LAMMPS *lmp, int narg, char **arg) :
+  Fix(lmp, narg, arg)
 {
   if (narg < 6) error->all("Illegal fix pour command");
 
@@ -151,7 +155,7 @@ FixPour::FixPour(int narg, char **arg) : Fix(narg, arg)
 
   // random number generator, same for all procs
 
-  random = new RanPark(seed);
+  random = new RanPark(lmp,seed);
 
   // allgather arrays
 
@@ -269,10 +273,11 @@ void FixPour::init()
 
   // check if a shear history fix exists
 
-  ifix_history = -1;
+  fix_history = NULL;
   if (force->pair_match("gran/history") || force->pair_match("gran/hertzian"))
     for (int i = 0; i < modify->nfix; i++)
-      if (strcmp(modify->fix[i]->style,"SHEAR_HISTORY") == 0) ifix_history = i;
+      if (strcmp(modify->fix[i]->style,"SHEAR_HISTORY") == 0)
+	fix_history = (FixShearHistory *) modify->fix[i];
 }
 
 /* ----------------------------------------------------------------------
@@ -403,7 +408,7 @@ void FixPour::pre_exchange()
     error->warning("Less insertions than requested");
 
   // check if new atom is in my sub-box or above it if I'm highest proc
-  // if so, add to my list via create_one()
+  // if so, add to my list via create_atom()
   // initialize info about the atom
   // type, diameter, density set from fix parameters
   // group mask set to "all" plus fix group
@@ -412,6 +417,7 @@ void FixPour::pre_exchange()
   // this gives continuous stream of atoms
   // set npartner for new atom to 0 (assume not touching any others)
 
+  AtomVec *avec = atom->avec;
   int m,flag;
   double denstmp,vxtmp,vytmp,vztmp;
   double g = 1.0;
@@ -445,7 +451,7 @@ void FixPour::pre_exchange()
 	     xtmp >= domain->subxlo && xtmp < domain->subxhi) flag = 1;
 
     if (flag) {
-      atom->create_one(ntype,xtmp,ytmp,ztmp);
+      avec->create_atom(ntype,xtmp,ytmp,ztmp,0);
       m = atom->nlocal - 1;
       atom->type[m] = ntype;
       atom->radius[m] = radtmp;
@@ -458,8 +464,7 @@ void FixPour::pre_exchange()
       atom->v[m][0] = vxtmp;
       atom->v[m][1] = vytmp;
       atom->v[m][2] = vztmp;
-      if (ifix_history >= 0)
-	((FixShearHistory *) modify->fix[ifix_history])->npartner[m] = 0;
+      if (fix_history) fix_history->npartner[m] = 0;
     }
   }
 
diff --git a/src/GRANULAR/fix_pour.h b/src/GRANULAR/fix_pour.h
index 2fea9b3576753c6f3ebeac2ef42deda74559163f..c2a011218da7efc4130a328f379642b8534fd1e3 100644
--- a/src/GRANULAR/fix_pour.h
+++ b/src/GRANULAR/fix_pour.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,7 +16,7 @@
 
 #include "fix.h"
 
-class RanPark;
+namespace LAMMPS_NS {
 
 class FixPour : public Fix {
   friend class PairGranHistory;
@@ -24,7 +24,7 @@ class FixPour : public Fix {
   friend class PairGranNoHistory;
 
  public:
-  FixPour(int, char **);
+  FixPour(class LAMMPS *, int, char **);
   ~FixPour();
   int setmask();
   void init();
@@ -47,12 +47,13 @@ class FixPour : public Fix {
   double PI;
   int nfreq,nfirst,ninserted,nper;
   double lo_current,hi_current;
-  int ifix_history;
-
-  RanPark *random;
+  class FixShearHistory *fix_history;
+  class RanPark *random;
 
   int overlap(int);
   void xyz_random(double, double &, double &, double &);
 };
 
+}
+
 #endif
diff --git a/src/GRANULAR/fix_shear_history.cpp b/src/GRANULAR/fix_shear_history.cpp
deleted file mode 100644
index 0c509a952237b0769335d8067eb9053f90123eac..0000000000000000000000000000000000000000
--- a/src/GRANULAR/fix_shear_history.cpp
+++ /dev/null
@@ -1,282 +0,0 @@
-/* ----------------------------------------------------------------------
-   LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
-
-   Copyright (2003) Sandia Corporation.  Under the terms of Contract
-   DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
-   certain rights in this software.  This software is distributed under 
-   the GNU General Public License.
-
-   See the README file in the top-level LAMMPS directory.
-------------------------------------------------------------------------- */
-
-#include "string.h"
-#include "stdio.h"
-#include "fix_shear_history.h"
-#include "atom.h"
-#include "neighbor.h"
-#include "force.h"
-#include "update.h"
-#include "modify.h"
-#include "memory.h"
-#include "error.h"
-
-#define MAXTOUCH 15
-
-/* ---------------------------------------------------------------------- */
-
-FixShearHistory::FixShearHistory(int narg, char **arg) : Fix(narg, arg)
-{
-  restart_peratom = 1;
-
-  // perform initial allocation of atom-based arrays
-  // register with atom class
-
-  npartner = NULL;
-  partner = NULL;
-  shearpartner = NULL;
-  grow_arrays(atom->nmax);
-  atom->add_callback(0);
-  atom->add_callback(1);
-
-  // initialize npartner to 0 so neighbor list creation is OK the 1st time
-
-  int nlocal = atom->nlocal;
-  for (int i = 0; i < nlocal; i++) npartner[i] = 0;
-}
-
-/* ---------------------------------------------------------------------- */
-
-FixShearHistory::~FixShearHistory()
-{
-  // if atom class still exists:
-  //   unregister this fix so atom class doesn't invoke it any more
-
-  if (atom) atom->delete_callback(id,0);
-  if (atom) atom->delete_callback(id,1);
-
-  // delete locally stored arrays
-
-  memory->sfree(npartner);
-  memory->destroy_2d_int_array(partner);
-  memory->destroy_3d_double_array(shearpartner);
-}
-
-/* ---------------------------------------------------------------------- */
-
-int FixShearHistory::setmask()
-{
-  int mask = 0;
-  mask |= PRE_EXCHANGE;
-  return mask;
-}
-
-/* ---------------------------------------------------------------------- */
-
-void FixShearHistory::init()
-{
-  if (atom->tag_enable == 0) 
-    error->all("Pair style granular with history requires atoms have IDs");
-}
-
-/* ----------------------------------------------------------------------
-   copy shear partner info from neighbor lists to atom arrays
-   so can be exchanged with atoms
-------------------------------------------------------------------------- */
-
-void FixShearHistory::pre_exchange()
-{
-  int i,j,k,m;
-
-  // zero npartners for all current atoms
-
-  int nlocal = atom->nlocal;
-  for (i = 0; i < nlocal; i++) npartner[i] = 0;
-
-  // copy shear info from neighbor list atoms to atom arrays
-  // nlocal = nlocal_neighbor = nlocal when neighbor list last built,
-  //   which might be pre-insert on this step
-
-  int numneigh;
-  int *neighs,*touch;
-  double *firstshear,*shear;
-  int *tag = atom->tag;
-  nlocal = neighbor->nlocal_neighbor;
-
-  for (i = 0; i < nlocal; i++) {
-    neighs = neighbor->firstneigh[i];
-    touch = neighbor->firsttouch[i];
-    firstshear = neighbor->firstshear[i];
-    numneigh = neighbor->numneigh[i];
-    for (k = 0; k < numneigh; k++) {
-      if (touch[k]) {
-	shear = &firstshear[3*k];
-	j = neighs[k];
-	if (npartner[i] < MAXTOUCH) {
-	  m = npartner[i];
-	  partner[i][m] = tag[j];
-	  shearpartner[i][m][0] = shear[0];
-	  shearpartner[i][m][1] = shear[1];
-	  shearpartner[i][m][2] = shear[2];
-	}
-	npartner[i]++;
-	if (j < nlocal) {
-	  if (npartner[j] < MAXTOUCH) {
-	    m = npartner[j];
-	    partner[j][m] = tag[i];
-	    shearpartner[j][m][0] = -shear[0];
-	    shearpartner[j][m][1] = -shear[1];
-	    shearpartner[j][m][2] = -shear[2];
-	  }
-	  npartner[j]++;
-	}
-      }
-    }
-  }
-
-  // test for too many touching neighbors
-
-  int flag = 0;
-  for (i = 0; i < nlocal; i++)
-    if (npartner[i] >= MAXTOUCH) flag = 1;
-  int flag_all;
-  MPI_Allreduce(&flag,&flag_all,1,MPI_INT,MPI_SUM,world);
-  if (flag_all) error->all("Too many touching neighbors - boost MAXTOUCH");
-}
-
-/* ----------------------------------------------------------------------
-   memory usage of local atom-based arrays
-------------------------------------------------------------------------- */
-
-int FixShearHistory::memory_usage()
-{
-  int nmax = atom->nmax;
-  int bytes = nmax * sizeof(int);
-  bytes += nmax*MAXTOUCH * sizeof(int);
-  bytes += nmax*MAXTOUCH*3 * sizeof(double);
-  return bytes;
-}
-
-/* ----------------------------------------------------------------------
-   allocate local atom-based arrays
-------------------------------------------------------------------------- */
-
-void FixShearHistory::grow_arrays(int nmax)
-{
-  npartner = (int *) memory->srealloc(npartner,nmax*sizeof(int),
-				      "shear_history:npartner");
-  partner = memory->grow_2d_int_array(partner,nmax,MAXTOUCH,
-				      "shear_history:partner");
-  shearpartner = 
-    memory->grow_3d_double_array(shearpartner,nmax,MAXTOUCH,3,
-				 "shear_history:shearpartner");
-}
-
-/* ----------------------------------------------------------------------
-   copy values within local atom-based arrays
-------------------------------------------------------------------------- */
-
-void FixShearHistory::copy_arrays(int i, int j)
-{
-  npartner[j] = npartner[i];
-  for (int m = 0; m < npartner[j]; m++) {
-    partner[j][m] = partner[i][m];
-    shearpartner[j][m][0] = shearpartner[i][m][0];
-    shearpartner[j][m][1] = shearpartner[i][m][1];
-    shearpartner[j][m][2] = shearpartner[i][m][2];
-  }
-}
-
-/* ----------------------------------------------------------------------
-   pack values in local atom-based arrays for exchange with another proc
-------------------------------------------------------------------------- */
-
-int FixShearHistory::pack_exchange(int i, double *buf)
-{
-  int m = 0;
-  buf[m++] = npartner[i];
-  for (int n = 0; n < npartner[i]; n++) {
-    buf[m++] = partner[i][n];
-    buf[m++] = shearpartner[i][n][0];
-    buf[m++] = shearpartner[i][n][1];
-    buf[m++] = shearpartner[i][n][2];
-  }
-  return m;
-}
-
-/* ----------------------------------------------------------------------
-   unpack values in local atom-based arrays from exchange with another proc
-------------------------------------------------------------------------- */
-
-int FixShearHistory::unpack_exchange(int nlocal, double *buf)
-{
-  int m = 0;
-  npartner[nlocal] = static_cast<int> (buf[m++]);
-  for (int n = 0; n < npartner[nlocal]; n++) {
-    partner[nlocal][n] = static_cast<int> (buf[m++]);
-    shearpartner[nlocal][n][0] = buf[m++];
-    shearpartner[nlocal][n][1] = buf[m++];
-    shearpartner[nlocal][n][2] = buf[m++];
-  }
-  return m;
-}
-
-/* ----------------------------------------------------------------------
-   pack values in local atom-based arrays for restart file
-------------------------------------------------------------------------- */
-
-int FixShearHistory::pack_restart(int i, double *buf)
-{
-  int m = 0;
-  buf[m++] = 4*npartner[i] + 2;
-  buf[m++] = npartner[i];
-  for (int n = 0; n < npartner[i]; n++) {
-    buf[m++] = partner[i][n];
-    buf[m++] = shearpartner[i][n][0];
-    buf[m++] = shearpartner[i][n][1];
-    buf[m++] = shearpartner[i][n][2];
-  }
-  return m;
-}
-
-/* ----------------------------------------------------------------------
-   unpack values from atom->extra array to restart the fix
-------------------------------------------------------------------------- */
-
-void FixShearHistory::unpack_restart(int nlocal, int nth)
-{
-  double **extra = atom->extra;
-
-  // skip to Nth set of extra values
-
-  int m = 0;
-  for (int i = 0; i < nth; i++) m += static_cast<int> (extra[nlocal][m]);
-  m++;
-
-  npartner[nlocal] = static_cast<int> (extra[nlocal][m++]);
-  for (int n = 0; n < npartner[nlocal]; n++) {
-    partner[nlocal][n] = static_cast<int> (extra[nlocal][m++]);
-    shearpartner[nlocal][n][0] = extra[nlocal][m++];
-    shearpartner[nlocal][n][1] = extra[nlocal][m++];
-    shearpartner[nlocal][n][2] = extra[nlocal][m++];
-  }
-}
-
-/* ----------------------------------------------------------------------
-   maxsize of any atom's restart data
-------------------------------------------------------------------------- */
-
-int FixShearHistory::maxsize_restart()
-{
-  return 4*MAXTOUCH + 2;
-}
-
-/* ----------------------------------------------------------------------
-   size of atom nlocal's restart data
-------------------------------------------------------------------------- */
-
-int FixShearHistory::size_restart(int nlocal)
-{
-  return 4*npartner[nlocal] + 2;
-}
diff --git a/src/GRANULAR/fix_wall_gran.cpp b/src/GRANULAR/fix_wall_gran.cpp
index 7a90f023bd4de46ef7cfbda393d662efc2d65732..5850d4ade05c6f7b986369ab228f7b843ae865c3 100644
--- a/src/GRANULAR/fix_wall_gran.cpp
+++ b/src/GRANULAR/fix_wall_gran.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -22,21 +22,15 @@
 #include "atom.h"
 #include "update.h"
 #include "force.h"
+#include "pair.h"
 #include "modify.h"
-#include "pair_gran_no_history.h"
-#include "pair_gran_history.h"
-#include "pair_gran_hertzian.h"
 #include "memory.h"
 #include "error.h"
 
-#define XPLANE    1
-#define YPLANE    2
-#define ZPLANE    3
-#define ZCYLINDER 4
+using namespace LAMMPS_NS;
 
-#define NO_HISTORY 1
-#define HISTORY    2
-#define HERTZIAN   3
+enum{XPLANE,YPLANE,ZPLANE,ZCYLINDER};
+enum{NO_HISTORY,HISTORY,HERTZIAN};
 
 #define BIG 1.0e20
 
@@ -45,7 +39,8 @@
 
 /* ---------------------------------------------------------------------- */
 
-FixWallGran::FixWallGran(int narg, char **arg) : Fix(narg, arg)
+FixWallGran::FixWallGran(LAMMPS *lmp, int narg, char **arg) :
+  Fix(lmp, narg, arg)
 {
   if (narg < 4) error->all("Illegal fix wall/gran command");
   
@@ -125,7 +120,7 @@ FixWallGran::FixWallGran(int narg, char **arg) : Fix(narg, arg)
   }
 
   // perform initial allocation of atom-based arrays
-  // register with atom class
+  // register with Atom class
 
   shear = NULL;
   grow_arrays(atom->nmax);
@@ -143,11 +138,10 @@ FixWallGran::FixWallGran(int narg, char **arg) : Fix(narg, arg)
 
 FixWallGran::~FixWallGran()
 {
-  // if atom class still exists:
-  //   unregister this fix so atom class doesn't invoke it any more
+  // unregister callbacks to this fix from Atom class
 
-  if (atom) atom->delete_callback(id,0);
-  if (atom) atom->delete_callback(id,1);
+  atom->delete_callback(id,0);
+  atom->delete_callback(id,1);
 
   // delete locally stored arrays
 
@@ -167,32 +161,29 @@ int FixWallGran::setmask()
 
 void FixWallGran::init()
 {
-  // set constants that depend on pair style
-
-  Pair *anypair;
-  if (anypair = force->pair_match("gran/no_history")) {
-    historystyle = 0;
-    pairstyle = NO_HISTORY;
-    xkk = ((PairGranNoHistory *) anypair)->xkk;
-    xkkt = ((PairGranNoHistory *) anypair)->xkkt;
-  } else if (anypair = force->pair_match("gran/history")) {
-    historystyle = 1;
-    pairstyle = HISTORY;
-    xkk = ((PairGranHistory *) anypair)->xkk;
-    xkkt = ((PairGranHistory *) anypair)->xkkt;
-  } else if (anypair = force->pair_match("gran/hertzian")) {
-    historystyle = 1;
-    pairstyle = HERTZIAN;
-    xkk = ((PairGranHertzian *) anypair)->xkk;
-    xkkt = ((PairGranHertzian *) anypair)->xkkt;
-  } else
-    error->all("Fix wall/gran can only be used with granular pair style");
-
-  // friction coeffs
+  // insure use of granular pair_style
+  // set local values from Pair values
 
+  Pair *pair = force->pair_match("gran");
+  if (pair == NULL)
+    error->all("Fix wall/gran is incompatible with Pair style");
+  int itmp;
+  double tmp1,tmp2;
+  pair->extract_gran(&xkk,&tmp1,&tmp2,&itmp);
+
+  // same initialization as in pair_gran_history::init_style()
+
+  xkkt = xkk * 2.0/7.0;
   dt = update->dt;
+  double gammas = 0.5*gamman;
   gamman_dl = gamman/dt;
-  gammas_dl = 0.5*gamman_dl;
+  gammas_dl = gammas/dt;
+
+  // set pairstyle from granular pair style
+
+  if (force->pair_match("gran/no_history")) pairstyle = NO_HISTORY;
+  else if (force->pair_match("gran/history")) pairstyle = HISTORY;
+  else if (force->pair_match("gran/hertzian")) pairstyle = HERTZIAN;
 }
 
 /* ---------------------------------------------------------------------- */
@@ -274,7 +265,7 @@ void FixWallGran::post_force(int vflag)
       rsq = dx*dx + dy*dy + dz*dz;
 
       if (rsq > radius[i]*radius[i]) {
-	if (historystyle) {
+	if (pairstyle != NO_HISTORY) {
 	  shear[i][0] = 0.0;
 	  shear[i][1] = 0.0;
 	  shear[i][2] = 0.0;
diff --git a/src/GRANULAR/fix_wall_gran.h b/src/GRANULAR/fix_wall_gran.h
index 5b7d2b3307384eeb748a788c280981e15170a2cc..6ebfa4b19fbc353f0be3abd40c90e2fc57ab0a40 100644
--- a/src/GRANULAR/fix_wall_gran.h
+++ b/src/GRANULAR/fix_wall_gran.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,9 +16,11 @@
 
 #include "fix.h"
 
+namespace LAMMPS_NS {
+
 class FixWallGran : public Fix {
  public:
-  FixWallGran(int, char **);
+  FixWallGran(class LAMMPS *, int, char **);
   ~FixWallGran();
   int setmask();
   void init();
@@ -36,7 +38,7 @@ class FixWallGran : public Fix {
   int maxsize_restart();
 
  private:
-  int wallstyle,pairstyle,historystyle,wiggle,axis;
+  int wallstyle,pairstyle,wiggle,axis;
   double xkk,xkkt,gamman,xmu;
   double lo,hi,cylradius;
   double dt,gamman_dl,gammas_dl;
@@ -55,4 +57,6 @@ class FixWallGran : public Fix {
 		double *);
 };
 
+}
+
 #endif
diff --git a/src/GRANULAR/pair_gran_hertzian.cpp b/src/GRANULAR/pair_gran_hertzian.cpp
index 5180397114d84c7dffab803b2f16eb833767e531..87ba3d248b2aee807de1fbb6b7f741393e50c365 100644
--- a/src/GRANULAR/pair_gran_hertzian.cpp
+++ b/src/GRANULAR/pair_gran_hertzian.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -23,11 +23,20 @@
 #include "force.h"
 #include "neighbor.h"
 
+using namespace LAMMPS_NS;
+
 #define MIN(a,b) ((a) < (b) ? (a) : (b))
 #define MAX(a,b) ((a) > (b) ? (a) : (b))
 
 /* ---------------------------------------------------------------------- */
 
+PairGranHertzian::PairGranHertzian(LAMMPS *lmp) : PairGranHistory(lmp)
+{
+  history = 1;
+}
+
+/* ---------------------------------------------------------------------- */
+
 void PairGranHertzian::compute(int eflag, int vflag)
 {
   int i,j,k,numneigh;
diff --git a/src/GRANULAR/pair_gran_hertzian.h b/src/GRANULAR/pair_gran_hertzian.h
index 9a7504fe613f01805f11c14f6e110dc5d7e6b4e2..5dd1a4b7dc5e1b8bb8524df28e9054a8fad5d962 100644
--- a/src/GRANULAR/pair_gran_hertzian.h
+++ b/src/GRANULAR/pair_gran_hertzian.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,9 +16,14 @@
 
 #include "pair_gran_history.h"
 
+namespace LAMMPS_NS {
+
 class PairGranHertzian : public PairGranHistory {
  public:
+  PairGranHertzian(class LAMMPS *);
   void compute(int, int);
 };
 
+}
+
 #endif
diff --git a/src/GRANULAR/pair_gran_history.cpp b/src/GRANULAR/pair_gran_history.cpp
index 8c34eb6dc40d895c9bdf36a6ce65f2e414519359..541b0e995014f336037dfc17d1be19776a7ea08f 100644
--- a/src/GRANULAR/pair_gran_history.cpp
+++ b/src/GRANULAR/pair_gran_history.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -32,24 +32,27 @@
 #include "neighbor.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define MIN(a,b) ((a) < (b) ? (a) : (b))
 #define MAX(a,b) ((a) > (b) ? (a) : (b))
 
 /* ---------------------------------------------------------------------- */
 
-PairGranHistory::PairGranHistory()
+PairGranHistory::PairGranHistory(LAMMPS *lmp) : Pair(lmp)
 {
   single_enable = 0;
 
   for (int i = 0; i < 6; i++) virial[i] = 0.0;
-  ifix_history = -1;
+  history = 1;
+  fix_history = NULL;
 }
 
 /* ---------------------------------------------------------------------- */
 
 PairGranHistory::~PairGranHistory()
 {
-  if (ifix_history >= 0) modify->delete_fix("SHEAR_HISTORY");
+  if (fix_history) modify->delete_fix("SHEAR_HISTORY");
 
   if (allocated) {
     memory->destroy_2d_int_array(setflag);
@@ -335,32 +338,21 @@ void PairGranHistory::init_style()
   if (atom->check_style("granular") == 0)
     error->all("Must use atom style granular with pair style granular");
 
-  // for pair choices with shear history:
-  //   check if newton flag is valid
-  //   if first init, create Fix needed for storing shear history
+  // if shear history is stored:
+  // check if newton flag is valid
+  // if first init, create Fix needed for storing shear history
 
-  int history = 0;
-  if (force->pair_match("gran/history") || force->pair_match("gran/hertzian"))
-    history = 1;
-  
   if (history && force->newton_pair == 1)
     error->all("Potential with shear history requires newton pair off");
 
-  if (history && ifix_history == -1) {
+  if (history && fix_history == NULL) {
     char **fixarg = new char*[3];
     fixarg[0] = "SHEAR_HISTORY";
     fixarg[1] = "all";
     fixarg[2] = "SHEAR_HISTORY";
     modify->add_fix(3,fixarg);
     delete [] fixarg;
-  }
-
-  // find associated SHEAR_HISTORY fix that must exist
-  // could have changed locations in fix list since created
-
-  if (history) {
-    for (i = 0; i < modify->nfix; i++)
-      if (strcmp(modify->fix[i]->style,"SHEAR_HISTORY") == 0) ifix_history = i;
+    fix_history = (FixShearHistory *) modify->fix[modify->nfix-1];
   }
 
   // check for freeze Fix and set freeze_group_bit
@@ -452,3 +444,14 @@ void PairGranHistory::read_restart_settings(FILE *fp)
   MPI_Bcast(&xmu,1,MPI_DOUBLE,0,world);
   MPI_Bcast(&dampflag,1,MPI_INT,0,world);
 }
+
+/* ---------------------------------------------------------------------- */
+
+void PairGranHistory::extract_gran(double *p_xkk, double *p_gamman,
+				   double *p_xmu, int *p_dampflag)
+{
+  *p_xkk = xkk;
+  *p_gamman = gamman;
+  *p_xmu = xmu;
+  *p_dampflag = dampflag;
+}
diff --git a/src/GRANULAR/pair_gran_history.h b/src/GRANULAR/pair_gran_history.h
index 60f2329082d403bd0e50e9c75d167595122e99af..0ad8bb3b57c9df4f000bb95a46b3f2ce84795b5f 100644
--- a/src/GRANULAR/pair_gran_history.h
+++ b/src/GRANULAR/pair_gran_history.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,13 +16,11 @@
 
 #include "pair.h"
 
-class PairGranHistory : public Pair {
-  friend class Neighbor;
-  friend class FixWallGran;
-  friend class FixGranDiag;
+namespace LAMMPS_NS {
 
+class PairGranHistory : public Pair {
  public:
-  PairGranHistory();
+  PairGranHistory(class LAMMPS *);
   ~PairGranHistory();
   virtual void compute(int, int);
   void settings(int, char **);
@@ -34,14 +32,20 @@ class PairGranHistory : public Pair {
   void write_restart_settings(FILE *);
   void read_restart_settings(FILE *);
 
+  void extract_gran(double *, double *, double *, int *);
+
  protected:
   double xkk,xkkt,xmu;
   int dampflag;
   double gamman;
   double dt,gamman_dl,gammas_dl;
-  int ifix_history,freeze_group_bit;
+  int freeze_group_bit;
+  int history;
+  class FixShearHistory *fix_history;
 
   void allocate();
 };
 
+}
+
 #endif
diff --git a/src/GRANULAR/pair_gran_no_history.cpp b/src/GRANULAR/pair_gran_no_history.cpp
index 0e2a7a94e85607d5035da234e4a72c11554ce295..4542e260480c2b7dedcc0de5a91231e85f9f9182 100644
--- a/src/GRANULAR/pair_gran_no_history.cpp
+++ b/src/GRANULAR/pair_gran_no_history.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -23,11 +23,20 @@
 #include "force.h"
 #include "neighbor.h"
 
+using namespace LAMMPS_NS;
+
 #define MIN(a,b) ((a) < (b) ? (a) : (b))
 #define MAX(a,b) ((a) > (b) ? (a) : (b))
 
 /* ---------------------------------------------------------------------- */
 
+PairGranNoHistory::PairGranNoHistory(LAMMPS *lmp) : PairGranHistory(lmp)
+{
+  history = 0;
+}
+
+/* ---------------------------------------------------------------------- */
+
 void PairGranNoHistory::compute(int eflag, int vflag)
 {
   int i,j,k,numneigh;
diff --git a/src/GRANULAR/pair_gran_no_history.h b/src/GRANULAR/pair_gran_no_history.h
index d3d2e74c1a1176c668b7a6272cb386b5185be084..613200448eb3e914957adbb9a037532269955357 100644
--- a/src/GRANULAR/pair_gran_no_history.h
+++ b/src/GRANULAR/pair_gran_no_history.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,9 +16,14 @@
 
 #include "pair_gran_history.h"
 
+namespace LAMMPS_NS {
+
 class PairGranNoHistory : public PairGranHistory {
  public:
+  PairGranNoHistory(class LAMMPS *);
   void compute(int, int);
 };
 
+}
+
 #endif
diff --git a/src/GRANULAR/style_granular.h b/src/GRANULAR/style_granular.h
index b221551953836ac26d696e6b63e5310ecf72156d..7b0f4b6a714a2398600707c7c1cc45233e469b38 100644
--- a/src/GRANULAR/style_granular.h
+++ b/src/GRANULAR/style_granular.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -12,11 +12,11 @@
 ------------------------------------------------------------------------- */
 
 #ifdef AtomInclude
-#include "atom_granular.h"
+#include "atom_vec_granular.h"
 #endif
 
 #ifdef AtomClass
-AtomStyle(granular,AtomGranular)
+AtomStyle(granular,AtomVecGranular)
 # endif
 
 #ifdef FixInclude
diff --git a/src/KSPACE/Install.csh b/src/KSPACE/Install.csh
index 8a58067c7c5cc100352a641d074071fdc56c5d4a..56460813043d6732e5e725754a222ec710eda368 100644
--- a/src/KSPACE/Install.csh
+++ b/src/KSPACE/Install.csh
@@ -1,7 +1,5 @@
 # Install/unInstall package classes in LAMMPS
 
-# pair_lj_charmm_coul_long.h must always be in src
-
 if ($1 == 1) then
 
   cp style_kspace.h ..
@@ -24,7 +22,7 @@ if ($1 == 1) then
   cp pair_buck_coul_long.h ..
   cp pair_lj_cut_coul_long.h ..
   cp pair_lj_cut_coul_long_tip4p.h ..
-#  cp pair_lj_charmm_coul_long.h ..
+  cp pair_lj_charmm_coul_long.h ..
   cp fft3d.h ..
   cp fft3d_wrap.h ..
   cp remap.h ..
@@ -53,7 +51,7 @@ else if ($1 == 0) then
   rm ../pair_buck_coul_long.h
   rm ../pair_lj_cut_coul_long.h
   rm ../pair_lj_cut_coul_long_tip4p.h
-#  rm ../pair_lj_charmm_coul_long.h
+  rm ../pair_lj_charmm_coul_long.h
   rm ../fft3d.h
   rm ../fft3d_wrap.h
   rm ../remap.h
diff --git a/src/KSPACE/ewald.cpp b/src/KSPACE/ewald.cpp
index 202a6779997a58428af1c0c2c8245160de56d986..821c2191bfbfd0c0eed2214dc6c3165608f04ef8 100644
--- a/src/KSPACE/ewald.cpp
+++ b/src/KSPACE/ewald.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -23,21 +23,19 @@
 #include "atom.h"
 #include "comm.h"
 #include "force.h"
-#include "pair_buck_coul_long.h"
-#include "pair_lj_cut_coul_long.h"
-#include "pair_lj_charmm_coul_long.h"
-#include "pair_lj_class2_coul_long.h"
-#include "pair_table.h"
+#include "pair.h"
 #include "domain.h"
 #include "memory.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define MIN(a,b) ((a) < (b) ? (a) : (b))
 #define MAX(a,b) ((a) > (b) ? (a) : (b))
 
 /* ---------------------------------------------------------------------- */
 
-Ewald::Ewald(int narg, char **arg) : KSpace(narg, arg)
+Ewald::Ewald(LAMMPS *lmp, int narg, char **arg) : KSpace(lmp, narg, arg)
 {
   if (narg != 1) error->all("Illegal kspace_style ewald command");
 
@@ -90,27 +88,16 @@ void Ewald::init()
       error->all("Incorrect boundaries with slab Ewald");
   }
 
-  // insure use of pair_style with long-range Coulombics
-  // set cutoff to short-range Coulombic cutoff
+  // insure use of long (or table) pair_style with long-range Coulombics
+  // set cutoff to Pair's short-range Coulombic cutoff
 
   qqrd2e = force->qqrd2e;
 
+  Pair *pair = force->pair_match("long");
+  if (pair == NULL) pair = force->pair_match("table");
+  if (pair == NULL) error->all("KSpace style is incompatible with Pair style");
   double cutoff;
-
-  Pair *anypair;
-  if (force->pair == NULL) 
-    error->all("KSpace style is incompatible with Pair style");
-  else if (anypair = force->pair_match("buck/coul/long"))
-    cutoff = ((PairBuckCoulLong *) anypair)->cut_coul;
-  else if (anypair = force->pair_match("lj/cut/coul/long"))
-    cutoff = ((PairLJCutCoulLong *) anypair)->cut_coul;
-  else if (anypair = force->pair_match("lj/charmm/coul/long"))
-    cutoff = ((PairLJCharmmCoulLong *) anypair)->cut_coul;
-  else if (anypair = force->pair_match("lj/class2/coul/long"))
-    cutoff = ((PairLJClass2CoulLong *) anypair)->cut_coul;
-  else if (anypair = force->pair_match("table"))
-    cutoff = ((PairTable *) anypair)->cut_coul();
-  else error->all("KSpace style is incompatible with Pair style");
+  pair->extract_long(&cutoff);
 
   // compute qsum & qsqsum
 
diff --git a/src/KSPACE/ewald.h b/src/KSPACE/ewald.h
index cbd28c5693d0ff847d19ab91a427acb576dc020d..e6f5a1a19f516951f0d80e6c1b456a65a0120771 100644
--- a/src/KSPACE/ewald.h
+++ b/src/KSPACE/ewald.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,9 +16,11 @@
 
 #include "kspace.h"
 
+namespace LAMMPS_NS {
+
 class Ewald : public KSpace {
  public:
-  Ewald(int, char **);
+  Ewald(class LAMMPS *, int, char **);
   ~Ewald();
   void init();
   void setup();
@@ -49,4 +51,6 @@ class Ewald : public KSpace {
 };
 
 #endif
+}
+
 
diff --git a/src/KSPACE/fft3d.cpp b/src/KSPACE/fft3d.cpp
index 3af1923d1524a21e43b8fe2bfb7dfbd71dd8c5f9..63fa8fff1c028dc2bd5908d160ecc1c1b338db57 100644
--- a/src/KSPACE/fft3d.cpp
+++ b/src/KSPACE/fft3d.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
diff --git a/src/KSPACE/fft3d.h b/src/KSPACE/fft3d.h
index eb4a179db3140f07dc1221386d0cde206e5f1aa4..3c3c9adb9325e186a1f0a32a7e3b6c71aeab7e6c 100644
--- a/src/KSPACE/fft3d.h
+++ b/src/KSPACE/fft3d.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
diff --git a/src/KSPACE/fft3d_wrap.cpp b/src/KSPACE/fft3d_wrap.cpp
index af72fdf4a23ef741b2cbfefc44203d16d49ce23b..4f15a87a76418722baac1a1ae242cb5e88df58b3 100644
--- a/src/KSPACE/fft3d_wrap.cpp
+++ b/src/KSPACE/fft3d_wrap.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -15,14 +15,16 @@
 #include "fft3d_wrap.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 /* ---------------------------------------------------------------------- */
 
-FFT3d::FFT3d(MPI_Comm comm, int nfast, int nmid, int nslow,
+FFT3d::FFT3d(LAMMPS *lmp, MPI_Comm comm, int nfast, int nmid, int nslow,
 	     int in_ilo, int in_ihi, int in_jlo, int in_jhi,
 	     int in_klo, int in_khi,
 	     int out_ilo, int out_ihi, int out_jlo, int out_jhi,
 	     int out_klo, int out_khi,
-	     int scaled, int permute, int *nbuf)
+	     int scaled, int permute, int *nbuf) : Pointers(lmp)
 {
   plan = fft_3d_create_plan(comm,nfast,nmid,nslow,
 			    in_ilo,in_ihi,in_jlo,in_jhi,in_klo,in_khi,
diff --git a/src/KSPACE/fft3d_wrap.h b/src/KSPACE/fft3d_wrap.h
index 2d32e346266b030e4eb4b5bae17106206958e0de..0b55fe32f6b9e71be561d5fbae08533af6be4a97 100644
--- a/src/KSPACE/fft3d_wrap.h
+++ b/src/KSPACE/fft3d_wrap.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -14,12 +14,14 @@
 #ifndef FFT3D_WRAP_H
 #define FFT3D_WRAP_H
 
-#include "lammps.h"
+#include "pointers.h"
 #include "fft3d.h"
 
-class FFT3d : public LAMMPS {
+namespace LAMMPS_NS {
+
+class FFT3d : protected Pointers {
  public:
-  FFT3d(MPI_Comm,int,int,int,int,int,int,int,int,int,
+  FFT3d(class LAMMPS *, MPI_Comm,int,int,int,int,int,int,int,int,int,
 	int,int,int,int,int,int,int,int,int *);
   ~FFT3d();
   void compute(double *, double *, int);
@@ -29,4 +31,6 @@ class FFT3d : public LAMMPS {
   struct fft_plan_3d *plan;
 };
 
+}
+
 #endif
diff --git a/src/KSPACE/pair_buck_coul_long.cpp b/src/KSPACE/pair_buck_coul_long.cpp
index 450fcb5efa52c6e88ad1c333f0c0af15206d9182..6c5ab74e543d7d9429be54ade2ef148081b9389c 100644
--- a/src/KSPACE/pair_buck_coul_long.cpp
+++ b/src/KSPACE/pair_buck_coul_long.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -25,6 +25,8 @@
 #include "neighbor.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define MIN(a,b) ((a) < (b) ? (a) : (b))
 #define MAX(a,b) ((a) > (b) ? (a) : (b))
 
@@ -36,9 +38,11 @@
 #define A4       -1.453152027
 #define A5        1.061405429
 
-/* ----------------------------------------------------------------------
-   free all arrays
-------------------------------------------------------------------------- */
+/* ---------------------------------------------------------------------- */
+
+PairBuckCoulLong::PairBuckCoulLong(LAMMPS *lmp) : Pair(lmp) {}
+
+/* ---------------------------------------------------------------------- */
 
 PairBuckCoulLong::~PairBuckCoulLong()
 {
@@ -305,7 +309,7 @@ void PairBuckCoulLong::init_style()
 {
   // require an atom style with charge defined
 
-  if (atom->charge_allow == 0)
+  if (atom->q == NULL)
     error->all("Must use charged atom style with this pair style");
 
   cut_coulsq = cut_coul * cut_coul;
@@ -444,3 +448,11 @@ void PairBuckCoulLong::single(int i, int j, int itype, int jtype,
     } else one.eng_vdwl = 0.0;
   }
 }
+
+/* ---------------------------------------------------------------------- */
+
+void PairBuckCoulLong::extract_long(double *p_cut_coul)
+{
+  *p_cut_coul = cut_coul;
+}
+
diff --git a/src/KSPACE/pair_buck_coul_long.h b/src/KSPACE/pair_buck_coul_long.h
index 0f87844fa8d22fb4d737ac25acdc3370f494fff0..5b3886efd8696956f4154ffda267d9e3a87f8685 100644
--- a/src/KSPACE/pair_buck_coul_long.h
+++ b/src/KSPACE/pair_buck_coul_long.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,11 +16,11 @@
 
 #include "pair.h"
 
+namespace LAMMPS_NS {
+
 class PairBuckCoulLong : public Pair {
  public:
-  double cut_coul;
-
-  PairBuckCoulLong() {}
+  PairBuckCoulLong(class LAMMPS *);
   ~PairBuckCoulLong();
   void compute(int, int);
   void settings(int, char **);
@@ -33,10 +33,12 @@ class PairBuckCoulLong : public Pair {
   void read_restart_settings(FILE *);
   void single(int, int, int, int, double, double, double, int, One &);
 
+  void extract_long(double *);
+
  private:
   double cut_lj_global;
   double **cut_lj,**cut_ljsq;
-  double cut_coulsq;
+  double cut_coul,cut_coulsq;
   double **a,**rho,**c;
   double **rhoinv,**buck1,**buck2,**offset;
   double g_ewald;
@@ -44,4 +46,6 @@ class PairBuckCoulLong : public Pair {
   void allocate();
 };
 
+}
+
 #endif
diff --git a/src/KSPACE/pair_lj_charmm_coul_long.cpp b/src/KSPACE/pair_lj_charmm_coul_long.cpp
index 3247e0fbb6a7594287474073b2d6a12b480a954c..a0d3b40875638e152e8aa08e77c9d476f6b7da19 100644
--- a/src/KSPACE/pair_lj_charmm_coul_long.cpp
+++ b/src/KSPACE/pair_lj_charmm_coul_long.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -31,6 +31,8 @@
 #include "neighbor.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define MIN(a,b) ((a) < (b) ? (a) : (b))
 #define MAX(a,b) ((a) > (b) ? (a) : (b))
 
@@ -44,7 +46,7 @@
 
 /* ---------------------------------------------------------------------- */
 
-PairLJCharmmCoulLong::PairLJCharmmCoulLong()
+PairLJCharmmCoulLong::PairLJCharmmCoulLong(LAMMPS *lmp) : Pair(lmp)
 {
   respa_enable = 1;
   ftable = NULL;
@@ -763,7 +765,7 @@ void PairLJCharmmCoulLong::init_style()
 {
   // require an atom style with charge defined
 
-  if (atom->charge_allow == 0)
+  if (atom->q == NULL)
     error->all("Must use charged atom style with this pair style");
 
   // require cut_lj_inner < cut_lj
@@ -1158,3 +1160,25 @@ void PairLJCharmmCoulLong::single(int i, int j, int itype, int jtype,
     } else one.eng_vdwl = 0.0;
   }
 }
+
+/* ---------------------------------------------------------------------- */
+
+void PairLJCharmmCoulLong::extract_charmm(double ***p_lj14_1, 
+					  double ***p_lj14_2,
+					  double ***p_lj14_3,
+					  double ***p_lj14_4,
+					  int *p_implicit_flag)
+{
+  *p_lj14_1 = lj14_1;
+  *p_lj14_2 = lj14_2;
+  *p_lj14_3 = lj14_3;
+  *p_lj14_4 = lj14_4;
+  *p_implicit_flag = 0;
+}
+
+/* ---------------------------------------------------------------------- */
+
+void PairLJCharmmCoulLong::extract_long(double *p_cut_coul)
+{
+  *p_cut_coul = cut_coul;
+}
diff --git a/src/KSPACE/pair_lj_cut_coul_long.cpp b/src/KSPACE/pair_lj_cut_coul_long.cpp
index ced25d88e6c3f85ce86be728000b9b759c38b88d..5b776d69c5f87e13b4c76e763b42a3afbeabdf86 100644
--- a/src/KSPACE/pair_lj_cut_coul_long.cpp
+++ b/src/KSPACE/pair_lj_cut_coul_long.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -31,6 +31,8 @@
 #include "neighbor.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define MIN(a,b) ((a) < (b) ? (a) : (b))
 #define MAX(a,b) ((a) > (b) ? (a) : (b))
 
@@ -44,15 +46,13 @@
 
 /* ---------------------------------------------------------------------- */
 
-PairLJCutCoulLong::PairLJCutCoulLong()
+PairLJCutCoulLong::PairLJCutCoulLong(LAMMPS *lmp) : Pair(lmp)
 {
   respa_enable = 1;
   ftable = NULL;
 }
 
-/* ----------------------------------------------------------------------
-   free all arrays
-------------------------------------------------------------------------- */
+/* ---------------------------------------------------------------------- */
 
 PairLJCutCoulLong::~PairLJCutCoulLong()
 {
@@ -739,7 +739,7 @@ void PairLJCutCoulLong::init_style()
 
   // require an atom style with charge defined
 
-  if (atom->charge_allow == 0)
+  if (atom->q == NULL)
     error->all("Must use charged atom style with this pair style");
 
   cut_coulsq = cut_coul * cut_coul;
@@ -1102,3 +1102,10 @@ void PairLJCutCoulLong::single(int i, int j, int itype, int jtype,
     } else one.eng_vdwl = 0.0;
   }
 }
+
+/* ---------------------------------------------------------------------- */
+
+void PairLJCutCoulLong::extract_long(double *p_cut_coul)
+{
+  *p_cut_coul = cut_coul;
+}
diff --git a/src/KSPACE/pair_lj_cut_coul_long.h b/src/KSPACE/pair_lj_cut_coul_long.h
index bb5827489b66a460f74739653d239e3695299cd1..6870b631976096d792c450d5217072643328cda8 100644
--- a/src/KSPACE/pair_lj_cut_coul_long.h
+++ b/src/KSPACE/pair_lj_cut_coul_long.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,11 +16,11 @@
 
 #include "pair.h"
 
+namespace LAMMPS_NS {
+
 class PairLJCutCoulLong : public Pair {
  public:
-  double cut_coul;
-
-  PairLJCutCoulLong();
+  PairLJCutCoulLong(class LAMMPS *);
   ~PairLJCutCoulLong();
   virtual void compute(int, int);
   virtual void settings(int, char **);
@@ -36,11 +36,12 @@ class PairLJCutCoulLong : public Pair {
   void compute_inner();
   void compute_middle();
   void compute_outer(int, int);
+  void extract_long(double *);
 
  protected:
   double cut_lj_global;
   double **cut_lj,**cut_ljsq;
-  double cut_coulsq;
+  double cut_coul,cut_coulsq;
   double **epsilon,**sigma;
   double **lj1,**lj2,**lj3,**lj4,**offset;
   double *cut_respa;
@@ -56,4 +57,6 @@ class PairLJCutCoulLong : public Pair {
   void free_tables();
 };
 
+}
+
 #endif
diff --git a/src/KSPACE/pair_lj_cut_coul_long_tip4p.cpp b/src/KSPACE/pair_lj_cut_coul_long_tip4p.cpp
index 151573bed7d5671a44d38b1bd77f91609a52a866..3c37218a92051c09bd8ecdd67ef2faaf91d9d6c0 100644
--- a/src/KSPACE/pair_lj_cut_coul_long_tip4p.cpp
+++ b/src/KSPACE/pair_lj_cut_coul_long_tip4p.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -33,6 +33,8 @@
 #include "neighbor.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define MIN(a,b) ((a) < (b) ? (a) : (b))
 #define MAX(a,b) ((a) > (b) ? (a) : (b))
 
@@ -46,7 +48,8 @@
 
 /* ---------------------------------------------------------------------- */
 
-PairLJCutCoulLongTIP4P::PairLJCutCoulLongTIP4P()
+PairLJCutCoulLongTIP4P::PairLJCutCoulLongTIP4P(LAMMPS *lmp) : 
+  PairLJCutCoulLong(lmp)
 {
   single_enable = 0;
 }
@@ -407,7 +410,7 @@ void PairLJCutCoulLongTIP4P::init_style()
     error->all("Pair style lj/cut/coul/long/tip4p requires atom IDs");
   if (!force->newton_pair) 
     error->all("Pair style lj/cut/coul/long/tip4p requires newton pair on");
-  if (atom->charge_allow == 0)
+  if (atom->q == NULL)
     error->all("Must use charged atom style with this pair style");
 
   cut_coulsq = cut_coul * cut_coul;
@@ -526,3 +529,16 @@ void PairLJCutCoulLongTIP4P::find_M(int i, int &iH1, int &iH2, double *xM)
   xM[1] = x[i][1] + alpha * (dely1 + dely2);
   xM[2] = x[i][2] + alpha * (delz1 + delz2);
 }
+
+/* ---------------------------------------------------------------------- */
+
+void PairLJCutCoulLongTIP4P::extract_tip4p(double *p_qdist, 
+					   int *p_typeO, int *p_typeH,
+					   int *p_typeA, int *p_typeB)
+{
+  *p_qdist = qdist;
+  *p_typeO = typeO;
+  *p_typeH = typeH;
+  *p_typeA = typeA;
+  *p_typeB = typeB;
+}
diff --git a/src/KSPACE/pair_lj_cut_coul_long_tip4p.h b/src/KSPACE/pair_lj_cut_coul_long_tip4p.h
index e7873ebe98c161b8b0aca1ea487b70894ff16ef1..487781d90b97813aafdef21f302071ce95129e0f 100644
--- a/src/KSPACE/pair_lj_cut_coul_long_tip4p.h
+++ b/src/KSPACE/pair_lj_cut_coul_long_tip4p.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,17 +16,19 @@
 
 #include "pair_lj_cut_coul_long.h"
 
+namespace LAMMPS_NS {
+
 class PairLJCutCoulLongTIP4P : public PairLJCutCoulLong {
-  friend class PPPM; 
-  
  public:
-  PairLJCutCoulLongTIP4P();
+  PairLJCutCoulLongTIP4P(class LAMMPS *);
   void compute(int, int);
   void settings(int, char **);
   void init_style();
   void write_restart_settings(FILE *fp);
   void read_restart_settings(FILE *fp);
 
+  void extract_tip4p(double *, int *, int *, int *, int *);
+
  private:
   int typeH,typeO;             // atom types of TIP4P water H and O atoms
   int typeA,typeB;             // angle and bond types of TIP4P water
@@ -38,4 +40,6 @@ class PairLJCutCoulLongTIP4P : public PairLJCutCoulLong {
   void find_M(int, int &, int &, double *);
 };
 
+}
+
 #endif
diff --git a/src/KSPACE/pppm.cpp b/src/KSPACE/pppm.cpp
index ad47238fdf87b0586529ca53c30f5cd96c4e4a1d..3bd78573818326e9dc9001b8c4113b1a4d163b93 100644
--- a/src/KSPACE/pppm.cpp
+++ b/src/KSPACE/pppm.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -25,12 +25,7 @@
 #include "comm.h"
 #include "neighbor.h"
 #include "force.h"
-#include "pair_buck_coul_long.h"
-#include "pair_lj_cut_coul_long.h"
-#include "pair_lj_charmm_coul_long.h"
-#include "pair_lj_class2_coul_long.h"
-#include "pair_lj_cut_coul_long_tip4p.h"
-#include "pair_table.h"
+#include "pair.h"
 #include "bond.h"
 #include "angle.h"
 #include "domain.h"
@@ -39,6 +34,8 @@
 #include "memory.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define MIN(a,b) ((a) < (b) ? (a) : (b))
 #define MAX(a,b) ((a) > (b) ? (a) : (b))
 
@@ -50,7 +47,7 @@
 
 /* ---------------------------------------------------------------------- */
 
-PPPM::PPPM(int narg, char **arg) : KSpace(narg, arg)
+PPPM::PPPM(LAMMPS *lmp, int narg, char **arg) : KSpace(lmp, narg, arg)
 {
   if (narg != 1) error->all("Illegal kspace_style pppm command");
 
@@ -128,41 +125,35 @@ void PPPM::init()
 
   deallocate();
 
-  // insure use of valid pair_style with long-range Coulombics
-  // set cutoff to short-range Coulombic cutoff
+  // insure use of long (or table) pair_style with long-range Coulombics
+  // set cutoff to Pair's short-range Coulombic cutoff
 
   qqrd2e = force->qqrd2e;
+
+  Pair *pair = force->pair_match("long");
+  if (pair == NULL) pair = force->pair_match("table");
+  if (pair == NULL) error->all("KSpace style is incompatible with Pair style");
+  pair->extract_long(&cutoff);
+
+  // insure use of TIP4P pair_style with TIP4P long-range Coulombics
+  // set TIP4P params from Pair's params
+
   qdist = 0.0;
 
-  Pair *anypair;
-  if (force->pair == NULL) 
-    error->all("Pair style is incompatible with KSpace style");
-  else if (anypair = force->pair_match("buck/coul/long"))
-    cutoff = ((PairBuckCoulLong *) anypair)->cut_coul;
-  else if (anypair = force->pair_match("lj/cut/coul/long"))
-    cutoff = ((PairLJCutCoulLong *) anypair)->cut_coul;
-  else if (anypair = force->pair_match("lj/charmm/coul/long"))
-    cutoff = ((PairLJCharmmCoulLong *) anypair)->cut_coul;
-  else if (anypair = force->pair_match("lj/class2/coul/long"))
-    cutoff = ((PairLJClass2CoulLong *) anypair)->cut_coul;
-  else if (anypair = force->pair_match("lj/cut/coul/long/tip4p")) {
-    if (strcmp(force->kspace_style,"pppm/tip4p") != 0)
-      error->all("Pair style is incompatible with KSpace style");
-    cutoff = ((PairLJCutCoulLongTIP4P *) anypair)->cut_coul;
-    qdist = ((PairLJCutCoulLongTIP4P *) anypair)->qdist;
-    typeO = ((PairLJCutCoulLongTIP4P *) anypair)->typeO;
-    typeH = ((PairLJCutCoulLongTIP4P *) anypair)->typeH;
-    int typeA = ((PairLJCutCoulLongTIP4P *) anypair)->typeA;
-    int typeB = ((PairLJCutCoulLongTIP4P *) anypair)->typeB;
+  pair = force->pair_match("tip4p");
+  if (strcmp(force->kspace_style,"pppm/tip4p") != 0 && pair != NULL)
+    error->all("KSpace style is incompatible with Pair style");
+  if (strcmp(force->kspace_style,"pppm/tip4p") == 0 && pair == NULL)
+    error->all("KSpace style is incompatible with Pair style");
+  if (pair) {
+    int typeA,typeB;
+    pair->extract_tip4p(&qdist,&typeO,&typeH,&typeA,&typeB);
     if (force->angle == NULL || force->bond == NULL)
       error->all("Bond and angle potentials must be defined for TIP4P");
     double theta = force->angle->equilibrium_angle(typeA);
     double blen = force->bond->equilibrium_distance(typeB);
     alpha = qdist / (2.0 * cos(0.5*theta) * blen);
-  } 
-  else if (anypair = force->pair_match("table"))
-    cutoff = ((PairTable *) anypair)->cut_coul();
-  else error->all("Pair style is incompatible with KSpace style");
+  }
 
   // compute qsum & qsqsum and warn if not charge-neutral
 
@@ -698,17 +689,17 @@ void PPPM::allocate()
 
   int tmp;
 
-  fft1 = new FFT3d(world,nx_pppm,ny_pppm,nz_pppm,
+  fft1 = new FFT3d(lmp,world,nx_pppm,ny_pppm,nz_pppm,
 		   nxlo_fft,nxhi_fft,nylo_fft,nyhi_fft,nzlo_fft,nzhi_fft,
 		   nxlo_fft,nxhi_fft,nylo_fft,nyhi_fft,nzlo_fft,nzhi_fft,
 		   0,0,&tmp);
 
-  fft2 = new FFT3d(world,nx_pppm,ny_pppm,nz_pppm,
+  fft2 = new FFT3d(lmp,world,nx_pppm,ny_pppm,nz_pppm,
 		   nxlo_fft,nxhi_fft,nylo_fft,nyhi_fft,nzlo_fft,nzhi_fft,
 		   nxlo_in,nxhi_in,nylo_in,nyhi_in,nzlo_in,nzhi_in,
 		   0,0,&tmp);
 
-  remap = new Remap(world,
+  remap = new Remap(lmp,world,
 		    nxlo_in,nxhi_in,nylo_in,nyhi_in,nzlo_in,nzhi_in,
 		    nxlo_fft,nxhi_fft,nylo_fft,nyhi_fft,nzlo_fft,nzhi_fft,
 		    1,0,0,2);
diff --git a/src/KSPACE/pppm.h b/src/KSPACE/pppm.h
index f75009842684b16e334c5f63d88c2eed7a342c82..2acaa9f30b72b6cead4834fa62a4ad0ad83c1bc0 100644
--- a/src/KSPACE/pppm.h
+++ b/src/KSPACE/pppm.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,12 +16,11 @@
 
 #include "kspace.h"
 
-class FFT3d;
-class Remap;
+namespace LAMMPS_NS {
 
 class PPPM : public KSpace {
  public:
-  PPPM(int, char **);
+  PPPM(class LAMMPS *, int, char **);
   ~PPPM();
   void init();
   void setup();
@@ -61,8 +60,8 @@ class PPPM : public KSpace {
   double *gf_b;
   double **rho1d,**rho_coeff;
 
-  FFT3d *fft1,*fft2;
-  Remap *remap;
+  class FFT3d *fft1,*fft2;
+  class Remap *remap;
 
   int **part2grid;             // storage for particle -> grid mapping
   int nmax;
@@ -91,4 +90,6 @@ class PPPM : public KSpace {
   void slabcorr(int);
 };
 
+}
+
 #endif
diff --git a/src/KSPACE/pppm_tip4p.cpp b/src/KSPACE/pppm_tip4p.cpp
index b677629255a33040cb3ce3b9eb6010f9327a1fd3..3486e9528760f2543eb00083ca632949418c7465 100644
--- a/src/KSPACE/pppm_tip4p.cpp
+++ b/src/KSPACE/pppm_tip4p.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -22,11 +22,14 @@
 #include "memory.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define OFFSET 4096
 
 /* ---------------------------------------------------------------------- */
 
-PPPMTIP4P::PPPMTIP4P(int narg, char **arg) : PPPM(narg, arg) {}
+PPPMTIP4P::PPPMTIP4P(LAMMPS *lmp, int narg, char **arg) :
+  PPPM(lmp, narg, arg) {}
 
 /* ----------------------------------------------------------------------
    find center grid pt for each of my particles
diff --git a/src/KSPACE/pppm_tip4p.h b/src/KSPACE/pppm_tip4p.h
index c23ca062aeaa50b9f9b8b6ecbcaa13ee21236483..bda20d437a32f95842438f3598d42e041e828db7 100644
--- a/src/KSPACE/pppm_tip4p.h
+++ b/src/KSPACE/pppm_tip4p.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,9 +16,11 @@
 
 #include "pppm.h"
 
+namespace LAMMPS_NS {
+
 class PPPMTIP4P : public PPPM {
  public:
-  PPPMTIP4P(int, char **);
+  PPPMTIP4P(class LAMMPS *, int, char **);
 
  private:
   void particle_map();
@@ -28,4 +30,6 @@ class PPPMTIP4P : public PPPM {
   void find_M(int, int &, int &, double *); 
 };
 
+}
+
 #endif
diff --git a/src/KSPACE/remap.cpp b/src/KSPACE/remap.cpp
index 215dc5b6d392942903de59611a2a98b3000b5437..f30a2d97f2b379ecec37bb2e10eb366e07cbf8ed 100644
--- a/src/KSPACE/remap.cpp
+++ b/src/KSPACE/remap.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
diff --git a/src/KSPACE/remap.h b/src/KSPACE/remap.h
index 15bcdbe41ea8d9eb19ccf3613eb4b5b535d7a399..6788354c698916db0d0f793c85eae2eb3b2d17b0 100644
--- a/src/KSPACE/remap.h
+++ b/src/KSPACE/remap.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
diff --git a/src/KSPACE/remap_wrap.cpp b/src/KSPACE/remap_wrap.cpp
index 9c652ab0f4c150ce96bf628a0d60f5aa5d9bc921..d46df6be4831b9362362312f61530633bd5389b7 100644
--- a/src/KSPACE/remap_wrap.cpp
+++ b/src/KSPACE/remap_wrap.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -15,14 +15,16 @@
 #include "remap_wrap.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 /* ---------------------------------------------------------------------- */
 
-Remap::Remap(MPI_Comm comm,
+Remap::Remap(LAMMPS *lmp, MPI_Comm comm,
 	     int in_ilo, int in_ihi, int in_jlo, int in_jhi,
 	     int in_klo, int in_khi,
 	     int out_ilo, int out_ihi, int out_jlo, int out_jhi,
 	     int out_klo, int out_khi,
-	     int nqty, int permute, int memory, int precision)
+	     int nqty, int permute, int memory, int precision) : Pointers(lmp)
 {
   plan = remap_3d_create_plan(comm,
 			      in_ilo,in_ihi,in_jlo,in_jhi,in_klo,in_khi,
diff --git a/src/KSPACE/remap_wrap.h b/src/KSPACE/remap_wrap.h
index b27a3593228e6f1b2a971650c6ea146c29d4e9d0..6b4b9a192a00d5d0df4745f06930268b7d38702e 100644
--- a/src/KSPACE/remap_wrap.h
+++ b/src/KSPACE/remap_wrap.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -14,12 +14,14 @@
 #ifndef REMAP_WRAP_H
 #define REMAP_WRAP_H
 
-#include "lammps.h"
+#include "pointers.h"
 #include "remap.h"
 
-class Remap : public LAMMPS {
+namespace LAMMPS_NS {
+
+class Remap : protected Pointers {
  public:
-  Remap(MPI_Comm,int,int,int,int,int,int,
+  Remap(class LAMMPS *, MPI_Comm,int,int,int,int,int,int,
 	int,int,int,int,int,int,int,int,int,int);
   ~Remap();
   void perform(double *, double *, double *);
@@ -28,4 +30,6 @@ class Remap : public LAMMPS {
   struct remap_plan_3d *plan;
 };
 
+}
+
 #endif
diff --git a/src/KSPACE/style_kspace.h b/src/KSPACE/style_kspace.h
index c6ea29b73ba6eed64bbff0f68bafbfe53a3682af..52cae87bdb42ae3534b1c694b7fb9bbf1feb0d5c 100644
--- a/src/KSPACE/style_kspace.h
+++ b/src/KSPACE/style_kspace.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
diff --git a/src/MAKE/Makefile.linux b/src/MAKE/Makefile.linux
index c164a657808c58496df1e32921f7b7cbbea275cf..0a76f12580d489247fc890642b0d22f1652b8389 100755
--- a/src/MAKE/Makefile.linux
+++ b/src/MAKE/Makefile.linux
@@ -8,6 +8,8 @@ SHELL = /bin/sh
 CC =		icc
 CCFLAGS =	-O -I/home/sjplimp/tools/mpich/include \
 		-I/home/sjplimp/tools/fftw/include -DFFT_FFTW -DGZIP
+#CCFLAGS =	-O -restrict -I/home/sjplimp/tools/mpich/include \
+#		-I/home/sjplimp/tools/fftw/include -DFFT_FFTW -DGZIP
 DEPFLAGS =	-M
 LINK =		icc
 LINKFLAGS =	-O -L/home/sjplimp/tools/mpich/lib \
diff --git a/src/MANYBODY/Install.csh b/src/MANYBODY/Install.csh
index 8d98bca303ca34c834805f7c61a9a19d15d3409a..3ac57d2ba8c130a5d5df9667ff17e1afdb5cd062 100644
--- a/src/MANYBODY/Install.csh
+++ b/src/MANYBODY/Install.csh
@@ -1,7 +1,5 @@
 # Install/unInstall package classes in LAMMPS
 
-# pair_eam.h must always be in src
-
 if ($1 == 1) then
 
   cp style_manybody.h ..
@@ -12,7 +10,7 @@ if ($1 == 1) then
   cp pair_sw.cpp ..
   cp pair_tersoff.cpp ..
 
-#  cp pair_eam.h ..
+  cp pair_eam.h ..
   cp pair_eam_alloy.h ..
   cp pair_eam_fs.h ..
   cp pair_sw.h ..
@@ -29,7 +27,7 @@ else if ($1 == 0) then
   rm ../pair_sw.cpp
   rm ../pair_tersoff.cpp
 
-#  rm ../pair_eam.h
+  rm ../pair_eam.h
   rm ../pair_eam_alloy.h
   rm ../pair_eam_fs.h
   rm ../pair_sw.h
diff --git a/src/MANYBODY/pair_eam.cpp b/src/MANYBODY/pair_eam.cpp
index ac1e7e04f95a337347e94327fd993fcdbc7e4ed4..e6ace5cbd68cef8ecdcfccc1dbf99e72ec7f4a99 100644
--- a/src/MANYBODY/pair_eam.cpp
+++ b/src/MANYBODY/pair_eam.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -28,6 +28,8 @@
 #include "memory.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define MIN(a,b) ((a) < (b) ? (a) : (b))
 #define MAX(a,b) ((a) > (b) ? (a) : (b))
 
@@ -35,7 +37,7 @@
 
 /* ---------------------------------------------------------------------- */
 
-PairEAM::PairEAM()
+PairEAM::PairEAM(LAMMPS *lmp) : Pair(lmp)
 {
   nmax = 0;
   rho = NULL;
@@ -54,10 +56,14 @@ PairEAM::PairEAM()
   frho_spline = NULL;
   rhor_spline = NULL;
   z2r_spline = NULL;
+
+  // set comm size needed by this Pair
+
+  comm_forward = 1;
+  comm_reverse = 1;
 }
 
 /* ----------------------------------------------------------------------
-   free all arrays
    check if allocated, since class can be destructed when incomplete
 ------------------------------------------------------------------------- */
 
@@ -410,11 +416,6 @@ double PairEAM::init_one(int i, int j)
 
 void PairEAM::init_style()
 {
-  // set communication sizes in comm class
-
-  comm->maxforward_pair = MAX(comm->maxforward_pair,1);
-  comm->maxreverse_pair = MAX(comm->maxreverse_pair,1);
-
   // convert read-in file(s) to arrays and spline them
 
   file2array();
@@ -804,17 +805,16 @@ void PairEAM::single(int i, int j, int itype, int jtype,
 
 /* ---------------------------------------------------------------------- */
 
-void PairEAM::single_embed(int i, int itype, double &fpi,
-			   int eflag, double &phi)
+void PairEAM::single_embed(int i, int itype, double &phi)
 {
+  printf("AAA %d\n",i);
   double p = rho[i]*rdrho + 1.0;
   int m = static_cast<int> (p);
   m = MAX(1,MIN(m,nrho-1));
   p -= m;
   
   double *coeff = frho_spline[type2frho[itype]][m];
-  fpi = (coeff[0]*p + coeff[1])*p + coeff[2];
-  if (eflag) phi = ((coeff[3]*p + coeff[4])*p + coeff[5])*p + coeff[6];
+  phi = ((coeff[3]*p + coeff[4])*p + coeff[5])*p + coeff[6];
 }
 
 /* ---------------------------------------------------------------------- */
@@ -876,3 +876,14 @@ int PairEAM::memory_usage()
   int bytes = 2 * nmax * sizeof(double);
   return bytes;
 }
+
+/* ----------------------------------------------------------------------
+   swap fp array with one passed in by caller
+------------------------------------------------------------------------- */
+
+void PairEAM::extract_eam(double *fp_caller, double **fp_caller_hold)
+{
+  double *tmp = fp;
+  fp = fp_caller;
+  *fp_caller_hold = tmp;
+}
diff --git a/src/MANYBODY/pair_eam_alloy.cpp b/src/MANYBODY/pair_eam_alloy.cpp
index bfc2912e4f8ff486d24111ab318e30817208a61d..e676ee7f1801e9d3fff2b0991e6647900034dc89 100644
--- a/src/MANYBODY/pair_eam_alloy.cpp
+++ b/src/MANYBODY/pair_eam_alloy.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -24,8 +24,17 @@
 #include "memory.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define MAXLINE 1024
 
+/* ---------------------------------------------------------------------- */
+
+PairEAMAlloy::PairEAMAlloy(LAMMPS *lmp) : PairEAM(lmp)
+{
+  one_coeff = 1;
+}
+
 /* ----------------------------------------------------------------------
    set coeffs for one or more type pairs
    read DYNAMO setfl file
diff --git a/src/MANYBODY/pair_eam_alloy.h b/src/MANYBODY/pair_eam_alloy.h
index 7231de3db654eb5ff74d20dcbb2f351733dcade3..a95bf77f99a14a206ebfc838c98369dc54554bd3 100644
--- a/src/MANYBODY/pair_eam_alloy.h
+++ b/src/MANYBODY/pair_eam_alloy.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,13 +16,21 @@
 
 #include "pair_eam.h"
 
-class PairEAMAlloy : public PairEAM {
+namespace LAMMPS_NS {
+
+// use virtual public since this class is parent in multiple inheritance
+
+class PairEAMAlloy : virtual public PairEAM {
  public:
+  PairEAMAlloy(class LAMMPS *);
+  virtual ~PairEAMAlloy() {}
   void coeff(int, char **);
 
- private:
+ protected:
   void read_file(char *);
   void file2array();
 };
 
+}
+
 #endif
diff --git a/src/MANYBODY/pair_eam_fs.cpp b/src/MANYBODY/pair_eam_fs.cpp
index c5c6a6dfd73689023410538067ec7a380da35d41..198375c6c755346712304d57c92726cb5739cc77 100644
--- a/src/MANYBODY/pair_eam_fs.cpp
+++ b/src/MANYBODY/pair_eam_fs.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -24,8 +24,17 @@
 #include "memory.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define MAXLINE 1024
 
+/* ---------------------------------------------------------------------- */
+
+PairEAMFS::PairEAMFS(LAMMPS *lmp) : PairEAM(lmp)
+{
+  one_coeff = 1;
+}
+
 /* ----------------------------------------------------------------------
    set coeffs for one or more type pairs
    read EAM Finnis-Sinclair file
diff --git a/src/MANYBODY/pair_eam_fs.h b/src/MANYBODY/pair_eam_fs.h
index baa977b2dac19b849757c100fa1331daa67b0060..8a7808d7f0d39d3eded0438c4784c648762a2269 100644
--- a/src/MANYBODY/pair_eam_fs.h
+++ b/src/MANYBODY/pair_eam_fs.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,13 +16,21 @@
 
 #include "pair_eam.h"
 
-class PairEAMFS : public PairEAM {
+namespace LAMMPS_NS {
+
+// use virtual public since this class is parent in multiple inheritance
+
+class PairEAMFS : virtual public PairEAM {
  public:
+  PairEAMFS(class LAMMPS *);
+  virtual ~PairEAMFS() {}
   void coeff(int, char **);
 
- private:
+ protected:
   void read_file(char *);
   void file2array();
 };
 
+}
+
 #endif
diff --git a/src/MANYBODY/pair_sw.cpp b/src/MANYBODY/pair_sw.cpp
index a5d89292ff554fd70af1a59702a7f4788bcf0db8..e508a6dca346270fedc8e9f6fd971af75137d5f7 100755
--- a/src/MANYBODY/pair_sw.cpp
+++ b/src/MANYBODY/pair_sw.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -29,12 +29,14 @@
 #include "memory.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define MAXLINE 1024
 #define DELTA 4
 
 /* ---------------------------------------------------------------------- */
 
-PairSW::PairSW()
+PairSW::PairSW(LAMMPS *lmp) : Pair(lmp)
 {
   neigh_half_every = 0;
   neigh_full_every = 1;
@@ -50,7 +52,6 @@ PairSW::PairSW()
 }
 
 /* ----------------------------------------------------------------------
-   free all arrays
    check if allocated, since class can be destructed when incomplete
 ------------------------------------------------------------------------- */
 
@@ -211,7 +212,7 @@ void PairSW::settings(int narg, char **arg)
 
 void PairSW::coeff(int narg, char **arg)
 {
-  int i,j,m,n;
+  int i,j,n;
 
   if (!allocated) allocate();
 
@@ -325,7 +326,7 @@ void PairSW::read_file(char *file)
   // one set of params can span multiple lines
   // store params if all 3 element tags are in element list
 
-  int i,n,nwords,ielement,jelement,kelement;
+  int n,nwords,ielement,jelement,kelement;
   char line[MAXLINE],*ptr;
   int eof = 0;
 
@@ -491,7 +492,6 @@ void PairSW::twobody(Param *param, double rsq, double &fforce,
 		     int eflag, double &eng)
 {
   double r,rinvsq,rp,rq,rainv,rainvsq,expsrainv;
-  double delr[3];
 
   r = sqrt(rsq);
   rinvsq = 1.0/rsq;
diff --git a/src/MANYBODY/pair_sw.h b/src/MANYBODY/pair_sw.h
index 9695cd9d180888d64c3ba8ba9cb01198a41ed0cd..227dff558b67847a6158aa16d1fda2d778e95d93 100755
--- a/src/MANYBODY/pair_sw.h
+++ b/src/MANYBODY/pair_sw.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,9 +16,11 @@
 
 #include "pair.h"
 
+namespace LAMMPS_NS {
+
 class PairSW : public Pair {
  public:
-  PairSW();
+  PairSW(class LAMMPS *);
   ~PairSW();
   void compute(int, int);
   void settings(int, char **);
@@ -55,4 +57,6 @@ class PairSW : public Pair {
 		 double *, double *, int, double &);
 };
 
+}
+
 #endif
diff --git a/src/MANYBODY/pair_tersoff.cpp b/src/MANYBODY/pair_tersoff.cpp
index 63e232712082b1110e4f23b660ac5fddca7c9b8e..aeda1f1c48365e5397e5c63b65970f4d2f25b829 100755
--- a/src/MANYBODY/pair_tersoff.cpp
+++ b/src/MANYBODY/pair_tersoff.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -29,12 +29,14 @@
 #include "memory.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define MAXLINE 1024
 #define DELTA 4
 
 /* ---------------------------------------------------------------------- */
 
-PairTersoff::PairTersoff()
+PairTersoff::PairTersoff(LAMMPS *lmp) : Pair(lmp)
 {
   neigh_half_every = 0;
   neigh_full_every = 1;
@@ -53,7 +55,6 @@ PairTersoff::PairTersoff()
 }
 
 /* ----------------------------------------------------------------------
-   free all arrays
    check if allocated, since class can be destructed when incomplete
 ------------------------------------------------------------------------- */
 
@@ -248,7 +249,7 @@ void PairTersoff::settings(int narg, char **arg)
 
 void PairTersoff::coeff(int narg, char **arg)
 {
-  int i,j,m,n;
+  int i,j,n;
 
   if (!allocated) allocate();
 
@@ -361,7 +362,7 @@ void PairTersoff::read_file(char *file)
   // read each line out of file, skipping blank lines or leading '#'
   // store line of params if all 3 element tags are in element list
 
-  int i,n,nwords,ielement,jelement,kelement;
+  int n,nwords,ielement,jelement,kelement;
   char line[MAXLINE],*ptr;
   int eof = 0;
 
diff --git a/src/MANYBODY/pair_tersoff.h b/src/MANYBODY/pair_tersoff.h
index d5f243f46b79937c6813e8dc07ca192f772e6820..3b75e96f663646fbb03fd13aa154fc1d65799027 100755
--- a/src/MANYBODY/pair_tersoff.h
+++ b/src/MANYBODY/pair_tersoff.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,9 +16,11 @@
 
 #include "pair.h"
 
+namespace LAMMPS_NS {
+
 class PairTersoff : public Pair {
  public:
-  PairTersoff();
+  PairTersoff(class LAMMPS *);
   ~PairTersoff();
   void compute(int, int);
   void settings(int, char **);
@@ -85,4 +87,6 @@ class PairTersoff : public Pair {
   }
 };
 
+}
+
 #endif
diff --git a/src/MANYBODY/style_manybody.h b/src/MANYBODY/style_manybody.h
index 2ba8d7cfd1a35345afa80cbde8224d70ad1886f6..449895a530bda93bceec6121c7916241778dad46 100644
--- a/src/MANYBODY/style_manybody.h
+++ b/src/MANYBODY/style_manybody.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
diff --git a/src/MOLECULE/Install.csh b/src/MOLECULE/Install.csh
index 2e59b8d9f4bfe734f8c8c9a4744e8f1f64f5ec87..6dce325641414f0ad917df595df241dd22021353 100644
--- a/src/MOLECULE/Install.csh
+++ b/src/MOLECULE/Install.csh
@@ -13,10 +13,9 @@ if ($1 == 1) then
   cp angle_cosine_squared.cpp ..
   cp angle_harmonic.cpp ..
   cp angle_hybrid.cpp ..
-  cp atom_angle.cpp ..
-  cp atom_bond.cpp ..
-  cp atom_full.cpp ..
-  cp atom_molecular.cpp ..
+  cp atom_vec_angle.cpp ..
+  cp atom_vec_bond.cpp ..
+  cp atom_vec_molecular.cpp ..
   cp bond.cpp ..
   cp bond_fene.cpp ..
   cp bond_fene_expand.cpp ..
@@ -46,10 +45,9 @@ if ($1 == 1) then
   cp angle_cosine_squared.h ..
   cp angle_harmonic.h ..
   cp angle_hybrid.h ..
-  cp atom_angle.h ..
-  cp atom_bond.h ..
-  cp atom_full.h ..
-  cp atom_molecular.h ..
+  cp atom_vec_angle.h ..
+  cp atom_vec_bond.h ..
+  cp atom_vec_molecular.h ..
 #  cp bond.h ..
   cp bond_fene.h ..
   cp bond_fene_expand.h ..
@@ -84,10 +82,9 @@ else if ($1 == 0) then
   rm ../angle_cosine_squared.cpp
   rm ../angle_harmonic.cpp
   rm ../angle_hybrid.cpp
-  rm ../atom_angle.cpp
-  rm ../atom_bond.cpp
-  rm ../atom_full.cpp
-  rm ../atom_molecular.cpp
+  rm ../atom_vec_angle.cpp
+  rm ../atom_vec_bond.cpp
+  rm ../atom_vec_molecular.cpp
   rm ../bond.cpp
   rm ../bond_fene.cpp
   rm ../bond_fene_expand.cpp
@@ -117,10 +114,9 @@ else if ($1 == 0) then
   rm ../angle_cosine_squared.h
   rm ../angle_harmonic.h
   rm ../angle_hybrid.h
-  rm ../atom_angle.h
-  rm ../atom_bond.h
-  rm ../atom_full.h
-  rm ../atom_molecular.h
+  rm ../atom_vec_angle.h
+  rm ../atom_vec_bond.h
+  rm ../atom_vec_molecular.h
 #  rm ../bond.h
   rm ../bond_fene.h
   rm ../bond_fene_expand.h
diff --git a/src/MOLECULE/angle.cpp b/src/MOLECULE/angle.cpp
index 3b689700f9a124496d374bc2a288e0407f7d7b72..f42c92d12f3b42ebd80f25af68555c5beb2bee7f 100644
--- a/src/MOLECULE/angle.cpp
+++ b/src/MOLECULE/angle.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,9 +16,11 @@
 #include "atom.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 /* ---------------------------------------------------------------------- */
 
-Angle::Angle()
+Angle::Angle(LAMMPS *lmp) : Pointers(lmp)
 {
   allocated = 0;
   PI = 4.0*atan(1.0);
diff --git a/src/MOLECULE/angle_charmm.cpp b/src/MOLECULE/angle_charmm.cpp
index e23cd9684a08614915e031e41e6664ae44b10a81..84578bae6e1d3e8ae7a2fd5633820a663fc368a4 100644
--- a/src/MOLECULE/angle_charmm.cpp
+++ b/src/MOLECULE/angle_charmm.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -26,11 +26,15 @@
 #include "memory.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define SMALL 0.001
 
-/* ----------------------------------------------------------------------
-   free all arrays 
-------------------------------------------------------------------------- */
+/* ---------------------------------------------------------------------- */
+
+AngleCharmm::AngleCharmm(LAMMPS *lmp) : Angle(lmp) {}
+
+/* ---------------------------------------------------------------------- */
 
 AngleCharmm::~AngleCharmm()
 {
diff --git a/src/MOLECULE/angle_charmm.h b/src/MOLECULE/angle_charmm.h
index 278e8e2493da7e84245a38216d85b5983dba25a4..f9597b8e3b52731e6e7b8572be563b02f5cfeb1f 100644
--- a/src/MOLECULE/angle_charmm.h
+++ b/src/MOLECULE/angle_charmm.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -17,9 +17,11 @@
 #include "stdio.h"
 #include "angle.h"
 
+namespace LAMMPS_NS {
+
 class AngleCharmm : public Angle {
  public:
-  AngleCharmm() {}
+  AngleCharmm(class LAMMPS *);
   ~AngleCharmm();
   void compute(int, int);
   void coeff(int, int, char **);
@@ -34,4 +36,6 @@ class AngleCharmm : public Angle {
   void allocate();
 };
 
+}
+
 #endif
diff --git a/src/MOLECULE/angle_cosine.cpp b/src/MOLECULE/angle_cosine.cpp
index 6f33f0e7bac712619007137b8d4c120d323b827a..2226fc07c89e87d27c8dbb507e9f166e6713440c 100644
--- a/src/MOLECULE/angle_cosine.cpp
+++ b/src/MOLECULE/angle_cosine.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -22,11 +22,15 @@
 #include "memory.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define SMALL 0.001
 
-/* ----------------------------------------------------------------------
-   free all arrays 
-------------------------------------------------------------------------- */
+/* ---------------------------------------------------------------------- */
+
+AngleCosine::AngleCosine(LAMMPS *lmp) : Angle(lmp) {}
+
+/* ---------------------------------------------------------------------- */
 
 AngleCosine::~AngleCosine()
 {
diff --git a/src/MOLECULE/angle_cosine.h b/src/MOLECULE/angle_cosine.h
index 6adf7e684662668dbc8d9c5f498b3879d28c29b6..9c00a6abc61ff10912f6dff4a1a3f6becd728a35 100644
--- a/src/MOLECULE/angle_cosine.h
+++ b/src/MOLECULE/angle_cosine.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -17,9 +17,11 @@
 #include "stdio.h"
 #include "angle.h"
 
+namespace LAMMPS_NS {
+
 class AngleCosine : public Angle {
  public:
-  AngleCosine() {}
+  AngleCosine(class LAMMPS *);
   ~AngleCosine();
   void compute(int, int);
   void coeff(int, int, char **);
@@ -34,4 +36,6 @@ class AngleCosine : public Angle {
   void allocate();
 };
 
+}
+
 #endif
diff --git a/src/MOLECULE/angle_cosine_squared.cpp b/src/MOLECULE/angle_cosine_squared.cpp
index 581204cee44a181034ef6adfd01aea8091540e88..0b353d12cfa7ad041d2d6c86430b2d32e591a288 100644
--- a/src/MOLECULE/angle_cosine_squared.cpp
+++ b/src/MOLECULE/angle_cosine_squared.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -26,11 +26,15 @@
 #include "memory.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define SMALL 0.001
 
-/* ----------------------------------------------------------------------
-   free all arrays 
-------------------------------------------------------------------------- */
+/* ---------------------------------------------------------------------- */
+
+AngleCosineSquared::AngleCosineSquared(LAMMPS *lmp) : Angle(lmp) {}
+
+/* ---------------------------------------------------------------------- */
 
 AngleCosineSquared::~AngleCosineSquared()
 {
diff --git a/src/MOLECULE/angle_cosine_squared.h b/src/MOLECULE/angle_cosine_squared.h
index cc7ce9b14f42d4a93178091f6a593be2f5c3b19c..735073152d5d6e343513e3a4a2b9d9916d9003c3 100644
--- a/src/MOLECULE/angle_cosine_squared.h
+++ b/src/MOLECULE/angle_cosine_squared.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -17,9 +17,11 @@
 #include "stdio.h"
 #include "angle.h"
 
+namespace LAMMPS_NS {
+
 class AngleCosineSquared : public Angle {
  public:
-  AngleCosineSquared() {}
+  AngleCosineSquared(class LAMMPS *);
   ~AngleCosineSquared();
   void compute(int, int);
   void coeff(int, int, char **);
@@ -34,4 +36,6 @@ class AngleCosineSquared : public Angle {
   void allocate();
 };
 
+}
+
 #endif
diff --git a/src/MOLECULE/angle_harmonic.cpp b/src/MOLECULE/angle_harmonic.cpp
index 6b9b2a9ccf2b27c4994594751fc92f4ca18a68ef..e209a2de4926fe268d9f077202e5e21c7f600343 100644
--- a/src/MOLECULE/angle_harmonic.cpp
+++ b/src/MOLECULE/angle_harmonic.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -22,11 +22,15 @@
 #include "memory.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define SMALL 0.001
 
-/* ----------------------------------------------------------------------
-   free all arrays 
-------------------------------------------------------------------------- */
+/* ---------------------------------------------------------------------- */
+
+AngleHarmonic::AngleHarmonic(LAMMPS *lmp) : Angle(lmp) {}
+
+/* ---------------------------------------------------------------------- */
 
 AngleHarmonic::~AngleHarmonic()
 {
diff --git a/src/MOLECULE/angle_harmonic.h b/src/MOLECULE/angle_harmonic.h
index 8b097f9e1af2214a08ea72ffc1e1567b4560476d..78ba0550b880e62c0ed6dfea36f09b5f013191c8 100644
--- a/src/MOLECULE/angle_harmonic.h
+++ b/src/MOLECULE/angle_harmonic.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -17,9 +17,11 @@
 #include "stdio.h"
 #include "angle.h"
 
+namespace LAMMPS_NS {
+
 class AngleHarmonic : public Angle {
  public:
-  AngleHarmonic() {}
+  AngleHarmonic(class LAMMPS *);
   ~AngleHarmonic();
   void compute(int, int);
   void coeff(int, int, char **);
@@ -34,4 +36,6 @@ class AngleHarmonic : public Angle {
   void allocate();
 };
 
+}
+
 #endif
diff --git a/src/MOLECULE/angle_hybrid.cpp b/src/MOLECULE/angle_hybrid.cpp
index 12d7a0093e9cfe28200b0adfbbebb5201537ce5b..16fafe531b8d89a8ec218280dc3767122413989c 100644
--- a/src/MOLECULE/angle_hybrid.cpp
+++ b/src/MOLECULE/angle_hybrid.cpp
@@ -1,7 +1,7 @@
 /* -----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -22,20 +22,18 @@
 #include "memory.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define EXTRA 1000
 
-/* ----------------------------------------------------------------------
-   set all global defaults 
-------------------------------------------------------------------------- */
+/* ---------------------------------------------------------------------- */
 
-AngleHybrid::AngleHybrid()
+AngleHybrid::AngleHybrid(LAMMPS *lmp) : Angle(lmp)
 {
   nstyles = 0;
 }
 
-/* ----------------------------------------------------------------------
-   free all arrays
-------------------------------------------------------------------------- */
+/* ---------------------------------------------------------------------- */
 
 AngleHybrid::~AngleHybrid()
 {
diff --git a/src/MOLECULE/angle_hybrid.h b/src/MOLECULE/angle_hybrid.h
index 250238cfc3f47b4e7fb133cb4f01c1730d1d88a0..c8aa24294116a1f1025b37b4753abb06223538b4 100644
--- a/src/MOLECULE/angle_hybrid.h
+++ b/src/MOLECULE/angle_hybrid.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -17,9 +17,11 @@
 #include "stdio.h"
 #include "angle.h"
 
+namespace LAMMPS_NS {
+
 class AngleHybrid : public Angle {
  public:
-  AngleHybrid();
+  AngleHybrid(class LAMMPS *);
   ~AngleHybrid();
   void compute(int, int);
   void settings(int, char **);
@@ -43,4 +45,6 @@ class AngleHybrid : public Angle {
   void allocate();
 };
 
+}
+
 #endif
diff --git a/src/MOLECULE/bond.cpp b/src/MOLECULE/bond.cpp
index c12665806306e88175edc2b99c120ad826d77213..45f2444092a4c02d847f4e741eecb8b5ce2ad756 100644
--- a/src/MOLECULE/bond.cpp
+++ b/src/MOLECULE/bond.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,12 +16,14 @@
 #include "atom.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 /* -----------------------------------------------------------------------
    set bond contribution to Vdwl energy to 0.0
    a particular bond style can override this
 ------------------------------------------------------------------------- */
 
-Bond::Bond()
+Bond::Bond(LAMMPS *lmp) : Pointers(lmp)
 {
   allocated = 0;
   eng_vdwl = 0.0;
diff --git a/src/MOLECULE/bond_fene.cpp b/src/MOLECULE/bond_fene.cpp
index 0c516341a43ce101513a26945994dc27c7296e9d..3369dfef2596bf731dcd5663db90583a7367a8c4 100644
--- a/src/MOLECULE/bond_fene.cpp
+++ b/src/MOLECULE/bond_fene.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -23,16 +23,16 @@
 #include "memory.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 /* ---------------------------------------------------------------------- */
 
-BondFENE::BondFENE()
+BondFENE::BondFENE(LAMMPS *lmp) : Bond(lmp)
 {
   TWO_1_3 = pow(2.0,(1.0/3.0));
 }
 
-/* ----------------------------------------------------------------------
-   free all arrays 
-------------------------------------------------------------------------- */
+/* ---------------------------------------------------------------------- */
 
 BondFENE::~BondFENE()
 {
diff --git a/src/MOLECULE/bond_fene.h b/src/MOLECULE/bond_fene.h
index 43c997f92dcbc543fcf841e55bcfd86ed7517911..5a889de662f05e962ae1d26d987f65635b7069b1 100644
--- a/src/MOLECULE/bond_fene.h
+++ b/src/MOLECULE/bond_fene.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -17,9 +17,11 @@
 #include "stdio.h"
 #include "bond.h"
 
+namespace LAMMPS_NS {
+
 class BondFENE : public Bond {
  public:
-  BondFENE();
+  BondFENE(class LAMMPS *);
   ~BondFENE();
   void compute(int, int);
   void coeff(int, char **);
@@ -35,4 +37,6 @@ class BondFENE : public Bond {
   void allocate();
 };
 
+}
+
 #endif
diff --git a/src/MOLECULE/bond_fene_expand.cpp b/src/MOLECULE/bond_fene_expand.cpp
index 801ae110f87aa9f1170c4d2c6c5e194e6565cfd3..c9a4f738e04f7d5e16d990360441d170da9c5c0a 100644
--- a/src/MOLECULE/bond_fene_expand.cpp
+++ b/src/MOLECULE/bond_fene_expand.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -11,8 +11,6 @@
    See the README file in the top-level LAMMPS directory.
 ------------------------------------------------------------------------- */
 
-// FENE bond potential, with repulsive LJ, with shift
-
 #include "math.h"
 #include "stdlib.h"
 #include "bond_fene_expand.h"
@@ -25,18 +23,16 @@
 #include "memory.h"
 #include "error.h"
 
-/* ----------------------------------------------------------------------
-   set all global defaults 
-------------------------------------------------------------------------- */
+using namespace LAMMPS_NS;
+
+/* ---------------------------------------------------------------------- */
 
-BondFENEExpand::BondFENEExpand()
+BondFENEExpand::BondFENEExpand(LAMMPS *lmp) : Bond(lmp)
 {
   TWO_1_3 = pow(2.0,(1.0/3.0));
 }
 
-/* ----------------------------------------------------------------------
-   free all arrays 
-------------------------------------------------------------------------- */
+/* ---------------------------------------------------------------------- */
 
 BondFENEExpand::~BondFENEExpand()
 {
diff --git a/src/MOLECULE/bond_fene_expand.h b/src/MOLECULE/bond_fene_expand.h
index 0e7167b1c68abf519ff5b6e6c979de23408cd124..a9767770172bc0cb9f90e5adb478140fb7e7172f 100644
--- a/src/MOLECULE/bond_fene_expand.h
+++ b/src/MOLECULE/bond_fene_expand.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -17,9 +17,11 @@
 #include "stdio.h"
 #include "bond.h"
 
+namespace LAMMPS_NS {
+
 class BondFENEExpand : public Bond {
  public:
-  BondFENEExpand();
+  BondFENEExpand(class LAMMPS *);
   ~BondFENEExpand();
   void compute(int, int);
   void coeff(int, char **);
@@ -35,4 +37,6 @@ class BondFENEExpand : public Bond {
   void allocate();
 };
 
+}
+
 #endif
diff --git a/src/MOLECULE/bond_harmonic.cpp b/src/MOLECULE/bond_harmonic.cpp
index 4520ec0dfb7288a98ec728ce54fc04cb3c1691bf..dc56435432873362489f26739e97ec5ebad492f6 100644
--- a/src/MOLECULE/bond_harmonic.cpp
+++ b/src/MOLECULE/bond_harmonic.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -22,9 +22,13 @@
 #include "memory.h"
 #include "error.h"
 
-/* ----------------------------------------------------------------------
-   free all arrays 
-------------------------------------------------------------------------- */
+using namespace LAMMPS_NS;
+
+/* ---------------------------------------------------------------------- */
+
+BondHarmonic::BondHarmonic(LAMMPS *lmp) : Bond(lmp) {}
+
+/* ---------------------------------------------------------------------- */
 
 BondHarmonic::~BondHarmonic()
 {
diff --git a/src/MOLECULE/bond_harmonic.h b/src/MOLECULE/bond_harmonic.h
index 438df27e0b3119f2efdfa82c16630c7e4e9ac9e1..bb49bde73a8a79a20086efc171d3c430cf6e6681 100644
--- a/src/MOLECULE/bond_harmonic.h
+++ b/src/MOLECULE/bond_harmonic.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -17,9 +17,11 @@
 #include "stdio.h"
 #include "bond.h"
 
+namespace LAMMPS_NS {
+
 class BondHarmonic : public Bond {
  public:
-  BondHarmonic() {}
+  BondHarmonic(class LAMMPS *);
   ~BondHarmonic();
   void compute(int, int);
   void coeff(int, char **);
@@ -34,4 +36,6 @@ class BondHarmonic : public Bond {
   void allocate();
 };
 
+}
+
 #endif
diff --git a/src/MOLECULE/bond_hybrid.cpp b/src/MOLECULE/bond_hybrid.cpp
index ff9f7b4f3f8cbfc59fc53106a98a281845061021..db57aaabfad6c632499e67f0761dd83e2b46283c 100644
--- a/src/MOLECULE/bond_hybrid.cpp
+++ b/src/MOLECULE/bond_hybrid.cpp
@@ -1,7 +1,7 @@
 /* -----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -22,20 +22,18 @@
 #include "memory.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define EXTRA 1000
 
-/* ----------------------------------------------------------------------
-   set all global defaults 
-------------------------------------------------------------------------- */
+/* ---------------------------------------------------------------------- */
 
-BondHybrid::BondHybrid()
+BondHybrid::BondHybrid(LAMMPS *lmp) : Bond(lmp)
 {
   nstyles = 0;
 }
 
-/* ----------------------------------------------------------------------
-   free all arrays
-------------------------------------------------------------------------- */
+/* ---------------------------------------------------------------------- */
 
 BondHybrid::~BondHybrid()
 {
diff --git a/src/MOLECULE/bond_morse.cpp b/src/MOLECULE/bond_morse.cpp
index 5cd83b8a32ad2de537e1cfc5e55f9aad051fa0be..355206cae50b46fb9bffbeabf8804ba7fb043721 100644
--- a/src/MOLECULE/bond_morse.cpp
+++ b/src/MOLECULE/bond_morse.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -26,9 +26,13 @@
 #include "memory.h"
 #include "error.h"
 
-/* ----------------------------------------------------------------------
-   free all arrays 
-------------------------------------------------------------------------- */
+using namespace LAMMPS_NS;
+
+/* ---------------------------------------------------------------------- */
+
+BondMorse::BondMorse(LAMMPS *lmp) : Bond(lmp) {}
+
+/* ---------------------------------------------------------------------- */
 
 BondMorse::~BondMorse()
 {
diff --git a/src/MOLECULE/bond_morse.h b/src/MOLECULE/bond_morse.h
index 9ac1d4cbf32eaaaabfda6bc4226fd8f35104a3dc..f409ecb44d973bd92993fc0470cbdb75b5fc5530 100644
--- a/src/MOLECULE/bond_morse.h
+++ b/src/MOLECULE/bond_morse.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -17,9 +17,11 @@
 #include "stdio.h"
 #include "bond.h"
 
+namespace LAMMPS_NS {
+
 class BondMorse : public Bond {
  public:
-  BondMorse() {}
+  BondMorse(class LAMMPS *);
   ~BondMorse();
   void compute(int, int);
   void coeff(int, char **);
@@ -34,4 +36,6 @@ class BondMorse : public Bond {
   void allocate();
 };
 
+}
+
 #endif
diff --git a/src/MOLECULE/bond_nonlinear.cpp b/src/MOLECULE/bond_nonlinear.cpp
index f39e61f6651ccb9ff50004dcea9ae84c8f78d376..ee7f47252da784378280da888d66b666fdd538e5 100644
--- a/src/MOLECULE/bond_nonlinear.cpp
+++ b/src/MOLECULE/bond_nonlinear.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -22,9 +22,13 @@
 #include "memory.h"
 #include "error.h"
 
-/* ----------------------------------------------------------------------
-   free all arrays 
-------------------------------------------------------------------------- */
+using namespace LAMMPS_NS;
+
+/* ---------------------------------------------------------------------- */
+
+BondNonlinear::BondNonlinear(LAMMPS *lmp) : Bond(lmp) {}
+
+/* ---------------------------------------------------------------------- */
 
 BondNonlinear::~BondNonlinear()
 {
diff --git a/src/MOLECULE/bond_nonlinear.h b/src/MOLECULE/bond_nonlinear.h
index 952ddf1661460603b281df75d54d07198f0fda21..cef2f50d2e99e78523450bffaebc00c4b6d655c0 100644
--- a/src/MOLECULE/bond_nonlinear.h
+++ b/src/MOLECULE/bond_nonlinear.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -17,9 +17,11 @@
 #include "stdio.h"
 #include "bond.h"
 
+namespace LAMMPS_NS {
+
 class BondNonlinear : public Bond {
  public:
-  BondNonlinear() {}
+  BondNonlinear(class LAMMPS *);
   ~BondNonlinear();
   void compute(int, int);
   void coeff(int, char **);
@@ -34,4 +36,6 @@ class BondNonlinear : public Bond {
   void allocate();
 };
 
+}
+
 #endif
diff --git a/src/MOLECULE/bond_quartic.cpp b/src/MOLECULE/bond_quartic.cpp
index 6889837bddfd840317ddf006d5b32caba82c24ef..5d958f7da1e3fe7092378bb52f04c45291bcfbb1 100755
--- a/src/MOLECULE/bond_quartic.cpp
+++ b/src/MOLECULE/bond_quartic.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -28,16 +28,16 @@
 #include "memory.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 /* ---------------------------------------------------------------------- */
 
-BondQuartic::BondQuartic()
+BondQuartic::BondQuartic(LAMMPS *lmp) : Bond(lmp)
 {
   TWO_1_3 = pow(2.0,(1.0/3.0));
 }
 
-/* ----------------------------------------------------------------------
-   free all arrays 
-------------------------------------------------------------------------- */
+/* ---------------------------------------------------------------------- */
 
 BondQuartic::~BondQuartic()
 {
diff --git a/src/MOLECULE/bond_quartic.h b/src/MOLECULE/bond_quartic.h
index 7bc7f55f3a761d2c8252346d4cd3ff099992b5ac..d89fe7ff87ddb0b37d890d5e1e0751c18c579644 100644
--- a/src/MOLECULE/bond_quartic.h
+++ b/src/MOLECULE/bond_quartic.h
@@ -1,7 +1,7 @@
 /* -----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -17,9 +17,11 @@
 #include "stdio.h"
 #include "bond.h"
 
+namespace LAMMPS_NS {
+
 class BondQuartic : public Bond {
  public:
-  BondQuartic();
+  BondQuartic(class LAMMPS *);
   ~BondQuartic();
   void compute(int, int);
   void coeff(int, char **);
@@ -36,4 +38,6 @@ class BondQuartic : public Bond {
   void allocate();
 };
 
+}
+
 #endif
diff --git a/src/MOLECULE/dihedral.cpp b/src/MOLECULE/dihedral.cpp
index 49de307e3673f82c53909426421cb5610ef6b34f..d523aa2754571dca2b5304b14acee18bc2c535cb 100644
--- a/src/MOLECULE/dihedral.cpp
+++ b/src/MOLECULE/dihedral.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,12 +16,14 @@
 #include "atom.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 /* ----------------------------------------------------------------------
    set dihedral contribution to Vdwl and Coulombic energy to 0.0
    DihedralCharmm will override this
 ------------------------------------------------------------------------- */
 
-Dihedral::Dihedral()
+Dihedral::Dihedral(LAMMPS *lmp) : Pointers(lmp)
 {
   allocated = 0;
   eng_vdwl = eng_coul = 0.0;
diff --git a/src/MOLECULE/dihedral_charmm.cpp b/src/MOLECULE/dihedral_charmm.cpp
index 24198df7f1bb22b5d79bbfdef63a36e2cfda37ed..7587fa705e3926a1f090508b5b92ddf1e61e74f7 100644
--- a/src/MOLECULE/dihedral_charmm.cpp
+++ b/src/MOLECULE/dihedral_charmm.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -24,19 +24,21 @@
 #include "neighbor.h"
 #include "domain.h"
 #include "force.h"
-#include "pair_lj_charmm_coul_charmm.h"
-#include "pair_lj_charmm_coul_charmm_implicit.h"
-#include "pair_lj_charmm_coul_long.h"
+#include "pair.h"
 #include "update.h"
 #include "memory.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define TOLERANCE 0.05
 #define SMALL     0.001
 
-/* ----------------------------------------------------------------------
-   free all arrays 
-------------------------------------------------------------------------- */
+/* ---------------------------------------------------------------------- */
+
+DihedralCharmm::DihedralCharmm(LAMMPS *lmp) : Dihedral(lmp) {}
+
+/* ---------------------------------------------------------------------- */
 
 DihedralCharmm::~DihedralCharmm()
 {
@@ -273,7 +275,7 @@ void DihedralCharmm::compute(int eflag, int vflag)
       r2inv = 1.0/rsq;
       r6inv = r2inv*r2inv*r2inv;
 
-      if (implicitflag) forcecoul = qqrd2e * q[i1]*q[i4]*r2inv;
+      if (implicit_flag) forcecoul = qqrd2e * q[i1]*q[i4]*r2inv;
       else forcecoul = qqrd2e * q[i1]*q[i4]*sqrt(r2inv);
       forcelj = r6inv * (lj14_1[itype][jtype]*r6inv - lj14_2[itype][jtype]);
       fforce = weight[type] * (forcelj+forcecoul)*r2inv;
@@ -382,32 +384,14 @@ void DihedralCharmm::coeff(int which, int narg, char **arg)
 
 void DihedralCharmm::init_style()
 {
-  // set local ptrs to LJ 14 arrays setup by pair
-
-  Pair *anypair;
-  if (anypair = force->pair_match("lj/charmm/coul/charmm")) {
-    PairLJCharmmCoulCharmm *pair = (PairLJCharmmCoulCharmm *) anypair;
-    lj14_1 = pair->lj14_1;
-    lj14_2 = pair->lj14_2;
-    lj14_3 = pair->lj14_3;
-    lj14_4 = pair->lj14_4;
-    implicitflag = 0;
-  } else if (anypair = force->pair_match("lj/charmm/coul/charmm/implicit")) {
-    PairLJCharmmCoulCharmmImplicit *pair = 
-      (PairLJCharmmCoulCharmmImplicit *) anypair;
-    lj14_1 = pair->lj14_1;
-    lj14_2 = pair->lj14_2;
-    lj14_3 = pair->lj14_3;
-    lj14_4 = pair->lj14_4;
-    implicitflag = 1;
-  } else if (anypair = force->pair_match("lj/charmm/coul/long")) {
-    PairLJCharmmCoulLong *pair = (PairLJCharmmCoulLong *) anypair;
-    lj14_1 = pair->lj14_1;
-    lj14_2 = pair->lj14_2;
-    lj14_3 = pair->lj14_3;
-    lj14_4 = pair->lj14_4;
-    implicitflag = 0;
-  } else error->all("Pair style is incompatible with DihedralCharmm");
+  // insure use of Charmm pair_style
+  // set local ptrs to LJ 14 arrays setup by Pair
+
+  Pair *pair = force->pair_match("charmm");
+  if (pair == NULL)
+    error->all("Dihedral charmm is incompatible with Pair style");
+  double cutoff;
+  pair->extract_charmm(&lj14_1,&lj14_2,&lj14_3,&lj14_4,&implicit_flag);
 }
 
 /* ----------------------------------------------------------------------
diff --git a/src/MOLECULE/dihedral_charmm.h b/src/MOLECULE/dihedral_charmm.h
index 107818633d2cfb9110d2e532405a641236b984d2..a036c54875060806d67a1930b045a1c2f308debe 100644
--- a/src/MOLECULE/dihedral_charmm.h
+++ b/src/MOLECULE/dihedral_charmm.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -17,9 +17,11 @@
 #include "stdio.h"
 #include "dihedral.h"
 
+namespace LAMMPS_NS {
+
 class DihedralCharmm : public Dihedral {
  public:
-  DihedralCharmm() {}
+  DihedralCharmm(class LAMMPS *);
   ~DihedralCharmm();
   void compute(int, int);
   void coeff(int, int, char **);
@@ -31,9 +33,11 @@ class DihedralCharmm : public Dihedral {
   double *k,*weight,*cos_shift,*sin_shift;
   int *multiplicity,*shift;
   double **lj14_1,**lj14_2,**lj14_3,**lj14_4;
-  int implicitflag;
+  int implicit_flag;
 
   void allocate();
 };
 
+}
+
 #endif
diff --git a/src/MOLECULE/dihedral_harmonic.cpp b/src/MOLECULE/dihedral_harmonic.cpp
index 8762262bdf632db45a35ad192ea238ce6cfa05ee..6034c3d60c2229e4d5f7ae4a77482123750c95e8 100644
--- a/src/MOLECULE/dihedral_harmonic.cpp
+++ b/src/MOLECULE/dihedral_harmonic.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -28,12 +28,16 @@
 #include "memory.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define TOLERANCE 0.05
 #define SMALL     0.001
 
-/* ----------------------------------------------------------------------
-   free all arrays 
-------------------------------------------------------------------------- */
+/* ---------------------------------------------------------------------- */
+
+DihedralHarmonic::DihedralHarmonic(LAMMPS *lmp) : Dihedral(lmp) {}
+
+/* ---------------------------------------------------------------------- */
 
 DihedralHarmonic::~DihedralHarmonic()
 {
diff --git a/src/MOLECULE/dihedral_harmonic.h b/src/MOLECULE/dihedral_harmonic.h
index e0ddac0882a06249e69d49e3e86e934d733ab52b..22ca49de9a1eef0c27b806c1e50f9a55b1fbd88f 100644
--- a/src/MOLECULE/dihedral_harmonic.h
+++ b/src/MOLECULE/dihedral_harmonic.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -17,9 +17,11 @@
 #include "stdio.h"
 #include "dihedral.h"
 
+namespace LAMMPS_NS {
+
 class DihedralHarmonic : public Dihedral {
  public:
-  DihedralHarmonic() {}
+  DihedralHarmonic(class LAMMPS *);
   ~DihedralHarmonic();
   void compute(int, int);
   void coeff(int, int, char **);
@@ -33,4 +35,6 @@ class DihedralHarmonic : public Dihedral {
   void allocate();
 };
 
+}
+
 #endif
diff --git a/src/MOLECULE/dihedral_helix.cpp b/src/MOLECULE/dihedral_helix.cpp
index ba6f7c7e332fb017c49ddb9fc739d26711b47813..bf1b601a0b3bf5b7fd1d63c690c523b7db80d936 100644
--- a/src/MOLECULE/dihedral_helix.cpp
+++ b/src/MOLECULE/dihedral_helix.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -29,6 +29,8 @@
 #include "memory.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define MIN(A,B) ((A) < (B)) ? (A) : (B)
 #define MAX(A,B) ((A) > (B)) ? (A) : (B)
 
@@ -36,9 +38,11 @@
 #define SMALL     0.001
 #define SMALLER   0.00001
 
-/* ----------------------------------------------------------------------
-   free all arrays 
-------------------------------------------------------------------------- */
+/* ---------------------------------------------------------------------- */
+
+DihedralHelix::DihedralHelix(LAMMPS *lmp) : Dihedral(lmp) {}
+
+/* ---------------------------------------------------------------------- */
 
 DihedralHelix::~DihedralHelix()
 {
diff --git a/src/MOLECULE/dihedral_helix.h b/src/MOLECULE/dihedral_helix.h
index 85481b4318e489f0df403b2e27b82e1e2f7a6d49..9263773b6465c1dbfd60615b0e010c1924948a36 100644
--- a/src/MOLECULE/dihedral_helix.h
+++ b/src/MOLECULE/dihedral_helix.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -17,9 +17,11 @@
 #include "stdio.h"
 #include "dihedral.h"
 
+namespace LAMMPS_NS {
+
 class DihedralHelix : public Dihedral {
  public:
-  DihedralHelix() {}
+  DihedralHelix(class LAMMPS *);
   ~DihedralHelix();
   void compute(int, int);
   void coeff(int, int, char **);
@@ -32,4 +34,6 @@ class DihedralHelix : public Dihedral {
   void allocate();
 };
 
+}
+
 #endif
diff --git a/src/MOLECULE/dihedral_hybrid.cpp b/src/MOLECULE/dihedral_hybrid.cpp
index dea4ce72fcbe71762a14bd4db678e689fb4ea291..589b7aafcda6779a25352ba93bbeef5a8604d527 100644
--- a/src/MOLECULE/dihedral_hybrid.cpp
+++ b/src/MOLECULE/dihedral_hybrid.cpp
@@ -1,7 +1,7 @@
 /* -----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -22,20 +22,18 @@
 #include "memory.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define EXTRA 1000
 
-/* ----------------------------------------------------------------------
-   set all global defaults 
-------------------------------------------------------------------------- */
+/* ---------------------------------------------------------------------- */
 
-DihedralHybrid::DihedralHybrid()
+DihedralHybrid::DihedralHybrid(LAMMPS *lmp) : Dihedral(lmp)
 {
   nstyles = 0;
 }
 
-/* ----------------------------------------------------------------------
-   free all arrays
-------------------------------------------------------------------------- */
+/* ---------------------------------------------------------------------- */
 
 DihedralHybrid::~DihedralHybrid()
 {
diff --git a/src/MOLECULE/dihedral_hybrid.h b/src/MOLECULE/dihedral_hybrid.h
index e6cc4713425f3a953e177d9b7e9eb8ef6cfa4021..c319b9e0d9fc624aa29e23cc396ad0528502bfa9 100644
--- a/src/MOLECULE/dihedral_hybrid.h
+++ b/src/MOLECULE/dihedral_hybrid.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -17,9 +17,11 @@
 #include "stdio.h"
 #include "dihedral.h"
 
+namespace LAMMPS_NS {
+
 class DihedralHybrid : public Dihedral {
  public:
-  DihedralHybrid();
+  DihedralHybrid(class LAMMPS *);
   ~DihedralHybrid();
   void compute(int, int);
   void settings(int, char **);
@@ -42,4 +44,6 @@ class DihedralHybrid : public Dihedral {
   void allocate();
 };
 
+}
+
 #endif
diff --git a/src/MOLECULE/dihedral_multi_harmonic.cpp b/src/MOLECULE/dihedral_multi_harmonic.cpp
index b3541f95210019d906f887e7930e50c04053f751..864625fc3865e9093d5012936b822ee29caf1c9b 100644
--- a/src/MOLECULE/dihedral_multi_harmonic.cpp
+++ b/src/MOLECULE/dihedral_multi_harmonic.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -27,15 +27,19 @@
 #include "memory.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define MIN(A,B) ((A) < (B)) ? (A) : (B)
 #define MAX(A,B) ((A) > (B)) ? (A) : (B)
 
 #define TOLERANCE 0.05
 #define SMALL     0.001
 
-/* ----------------------------------------------------------------------
-   free all arrays 
-------------------------------------------------------------------------- */
+/* ---------------------------------------------------------------------- */
+
+DihedralMultiHarmonic::DihedralMultiHarmonic(LAMMPS *lmp) : Dihedral(lmp) {}
+
+/* ---------------------------------------------------------------------- */
 
 DihedralMultiHarmonic::~DihedralMultiHarmonic()
 {
diff --git a/src/MOLECULE/dihedral_multi_harmonic.h b/src/MOLECULE/dihedral_multi_harmonic.h
index 695cdfe1afde7864d1ea1b00316903db17a5ed84..1fce65f4a3acc37d6ee9d9880765854a57b6dc45 100644
--- a/src/MOLECULE/dihedral_multi_harmonic.h
+++ b/src/MOLECULE/dihedral_multi_harmonic.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -17,9 +17,11 @@
 #include "stdio.h"
 #include "dihedral.h"
 
+namespace LAMMPS_NS {
+
 class DihedralMultiHarmonic : public Dihedral {
  public:
-  DihedralMultiHarmonic() {}
+  DihedralMultiHarmonic(class LAMMPS *);
   ~DihedralMultiHarmonic();
   void compute(int, int);
   void coeff(int, int, char **);
@@ -32,4 +34,6 @@ class DihedralMultiHarmonic : public Dihedral {
   void allocate();
 };
 
+}
+
 #endif
diff --git a/src/MOLECULE/dihedral_opls.cpp b/src/MOLECULE/dihedral_opls.cpp
index eff17571fc56dcf716c61dec4094d1814ef5c216..efb84c41d680074d1c7bf9c9fcd662d861ea1382 100644
--- a/src/MOLECULE/dihedral_opls.cpp
+++ b/src/MOLECULE/dihedral_opls.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -27,6 +27,8 @@
 #include "memory.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define MIN(A,B) ((A) < (B)) ? (A) : (B)
 #define MAX(A,B) ((A) > (B)) ? (A) : (B)
 
@@ -34,9 +36,11 @@
 #define SMALL     0.001
 #define SMALLER   0.00001
 
-/* ----------------------------------------------------------------------
-   free all arrays 
-------------------------------------------------------------------------- */
+/* ---------------------------------------------------------------------- */
+
+DihedralOPLS::DihedralOPLS(LAMMPS *lmp) : Dihedral(lmp) {}
+
+/* ---------------------------------------------------------------------- */
 
 DihedralOPLS::~DihedralOPLS()
 {
@@ -53,7 +57,7 @@ DihedralOPLS::~DihedralOPLS()
 
 void DihedralOPLS::compute(int eflag, int vflag)
 {
-  int i,m,n,i1,i2,i3,i4,type,factor;
+  int n,i1,i2,i3,i4,type,factor;
   double rfactor;
   double vb1x,vb1y,vb1z,vb2x,vb2y;
   double vb2z,vb2xm,vb2ym,vb2zm,vb3x,vb3y,vb3z,sb1;
diff --git a/src/MOLECULE/dihedral_opls.h b/src/MOLECULE/dihedral_opls.h
index d65363286c9aa1903f0a1acdd433b2d5565fc87f..2d71c2efc339a77749fff51e53165c402a95005d 100644
--- a/src/MOLECULE/dihedral_opls.h
+++ b/src/MOLECULE/dihedral_opls.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -17,9 +17,11 @@
 #include "stdio.h"
 #include "dihedral.h"
 
+namespace LAMMPS_NS {
+
 class DihedralOPLS : public Dihedral {
  public:
-  DihedralOPLS() {}
+  DihedralOPLS(class LAMMPS *);
   ~DihedralOPLS();
   void compute(int, int);
   void coeff(int, int, char **);
@@ -32,4 +34,6 @@ class DihedralOPLS : public Dihedral {
   void allocate();
 };
 
+}
+
 #endif
diff --git a/src/MOLECULE/dump_bond.cpp b/src/MOLECULE/dump_bond.cpp
index eb88e2478099760fb7033251f78b43d850c8b6b3..c1a9f8845835e46a2c69a7dc34b95ed463a92cb8 100644
--- a/src/MOLECULE/dump_bond.cpp
+++ b/src/MOLECULE/dump_bond.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -18,9 +18,11 @@
 #include "update.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 /* ---------------------------------------------------------------------- */
 
-DumpBond::DumpBond(int narg, char **arg) : Dump(narg, arg)
+DumpBond::DumpBond(LAMMPS *lmp, int narg, char **arg) : Dump(lmp, narg, arg)
 {
   if (narg != 5) error->all("Illegal dump bond command");
   if (atom->molecular == 0)
diff --git a/src/MOLECULE/dump_bond.h b/src/MOLECULE/dump_bond.h
index 6af31b8a9a773df8f414450f2d869410b05c989a..e78a1f15ca6336fd61c804df479145f3af533049 100644
--- a/src/MOLECULE/dump_bond.h
+++ b/src/MOLECULE/dump_bond.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,10 +16,11 @@
 
 #include "dump.h"
 
+namespace LAMMPS_NS {
+
 class DumpBond : public Dump {
  public:
-  DumpBond(int, char **);
-  ~DumpBond() {}
+  DumpBond(LAMMPS *, int, char **);
   void init();
 
  private:
@@ -31,4 +32,6 @@ class DumpBond : public Dump {
   void write_data(int, double *);
 };
 
+}
+
 #endif
diff --git a/src/MOLECULE/improper.cpp b/src/MOLECULE/improper.cpp
index bf428a62c643ecdc1c4fb71c9ec6114740e4f389..49639d2ea6a2e3d7e94ad254837dc6ad6237b791 100644
--- a/src/MOLECULE/improper.cpp
+++ b/src/MOLECULE/improper.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,9 +16,11 @@
 #include "atom.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 /* ---------------------------------------------------------------------- */
 
-Improper::Improper()
+Improper::Improper(LAMMPS *lmp) : Pointers(lmp)
 {
   allocated = 0;
   PI = 4.0*atan(1.0);
diff --git a/src/MOLECULE/improper_cvff.cpp b/src/MOLECULE/improper_cvff.cpp
index 2b7a0d111f7d2e339a73eadac643152232f37e9f..ad344d590132fbf89de683fa12dfe6bb2e3726f7 100644
--- a/src/MOLECULE/improper_cvff.cpp
+++ b/src/MOLECULE/improper_cvff.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -24,12 +24,16 @@
 #include "memory.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define TOLERANCE 0.05
 #define SMALL     0.001
 
-/* ----------------------------------------------------------------------
-   free all arrays 
-------------------------------------------------------------------------- */
+/* ---------------------------------------------------------------------- */
+
+ImproperCvff::ImproperCvff(LAMMPS *lmp) : Improper(lmp) {}
+
+/* ---------------------------------------------------------------------- */
 
 ImproperCvff::~ImproperCvff()
 {
diff --git a/src/MOLECULE/improper_cvff.h b/src/MOLECULE/improper_cvff.h
index 37225ee5011f1e4cd2d3c81b583270f92fa3be8e..51fcc4b2e3e9d6aeff32680fbbb5bebe195e1d1e 100644
--- a/src/MOLECULE/improper_cvff.h
+++ b/src/MOLECULE/improper_cvff.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -17,9 +17,11 @@
 #include "stdio.h"
 #include "improper.h"
 
+namespace LAMMPS_NS {
+
 class ImproperCvff : public Improper {
  public:
-  ImproperCvff() {}
+  ImproperCvff(class LAMMPS *);
   ~ImproperCvff();
   void compute(int, int);
   void coeff(int, int, char **);
@@ -33,4 +35,6 @@ class ImproperCvff : public Improper {
   void allocate();
 };
 
+}
+
 #endif
diff --git a/src/MOLECULE/improper_harmonic.cpp b/src/MOLECULE/improper_harmonic.cpp
index 58b0c58531bd75d1d5b35aa37aa9b5cb9b03a7c3..b8af76dc8cce22f0dedc4ed7033bc107d7f2c69b 100644
--- a/src/MOLECULE/improper_harmonic.cpp
+++ b/src/MOLECULE/improper_harmonic.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -24,12 +24,16 @@
 #include "memory.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define TOLERANCE 0.05
 #define SMALL     0.001
 
-/* ----------------------------------------------------------------------
-   free all arrays 
-------------------------------------------------------------------------- */
+/* ---------------------------------------------------------------------- */
+
+ImproperHarmonic::ImproperHarmonic(LAMMPS *lmp) : Improper(lmp) {}
+
+/* ---------------------------------------------------------------------- */
 
 ImproperHarmonic::~ImproperHarmonic()
 {
diff --git a/src/MOLECULE/improper_harmonic.h b/src/MOLECULE/improper_harmonic.h
index e21ac2e6b7f1d71c50018e47e4768868e8700bd7..fdc049534492618d85c6dac0d6b240220139ba74 100644
--- a/src/MOLECULE/improper_harmonic.h
+++ b/src/MOLECULE/improper_harmonic.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -17,9 +17,11 @@
 #include "stdio.h"
 #include "improper.h"
 
+namespace LAMMPS_NS {
+
 class ImproperHarmonic : public Improper {
  public:
-  ImproperHarmonic() {}
+  ImproperHarmonic(class LAMMPS *);
   ~ImproperHarmonic();
   void compute(int, int);
   void coeff(int, int, char **);
@@ -32,4 +34,6 @@ class ImproperHarmonic : public Improper {
   void allocate();
 };
 
+}
+
 #endif
diff --git a/src/MOLECULE/improper_hybrid.cpp b/src/MOLECULE/improper_hybrid.cpp
index c911f589500d8283eb2198cd3d2362509fab40b1..de4b959e5d9538b199b3e3dae1b5bc31686a86a3 100644
--- a/src/MOLECULE/improper_hybrid.cpp
+++ b/src/MOLECULE/improper_hybrid.cpp
@@ -1,7 +1,7 @@
 /* -----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -22,20 +22,18 @@
 #include "memory.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define EXTRA 1000
 
-/* ----------------------------------------------------------------------
-   set all global defaults 
-------------------------------------------------------------------------- */
+/* ---------------------------------------------------------------------- */
 
-ImproperHybrid::ImproperHybrid()
+ImproperHybrid::ImproperHybrid(LAMMPS *lmp) : Improper(lmp)
 {
   nstyles = 0;
 }
 
-/* ----------------------------------------------------------------------
-   free all arrays
-------------------------------------------------------------------------- */
+/* ---------------------------------------------------------------------- */
 
 ImproperHybrid::~ImproperHybrid()
 {
diff --git a/src/MOLECULE/improper_hybrid.h b/src/MOLECULE/improper_hybrid.h
index 1aca2401e59001f49695c51847985e3f6bffae71..191ea67cd84bc0ae2bf1c6e2a88f5356f19b9872 100644
--- a/src/MOLECULE/improper_hybrid.h
+++ b/src/MOLECULE/improper_hybrid.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -17,9 +17,11 @@
 #include "stdio.h"
 #include "improper.h"
 
+namespace LAMMPS_NS {
+
 class ImproperHybrid : public Improper {
  public:
-  ImproperHybrid();
+  ImproperHybrid(class LAMMPS *);
   ~ImproperHybrid();
   void compute(int, int);
   void settings(int, char **);
@@ -41,4 +43,6 @@ class ImproperHybrid : public Improper {
   void allocate();
 };
 
+}
+
 #endif
diff --git a/src/MOLECULE/pair_lj_charmm_coul_charmm.cpp b/src/MOLECULE/pair_lj_charmm_coul_charmm.cpp
index 101043e9977df744ffa5a04dd7e1f8d5b49fe812..2dc98fa4bd6e887f9551270c950968af5e2ee779 100644
--- a/src/MOLECULE/pair_lj_charmm_coul_charmm.cpp
+++ b/src/MOLECULE/pair_lj_charmm_coul_charmm.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -27,11 +27,17 @@
 #include "neighbor.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define MIN(a,b) ((a) < (b) ? (a) : (b))
 #define MAX(a,b) ((a) > (b) ? (a) : (b))
 
 /* ---------------------------------------------------------------------- */
 
+PairLJCharmmCoulCharmm::PairLJCharmmCoulCharmm(LAMMPS *lmp) : Pair(lmp) {}
+
+/* ---------------------------------------------------------------------- */
+
 PairLJCharmmCoulCharmm::~PairLJCharmmCoulCharmm()
 {
   if (allocated) {
@@ -327,7 +333,7 @@ void PairLJCharmmCoulCharmm::init_style()
 {
   // require an atom style with charge defined
 
-  if (atom->charge_allow == 0)
+  if (atom->q == NULL)
     error->all("Must use charged atom style with this pair style");
 
   // require cut_lj_inner < cut_lj, cut_coul_inner < cut_coul
@@ -491,3 +497,18 @@ void PairLJCharmmCoulCharmm::single(int i, int j, int itype, int jtype,
     } else one.eng_vdwl = 0.0;
   }
 }
+
+/* ---------------------------------------------------------------------- */
+
+void PairLJCharmmCoulCharmm::extract_charmm(double ***p_lj14_1, 
+					    double ***p_lj14_2,
+					    double ***p_lj14_3,
+					    double ***p_lj14_4,
+					    int *p_implicit_flag)
+{
+  *p_lj14_1 = lj14_1;
+  *p_lj14_2 = lj14_2;
+  *p_lj14_3 = lj14_3;
+  *p_lj14_4 = lj14_4;
+  *p_implicit_flag = 0;
+}
diff --git a/src/MOLECULE/pair_lj_charmm_coul_charmm.h b/src/MOLECULE/pair_lj_charmm_coul_charmm.h
index d6a6c63d29422a2415d6ad93b4a370305c74ca65..22ec6de0eab3733f6995a80151bc1f79d92d934f 100644
--- a/src/MOLECULE/pair_lj_charmm_coul_charmm.h
+++ b/src/MOLECULE/pair_lj_charmm_coul_charmm.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,12 +16,11 @@
 
 #include "pair.h"
 
+namespace LAMMPS_NS {
+
 class PairLJCharmmCoulCharmm : public Pair {
  public:
-  // these variables are public so DihedralCharmm can see them
-  double **lj14_1,**lj14_2,**lj14_3,**lj14_4;
-
-  PairLJCharmmCoulCharmm() {}
+  PairLJCharmmCoulCharmm(class LAMMPS *);
   ~PairLJCharmmCoulCharmm();
   virtual void compute(int, int);
   void settings(int, char **);
@@ -34,14 +33,20 @@ class PairLJCharmmCoulCharmm : public Pair {
   void read_restart_settings(FILE *);
   virtual void single(int, int, int, int, double, double, double, int, One &);
 
+  virtual void extract_charmm(double ***, double ***,
+			      double ***, double ***, int *);
+
  protected:
   double cut_lj_inner,cut_lj,cut_coul_inner,cut_coul;
   double cut_lj_innersq,cut_ljsq,cut_coul_innersq,cut_coulsq,cut_bothsq;
   double denom_lj,denom_coul;
   double **epsilon,**sigma,**eps14,**sigma14;
   double **lj1,**lj2,**lj3,**lj4;
+  double **lj14_1,**lj14_2,**lj14_3,**lj14_4;
 
   void allocate();
 };
 
+}
+
 #endif
diff --git a/src/MOLECULE/pair_lj_charmm_coul_charmm_implicit.cpp b/src/MOLECULE/pair_lj_charmm_coul_charmm_implicit.cpp
index d4bc75b172c3b5eda2cd6084e1f8db38a05094e2..6c0743cdccbf9979e1e02a3e11f0db121eda370a 100644
--- a/src/MOLECULE/pair_lj_charmm_coul_charmm_implicit.cpp
+++ b/src/MOLECULE/pair_lj_charmm_coul_charmm_implicit.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -18,6 +18,13 @@
 #include "update.h"
 #include "neighbor.h"
 
+using namespace LAMMPS_NS;
+
+/* ---------------------------------------------------------------------- */
+
+PairLJCharmmCoulCharmmImplicit::PairLJCharmmCoulCharmmImplicit(LAMMPS *lmp) :
+  PairLJCharmmCoulCharmm(lmp) {}
+
 /* ---------------------------------------------------------------------- */
 
 void PairLJCharmmCoulCharmmImplicit::compute(int eflag, int vflag)
@@ -212,3 +219,18 @@ void PairLJCharmmCoulCharmmImplicit::single(int i, int j, int itype, int jtype,
     } else one.eng_vdwl = 0.0;
   }
 }
+
+/* ---------------------------------------------------------------------- */
+
+void PairLJCharmmCoulCharmmImplicit::extract_charmm(double ***p_lj14_1, 
+						    double ***p_lj14_2,
+						    double ***p_lj14_3,
+						    double ***p_lj14_4,
+						    int *p_implicit_flag)
+{
+  *p_lj14_1 = lj14_1;
+  *p_lj14_2 = lj14_2;
+  *p_lj14_3 = lj14_3;
+  *p_lj14_4 = lj14_4;
+  *p_implicit_flag = 1;
+}
diff --git a/src/MOLECULE/pair_lj_charmm_coul_charmm_implicit.h b/src/MOLECULE/pair_lj_charmm_coul_charmm_implicit.h
index 2ef707551f754b70853e893b4594e748e0519c82..14f7a9da76f5efce6262a0cec56a882fe0fff0db 100644
--- a/src/MOLECULE/pair_lj_charmm_coul_charmm_implicit.h
+++ b/src/MOLECULE/pair_lj_charmm_coul_charmm_implicit.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,10 +16,17 @@
 
 #include "pair_lj_charmm_coul_charmm.h"
 
+namespace LAMMPS_NS {
+
 class PairLJCharmmCoulCharmmImplicit : public PairLJCharmmCoulCharmm {
  public:
+  PairLJCharmmCoulCharmmImplicit(class LAMMPS *);
   void compute(int, int);
   void single(int, int, int, int, double, double, double, int, One &);
+
+  void extract_charmm(double ***, double ***, double ***, double ***, int *);
 };
 
+}
+
 #endif
diff --git a/src/MOLECULE/style_molecule.h b/src/MOLECULE/style_molecule.h
index 1da512819deb46125711b59dfbab8f93311e48fc..0121b58315b84117a5bce129b8bece13c36370ee 100644
--- a/src/MOLECULE/style_molecule.h
+++ b/src/MOLECULE/style_molecule.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -28,17 +28,15 @@ AngleStyle(hybrid,AngleHybrid)
 #endif
 
 #ifdef AtomInclude
-#include "atom_angle.h"
-#include "atom_bond.h"
-#include "atom_full.h"
-#include "atom_molecular.h"
+#include "atom_vec_angle.h"
+#include "atom_vec_bond.h"
+#include "atom_vec_molecular.h"
 #endif
 
 #ifdef AtomClass
-AtomStyle(angle,AtomAngle)
-AtomStyle(bond,AtomBond)
-AtomStyle(full,AtomFull)
-AtomStyle(molecular,AtomMolecular)
+AtomStyle(angle,AtomVecAngle)
+AtomStyle(bond,AtomVecBond)
+AtomStyle(molecular,AtomVecMolecular)
 #endif
 
 #ifdef BondInclude
diff --git a/src/Makefile b/src/Makefile
index 87ffe074e82f69865914462edc7125005fd62355..a16198346e89324516a631fec8b425fdb22d003a 100755
--- a/src/Makefile
+++ b/src/Makefile
@@ -42,8 +42,8 @@ makelist:
 # Packages
 
 package:
-	@echo 'Available packages: class2, dpd, granular, kspace'
-	@echo '                    manybody, meam, molecule, poems, xtc'
+	@echo 'Available packages: class2, dpd, granular, kspace, manybody,"
+	@echo '                    meam, molecule, opt, poems, xtc'
 	@echo '  "make yes-name"   include a package'
 	@echo '  "make no-name"    exclude a package'
 	@echo '  "make yes-all"    include all packages'
@@ -51,7 +51,7 @@ package:
 
 yes-all:
 	make yes-class2 yes-dpd yes-granular yes-kspace \
-	yes-manybody yes-meam yes-molecule yes-poems yes-xtc
+	yes-manybody yes-meam yes-molecule yes-opt yes-poems yes-xtc
 
 no-all:
 	@echo 'Removing files, ignore any rm errors ...'
@@ -62,6 +62,7 @@ no-all:
 	@cd MANYBODY; csh -f Install.csh 0
 	@cd MEAM; csh -f Install.csh 0
 	@cd MOLECULE; csh -f Install.csh 0
+	@cd OPT; csh -f Install.csh 0
 	@cd POEMS; csh -f Install.csh 0
 	@cd XTC; csh -f Install.csh 0
 	@make clean
@@ -115,6 +116,13 @@ no-molecule:
 	@cd MOLECULE; csh -f Install.csh 0
 	@make clean
 
+yes-opt:
+	@cd OPT; csh -f Install.csh 1
+no-opt:
+	@echo 'Removing files, ignore any rm errors ...'
+	@cd OPT; csh -f Install.csh 0
+	@make clean
+
 yes-poems:
 	@cd POEMS; csh -f Install.csh 1
 no-poems:
@@ -139,6 +147,7 @@ package-update:
 	@csh -f Package.csh MANYBODY update
 	@csh -f Package.csh MEAM update
 	@csh -f Package.csh MOLECULE update
+	@csh -f Package.csh OPT update
 	@csh -f Package.csh POEMS update
 	@csh -f Package.csh XTC update
 
@@ -152,6 +161,7 @@ package-overwrite:
 	@csh -f Package.csh MANYBODY overwrite
 	@csh -f Package.csh MEAM overwrite
 	@csh -f Package.csh MOLECULE overwrite
+	@csh -f Package.csh OPT overwrite
 	@csh -f Package.csh POEMS overwrite
 	@csh -f Package.csh XTC overwrite
 
@@ -165,5 +175,6 @@ package-check:
 	@csh -f Package.csh MANYBODY check
 	@csh -f Package.csh MEAM check
 	@csh -f Package.csh MOLECULE check
+	@csh -f Package.csh OPT check
 	@csh -f Package.csh POEMS check
 	@csh -f Package.csh XTC check
diff --git a/src/Makefile.lib b/src/Makefile.lib
index 9c3e4532633a0173c1ea15ee8bf3f5bddf1aa46b..4a48d1814cd65ad1a3ee6599dfa32ff1e6ed064a 100644
--- a/src/Makefile.lib
+++ b/src/Makefile.lib
@@ -7,9 +7,9 @@ SHELL = /bin/sh
 ROOT =	lmp
 EXE =	lib$(ROOT)_$@.a
 
-SRC =	angle.cpp angle_charmm.cpp angle_class2.cpp angle_cosine.cpp angle_cosine_squared.cpp angle_harmonic.cpp angle_hybrid.cpp atom.cpp atom_angle.cpp atom_atomic.cpp atom_bond.cpp atom_charge.cpp atom_dpd.cpp atom_full.cpp atom_granular.cpp atom_hybrid.cpp atom_molecular.cpp bond.cpp bond_class2.cpp bond_fene.cpp bond_fene_expand.cpp bond_harmonic.cpp bond_hybrid.cpp bond_morse.cpp bond_nonlinear.cpp bond_quartic.cpp comm.cpp create_atoms.cpp create_box.cpp delete_atoms.cpp delete_bonds.cpp dihedral.cpp dihedral_charmm.cpp dihedral_class2.cpp dihedral_harmonic.cpp dihedral_helix.cpp dihedral_hybrid.cpp dihedral_multi_harmonic.cpp dihedral_opls.cpp displace_atoms.cpp domain.cpp dump.cpp dump_atom.cpp dump_bond.cpp dump_custom.cpp dump_dcd.cpp dump_xyz.cpp error.cpp ewald.cpp fft3d.cpp fft3d_wrap.cpp finish.cpp fix.cpp fix_add_force.cpp fix_ave_force.cpp fix_centro.cpp fix_com.cpp fix_drag.cpp fix_efield.cpp fix_energy.cpp fix_enforce2d.cpp fix_freeze.cpp fix_gran_diag.cpp fix_gravity.cpp fix_gyration.cpp fix_indent.cpp fix_insert.cpp fix_langevin.cpp fix_line_force.cpp fix_minimize.cpp fix_momentum.cpp fix_msd.cpp fix_nph.cpp fix_npt.cpp fix_nve.cpp fix_nve_gran.cpp fix_nvt.cpp fix_orient_fcc.cpp fix_plane_force.cpp fix_print.cpp fix_rdf.cpp fix_recenter.cpp fix_respa.cpp fix_rigid.cpp fix_set_force.cpp fix_shake.cpp fix_shear_history.cpp fix_spring.cpp fix_spring_rg.cpp fix_spring_self.cpp fix_stress.cpp fix_temp_rescale.cpp fix_tmd.cpp fix_uniaxial.cpp fix_viscous.cpp fix_volume_rescale.cpp fix_wall_gran.cpp fix_wall_lj93.cpp fix_wall_reflect.cpp fix_wiggle.cpp force.cpp group.cpp improper.cpp improper_class2.cpp improper_cvff.cpp improper_harmonic.cpp improper_hybrid.cpp input.cpp kspace.cpp lammps.cpp library.cpp memory.cpp min.cpp min_cg.cpp min_cg_fr.cpp min_sd.cpp minimize.cpp modify.cpp neigh_bond.cpp neigh_full.cpp neigh_gran.cpp neigh_half.cpp neigh_respa.cpp neighbor.cpp output.cpp pack.cpp pair.cpp pair_buck.cpp pair_buck_coul_cut.cpp pair_buck_coul_long.cpp pair_dpd.cpp pair_eam.cpp pair_eam_alloy.cpp pair_eam_fs.cpp pair_gran_hertzian.cpp pair_gran_history.cpp pair_gran_no_history.cpp pair_hybrid.cpp pair_lj_charmm_coul_charmm.cpp pair_lj_charmm_coul_charmm_implicit.cpp pair_lj_charmm_coul_long.cpp pair_lj_class2.cpp pair_lj_class2_coul_cut.cpp pair_lj_class2_coul_long.cpp pair_lj_cut.cpp pair_lj_cut_coul_cut.cpp pair_lj_cut_coul_debye.cpp pair_lj_cut_coul_long.cpp pair_lj_cut_coul_long_tip4p.cpp pair_lj_cut_fast.cpp pair_lj_expand.cpp pair_lj_smooth.cpp pair_morse.cpp pair_soft.cpp pair_sw.cpp pair_table.cpp pair_tersoff.cpp pair_yukawa.cpp pppm.cpp pppm_tip4p.cpp pressure.cpp random_mars.cpp random_park.cpp read_data.cpp read_restart.cpp region.cpp region_block.cpp region_cylinder.cpp region_intersect.cpp region_prism.cpp region_sphere.cpp region_union.cpp remap.cpp remap_wrap.cpp replicate.cpp respa.cpp run.cpp set.cpp shell.cpp special.cpp system.cpp temp_full.cpp temp_partial.cpp temp_ramp.cpp temp_region.cpp temper.cpp temperature.cpp thermo.cpp timer.cpp universe.cpp update.cpp variable.cpp velocity.cpp verlet.cpp write_restart.cpp
+SRC =	angle.cpp angle_charmm.cpp angle_class2.cpp angle_cosine.cpp angle_cosine_squared.cpp angle_harmonic.cpp angle_hybrid.cpp atom.cpp atom_vec.cpp atom_vec_angle.cpp atom_vec_atomic.cpp atom_vec_bond.cpp atom_vec_charge.cpp atom_vec_dpd.cpp atom_vec_granular.cpp atom_vec_hybrid.cpp atom_vec_molecular.cpp bond.cpp bond_class2.cpp bond_fene.cpp bond_fene_expand.cpp bond_harmonic.cpp bond_hybrid.cpp bond_morse.cpp bond_nonlinear.cpp bond_quartic.cpp comm.cpp compute.cpp compute_pressure.cpp compute_rotate_dipole.cpp compute_rotate_gran.cpp compute_temp.cpp compute_temp_partial.cpp compute_temp_ramp.cpp compute_temp_region.cpp create_atoms.cpp create_box.cpp delete_atoms.cpp delete_bonds.cpp dihedral.cpp dihedral_charmm.cpp dihedral_class2.cpp dihedral_harmonic.cpp dihedral_helix.cpp dihedral_hybrid.cpp dihedral_multi_harmonic.cpp dihedral_opls.cpp displace_atoms.cpp domain.cpp dump.cpp dump_atom.cpp dump_bond.cpp dump_custom.cpp dump_dcd.cpp dump_xtc.cpp dump_xyz.cpp error.cpp ewald.cpp fft3d.cpp fft3d_wrap.cpp finish.cpp fix.cpp fix_add_force.cpp fix_ave_force.cpp fix_com.cpp fix_deposit.cpp fix_drag.cpp fix_dump_centro.cpp fix_dump_epair.cpp fix_dump_etotal.cpp fix_dump_ke.cpp fix_dump_stress.cpp fix_efield.cpp fix_enforce2d.cpp fix_freeze.cpp fix_gran_diag.cpp fix_gravity.cpp fix_gyration.cpp fix_indent.cpp fix_langevin.cpp fix_line_force.cpp fix_minimize.cpp fix_momentum.cpp fix_msd.cpp fix_nph.cpp fix_npt.cpp fix_nve.cpp fix_nve_gran.cpp fix_nvt.cpp fix_orient_fcc.cpp fix_plane_force.cpp fix_pour.cpp fix_print.cpp fix_rdf.cpp fix_recenter.cpp fix_respa.cpp fix_rigid.cpp fix_set_force.cpp fix_shake.cpp fix_shear_history.cpp fix_spring.cpp fix_spring_rg.cpp fix_spring_self.cpp fix_temp_rescale.cpp fix_tmd.cpp fix_uniaxial.cpp fix_viscous.cpp fix_volume_rescale.cpp fix_wall_gran.cpp fix_wall_lj126.cpp fix_wall_lj93.cpp fix_wall_reflect.cpp fix_wiggle.cpp force.cpp group.cpp improper.cpp improper_class2.cpp improper_cvff.cpp improper_harmonic.cpp improper_hybrid.cpp input.cpp kspace.cpp lammps.cpp lattice.cpp library.cpp memory.cpp min.cpp min_cg.cpp min_cg_fr.cpp min_sd.cpp minimize.cpp modify.cpp neigh_bond.cpp neigh_full.cpp neigh_gran.cpp neigh_half.cpp neigh_respa.cpp neighbor.cpp output.cpp pack.cpp pair.cpp pair_buck.cpp pair_buck_coul_cut.cpp pair_buck_coul_long.cpp pair_dpd.cpp pair_eam.cpp pair_eam_alloy.cpp pair_eam_fs.cpp pair_gran_hertzian.cpp pair_gran_history.cpp pair_gran_no_history.cpp pair_hybrid.cpp pair_lj_charmm_coul_charmm.cpp pair_lj_charmm_coul_charmm_implicit.cpp pair_lj_charmm_coul_long.cpp pair_lj_class2.cpp pair_lj_class2_coul_cut.cpp pair_lj_class2_coul_long.cpp pair_lj_cut.cpp pair_lj_cut_coul_cut.cpp pair_lj_cut_coul_debye.cpp pair_lj_cut_coul_long.cpp pair_lj_cut_coul_long_tip4p.cpp pair_lj_expand.cpp pair_lj_smooth.cpp pair_morse.cpp pair_soft.cpp pair_sw.cpp pair_table.cpp pair_tersoff.cpp pair_yukawa.cpp pppm.cpp pppm_tip4p.cpp random_mars.cpp random_park.cpp read_data.cpp read_restart.cpp region.cpp region_block.cpp region_cylinder.cpp region_intersect.cpp region_prism.cpp region_sphere.cpp region_union.cpp remap.cpp remap_wrap.cpp replicate.cpp respa.cpp run.cpp set.cpp shell.cpp special.cpp temper.cpp thermo.cpp timer.cpp universe.cpp update.cpp variable.cpp velocity.cpp verlet.cpp write_restart.cpp
 
-INC =	angle.h angle_charmm.h angle_class2.h angle_cosine.h angle_cosine_squared.h angle_harmonic.h angle_hybrid.h atom.h atom_angle.h atom_atomic.h atom_bond.h atom_charge.h atom_dpd.h atom_full.h atom_granular.h atom_hybrid.h atom_molecular.h bond.h bond_class2.h bond_fene.h bond_fene_expand.h bond_harmonic.h bond_hybrid.h bond_morse.h bond_nonlinear.h bond_quartic.h comm.h create_atoms.h create_box.h delete_atoms.h delete_bonds.h dihedral.h dihedral_charmm.h dihedral_class2.h dihedral_harmonic.h dihedral_helix.h dihedral_hybrid.h dihedral_multi_harmonic.h dihedral_opls.h displace_atoms.h domain.h dump.h dump_atom.h dump_bond.h dump_custom.h dump_dcd.h dump_xyz.h error.h ewald.h fft3d.h fft3d_wrap.h finish.h fix.h fix_add_force.h fix_ave_force.h fix_centro.h fix_com.h fix_drag.h fix_efield.h fix_energy.h fix_enforce2d.h fix_freeze.h fix_gran_diag.h fix_gravity.h fix_gyration.h fix_indent.h fix_insert.h fix_langevin.h fix_line_force.h fix_minimize.h fix_momentum.h fix_msd.h fix_nph.h fix_npt.h fix_nve.h fix_nve_gran.h fix_nvt.h fix_orient_fcc.h fix_plane_force.h fix_print.h fix_rdf.h fix_recenter.h fix_respa.h fix_rigid.h fix_set_force.h fix_shake.h fix_shear_history.h fix_spring.h fix_spring_rg.h fix_spring_self.h fix_stress.h fix_temp_rescale.h fix_tmd.h fix_uniaxial.h fix_viscous.h fix_volume_rescale.h fix_wall_gran.h fix_wall_lj93.h fix_wall_reflect.h fix_wiggle.h force.h group.h improper.h improper_class2.h improper_cvff.h improper_harmonic.h improper_hybrid.h input.h integrate.h kspace.h lammps.h library.h memory.h memory.hold.h min.h min_cg.h min_cg_fr.h min_sd.h minimize.h modify.h neighbor.h output.h pack.h pair.h pair_buck.h pair_buck_coul_cut.h pair_buck_coul_long.h pair_dpd.h pair_eam.h pair_eam_alloy.h pair_eam_fs.h pair_gran_hertzian.h pair_gran_history.h pair_gran_no_history.h pair_hybrid.h pair_lj_charmm_coul_charmm.h pair_lj_charmm_coul_charmm_implicit.h pair_lj_charmm_coul_long.h pair_lj_class2.h pair_lj_class2_coul_cut.h pair_lj_class2_coul_long.h pair_lj_cut.h pair_lj_cut_coul_cut.h pair_lj_cut_coul_debye.h pair_lj_cut_coul_long.h pair_lj_cut_coul_long_tip4p.h pair_lj_cut_fast.h pair_lj_expand.h pair_lj_smooth.h pair_morse.h pair_soft.h pair_sw.h pair_table.h pair_tersoff.h pair_yukawa.h pppm.h pppm_tip4p.h pressure.h random_mars.h random_park.h read_data.h read_restart.h region.h region_block.h region_cylinder.h region_intersect.h region_prism.h region_sphere.h region_union.h remap.h remap_wrap.h replicate.h respa.h run.h set.h shell.h special.h style.h style_class2.h style_dpd.h style_granular.h style_kspace.h style_manybody.h style_molecule.h style_poems.h style_user.h style_xtc.h system.h temp_full.h temp_partial.h temp_ramp.h temp_region.h temper.h temperature.h thermo.h timer.h universe.h update.h variable.h velocity.h verlet.h write_restart.h
+INC =	angle.h angle_charmm.h angle_class2.h angle_cosine.h angle_cosine_squared.h angle_harmonic.h angle_hybrid.h atom.h atom_vec.h atom_vec_angle.h atom_vec_atomic.h atom_vec_bond.h atom_vec_charge.h atom_vec_dpd.h atom_vec_granular.h atom_vec_hybrid.h atom_vec_molecular.h bond.h bond_class2.h bond_fene.h bond_fene_expand.h bond_harmonic.h bond_hybrid.h bond_morse.h bond_nonlinear.h bond_quartic.h comm.h compute.h compute_pressure.h compute_rotate_dipole.h compute_rotate_gran.h compute_temp.h compute_temp_partial.h compute_temp_ramp.h compute_temp_region.h create_atoms.h create_box.h delete_atoms.h delete_bonds.h dihedral.h dihedral_charmm.h dihedral_class2.h dihedral_harmonic.h dihedral_helix.h dihedral_hybrid.h dihedral_multi_harmonic.h dihedral_opls.h displace_atoms.h domain.h dump.h dump_atom.h dump_bond.h dump_custom.h dump_dcd.h dump_xtc.h dump_xyz.h error.h ewald.h fft3d.h fft3d_wrap.h finish.h fix.h fix_add_force.h fix_ave_force.h fix_com.h fix_deposit.h fix_drag.h fix_dump_centro.h fix_dump_epair.h fix_dump_etotal.h fix_dump_ke.h fix_dump_stress.h fix_efield.h fix_enforce2d.h fix_freeze.h fix_gran_diag.h fix_gravity.h fix_gyration.h fix_indent.h fix_langevin.h fix_line_force.h fix_minimize.h fix_momentum.h fix_msd.h fix_nph.h fix_npt.h fix_nve.h fix_nve_gran.h fix_nvt.h fix_orient_fcc.h fix_plane_force.h fix_pour.h fix_print.h fix_rdf.h fix_recenter.h fix_respa.h fix_rigid.h fix_set_force.h fix_shake.h fix_shear_history.h fix_spring.h fix_spring_rg.h fix_spring_self.h fix_temp_rescale.h fix_tmd.h fix_uniaxial.h fix_viscous.h fix_volume_rescale.h fix_wall_gran.h fix_wall_lj126.h fix_wall_lj93.h fix_wall_reflect.h fix_wiggle.h force.h group.h improper.h improper_class2.h improper_cvff.h improper_harmonic.h improper_hybrid.h input.h integrate.h kspace.h lammps.h lattice.h library.h memory.h min.h min_cg.h min_cg_fr.h min_sd.h minimize.h modify.h neighbor.h output.h pack.h pair.h pair_buck.h pair_buck_coul_cut.h pair_buck_coul_long.h pair_dpd.h pair_eam.h pair_eam_alloy.h pair_eam_fs.h pair_gran_hertzian.h pair_gran_history.h pair_gran_no_history.h pair_hybrid.h pair_lj_charmm_coul_charmm.h pair_lj_charmm_coul_charmm_implicit.h pair_lj_charmm_coul_long.h pair_lj_class2.h pair_lj_class2_coul_cut.h pair_lj_class2_coul_long.h pair_lj_cut.h pair_lj_cut_coul_cut.h pair_lj_cut_coul_debye.h pair_lj_cut_coul_long.h pair_lj_cut_coul_long_tip4p.h pair_lj_expand.h pair_lj_smooth.h pair_morse.h pair_soft.h pair_sw.h pair_table.h pair_tersoff.h pair_yukawa.h pointers.h pppm.h pppm_tip4p.h random_mars.h random_park.h read_data.h read_restart.h region.h region_block.h region_cylinder.h region_intersect.h region_prism.h region_sphere.h region_union.h remap.h remap_wrap.h replicate.h respa.h run.h set.h shell.h special.h style.h style_class2.h style_dpd.h style_granular.h style_kspace.h style_manybody.h style_meam.h style_molecule.h style_poems.h style_user.h style_xtc.h temper.h thermo.h timer.h universe.h update.h variable.h velocity.h verlet.h write_restart.h
 
 OBJ = 	$(SRC:.cpp=.o)
 
diff --git a/src/POEMS/Install.csh b/src/POEMS/Install.csh
index 00fdf2503be632ce4e7d875a6db80c3886bce397..8e9577def74fe6e02c6823dbf2198c152a423b04 100644
--- a/src/POEMS/Install.csh
+++ b/src/POEMS/Install.csh
@@ -5,6 +5,7 @@ if ($1 == 1) then
   cp style_poems.h ..
 
   cp fix_poems.cpp ..
+
   cp fix_poems.h ..
 
 else if ($1 == 0) then
@@ -13,6 +14,7 @@ else if ($1 == 0) then
   touch ../style_poems.h
 
   rm ../fix_poems.cpp
+
   rm ../fix_poems.h
 
 endif
diff --git a/src/POEMS/fix_poems.cpp b/src/POEMS/fix_poems.cpp
index 8dbc778a83e89baf038a7be73593c7c805205354..d4a8ca3dc9006bbda70e9cbe4a67a917f4e41a20 100644
--- a/src/POEMS/fix_poems.cpp
+++ b/src/POEMS/fix_poems.cpp
@@ -1,7 +1,7 @@
 /* -----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -35,6 +35,8 @@
 #include "memory.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define MAXBODY 2         // currently 2 since only linear chains allowed
 #define DELTA 128
 #define TOLERANCE 1.0e-6
@@ -45,10 +47,11 @@
 #define MAX(A,B) ((A) > (B)) ? (A) : (B)
 
 /* ----------------------------------------------------------------------
-   constructor - define rigid bodies and joints, initiate POEMS
+   define rigid bodies and joints, initiate POEMS
 ------------------------------------------------------------------------- */
 
-FixPOEMS::FixPOEMS(int narg, char **arg) : Fix(narg, arg)
+FixPOEMS::FixPOEMS(LAMMPS *lmp, int narg, char **arg) :
+  Fix(lmp, narg, arg)
 {
   int i,j,ibody;
 
@@ -57,7 +60,7 @@ FixPOEMS::FixPOEMS(int narg, char **arg) : Fix(narg, arg)
   // can't use with pure granular style since mass arrays are different
   // hybrid granular style would be OK if fix were on non-granular atoms
 
-  if (strcmp(atom->style,"granular") == 0)
+  if (atom->check_style("granular"))
     error->all("Cannot use fix poems with atom style granular");
 
   // perform initial allocation of atom-based arrays
@@ -262,7 +265,7 @@ FixPOEMS::FixPOEMS(int narg, char **arg) : Fix(narg, arg)
 }
 
 /* ----------------------------------------------------------------------
-   destructor - free all memory for rigid bodies, joints, and POEMS
+   free all memory for rigid bodies, joints, and POEMS
 ------------------------------------------------------------------------- */
 
 FixPOEMS::~FixPOEMS()
diff --git a/src/POEMS/fix_poems.h b/src/POEMS/fix_poems.h
index da2a82c16c9ccbcc5bfca14cea57d5062452e97a..15a14c167cfc858708514fe31efd5aa54b435780 100644
--- a/src/POEMS/fix_poems.h
+++ b/src/POEMS/fix_poems.h
@@ -1,7 +1,7 @@
 /* -----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,11 +16,11 @@
 
 #include "fix.h"
 
-class Workspace;
+namespace LAMMPS_NS {
 
 class FixPOEMS : public Fix  {
  public:
-  FixPOEMS(int narg, char **arg);
+  FixPOEMS(class LAMMPS *, int narg, char **arg);
   ~FixPOEMS();
   int setmask();
   void init();
@@ -85,7 +85,7 @@ class FixPOEMS : public Fix  {
 
   // POEMS object
 
-  Workspace *poems;
+  class Workspace *poems;
 
   // internal class functions
 
@@ -102,4 +102,6 @@ class FixPOEMS : public Fix  {
   void set_xv(int);
 };
 
+}
+
 #endif
diff --git a/src/POEMS/style_poems.h b/src/POEMS/style_poems.h
index 28509dc307d1f64220df201fbfba2cd330275ccb..0434d02bf87bed749af2c5f286aeab1f3cb093d9 100644
--- a/src/POEMS/style_poems.h
+++ b/src/POEMS/style_poems.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
diff --git a/src/XTC/dump_xtc.cpp b/src/XTC/dump_xtc.cpp
index 193c337f092d58e2339367e4f467eb3a11d9b880..1cd662d13222eb123ae3d8915d9eee873710c588 100644
--- a/src/XTC/dump_xtc.cpp
+++ b/src/XTC/dump_xtc.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -32,6 +32,8 @@
 #include "error.h"
 #include "memory.h"
 
+using namespace LAMMPS_NS;
+
 #define EPS 1e-5
 #define XTC_MAGIC 1995
 
@@ -42,7 +44,7 @@ int xdr3dfcoord(XDR *, float *, int *, float *);
 
 /* ---------------------------------------------------------------------- */
 
-DumpXTC::DumpXTC(int narg, char **arg) : Dump(narg, arg)
+DumpXTC::DumpXTC(LAMMPS *lmp, int narg, char **arg) : Dump(lmp, narg, arg)
 {
   if (narg != 5 && narg != 6) error->all("Illegal dump xtc command");
   if (igroup != group->find("all")) error->all("Dump xtc must use group all");
diff --git a/src/XTC/dump_xtc.h b/src/XTC/dump_xtc.h
index e9968d29f15e1585662871a38a8b6093f7d156a1..dae715449de150f9b79806fae8d810e21c271540 100644
--- a/src/XTC/dump_xtc.h
+++ b/src/XTC/dump_xtc.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -18,9 +18,11 @@
 #include "rpc/rpc.h"
 #include "rpc/xdr.h"
 
+namespace LAMMPS_NS {
+
 class DumpXTC : public Dump {
  public:
-  DumpXTC(int, char**);
+  DumpXTC(class LAMMPS *, int, char**);
   ~DumpXTC();
   void init();
   int memory_usage();
@@ -41,4 +43,6 @@ class DumpXTC : public Dump {
   void write_frame();
 };
 
+}
+
 #endif
diff --git a/src/XTC/style_xtc.h b/src/XTC/style_xtc.h
index 13c21825d9e75be516fe3d81081bedafb29a4d8b..7110dda3121b80d9db78f85355f6563459cdf911 100644
--- a/src/XTC/style_xtc.h
+++ b/src/XTC/style_xtc.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
diff --git a/src/angle.h b/src/angle.h
index 3e6e9d659c1d8981fb8cbb8accc2523d54d9cabc..48e8fe441bbb3bf33c660a0578b8aa4c480a0a74 100644
--- a/src/angle.h
+++ b/src/angle.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -15,9 +15,11 @@
 #define ANGLE_H
 
 #include "stdio.h"
-#include "lammps.h"
+#include "pointers.h"
 
-class Angle : public LAMMPS {
+namespace LAMMPS_NS {
+
+class Angle : protected Pointers {
  public:
   int allocated;
   int *setflag;
@@ -25,7 +27,7 @@ class Angle : public LAMMPS {
   double virial[6];
   double PI;
 
-  Angle();
+  Angle(class LAMMPS *);
   virtual ~Angle() {}
   virtual void init();
   virtual void compute(int, int) = 0;
@@ -38,4 +40,6 @@ class Angle : public LAMMPS {
   virtual int memory_usage() {return 0;}
 };
 
+}
+
 #endif
diff --git a/src/atom.cpp b/src/atom.cpp
index 68d1524f977219220386c6f88fc8545b9fbb9120..0a965531683f4f04eb46b95797c2312615ec5c05 100644
--- a/src/atom.cpp
+++ b/src/atom.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -12,11 +12,11 @@
 ------------------------------------------------------------------------- */
 
 #include "mpi.h"
-#include "math.h"
 #include "stdio.h"
 #include "stdlib.h"
 #include "string.h"
 #include "atom.h"
+#include "atom_vec.h"
 #include "comm.h"
 #include "force.h"
 #include "modify.h"
@@ -29,111 +29,42 @@
 #include "memory.h"
 #include "error.h"
 
+#define AtomInclude
+#include "style.h"
+#undef AtomInclude
+
+using namespace LAMMPS_NS;
+
 #define MIN(A,B) ((A) < (B)) ? (A) : (B)
 #define MAX(A,B) ((A) > (B)) ? (A) : (B)
 
-#define DELTA 10000
-#define DELTA_CALLBACK 1
+#define DELTA 1
+#define DELTA_MEMSTR 1024
 
 /* ---------------------------------------------------------------------- */
 
-Atom::Atom(int narg, char **arg)
+Atom::Atom(LAMMPS *lmp) : Pointers(lmp)
 {
-  int n = strlen(arg[0]) + 1;
-  style = new char[n];
-  strcpy(style,arg[0]);
-  
-  // arg[0] sets one style flag to 1
-  
-  style_angle = style_atomic = style_bond = style_charge = style_dipole =
-    style_dpd = style_full = style_granular = style_molecular = 
-    style_peri = style_hybrid = 0;
-  
-  set_style(arg[0]);
-
-  // if hybrid style, set additional style for each additional arg
-  
-  if (style_hybrid) {
-    if (narg < 2) error->all("Illegal atom style hybrid command");
-    for (int i = 1; i < narg; i++) {
-      if (strcmp(arg[i],"hybrid") == 0) 
-	error->all("Atom style hybrid cannot have hybrid as an argument");
-      set_style(arg[i]);
-    }
-  }
-
-  // set low-level flags from style flags
-
-  mass_require = 0;
-  if (style_angle || style_atomic || style_bond || style_charge ||
-      style_dipole || style_dpd || style_full ||
-      style_molecular || style_hybrid) mass_require = 1;
-
-  mass_allow = 0;
-  if (style_granular || style_peri) mass_allow = 1;
-
-  charge_allow = 0;
-  if (style_charge || style_full || style_dipole) charge_allow = 1;
-
-  dipole_require = 0;
-  if (style_dipole) dipole_require = 1;
-
-  molecular = 0;
-  if (style_angle || style_bond || style_full || style_molecular)
-    molecular = 1;
-
-  bonds_allow = 0;
-  if (style_angle || style_bond || style_full || style_molecular)
-    bonds_allow = 1;
-
-  angles_allow = 0;
-  if (style_angle || style_full || style_molecular) angles_allow = 1;
-
-  dihedrals_allow = 0;
-  if (style_full || style_molecular) dihedrals_allow = 1;
-
-  impropers_allow = 0;
-  if (style_full || style_molecular) impropers_allow = 1;
+  // no atoms
 
-  // set size variables from styles
-  // if size_comm and size_reverse are changed,
-  //   must also change direct_flag in comm::init()
-
-  size_comm = 3;
-  if (style_dpd) size_comm += 3;                  // v
-  if (style_dipole) size_comm += 3;               // mu
-  if (style_granular) size_comm += 6;             // v,phiv
-
-  size_reverse = 3;
-  if (style_dipole) size_reverse += 3;            // torque
-  if (style_granular) size_reverse += 3;          // phia
-
-  size_border = 6;
-  if (charge_allow) size_border += 1;             // q
-  if (style_dpd) size_border += 3;                // v
-  if (style_dipole) size_border += 3;             // mu
-  if (style_granular) size_border += 8;           // v,phiv,radius,rmass
-  if (molecular) size_border += 1;                // molecule
-
-  size_atom_valid = 5;
-  if (molecular) size_atom_valid += 1;            // molecule
-  if (charge_allow) size_atom_valid += 1;         // q
-  if (style_granular) size_atom_valid += 2;       // radius,density
-  if (style_peri) size_atom_valid += 2;           // vfrac,rmass
-  if (style_dipole) size_atom_valid += 3;         // mu
+  natoms = nlocal = nghost = nmax = 0;
+  ntypes = 0;
+  nbondtypes = nangletypes = ndihedraltypes = nimpropertypes = 0;
+  nbonds = nangles = ndihedrals = nimpropers = 0;
+  bond_per_atom = angle_per_atom = dihedral_per_atom = improper_per_atom = 0;
 
-  // initialize atom arrays to empty
+  // atom arrays
+  // customize by adding new array
 
   tag = type = mask = image = NULL;
   x = v = f = NULL;
 
+  molecule = NULL;
   q = NULL;
   mu = omega = torque = NULL;
   phix = phiv = phia = NULL;
   radius = density = rmass = vfrac = NULL;
 
-  molecule = NULL;
-
   maxspecial = 1;
   nspecial = NULL;
   special = NULL;
@@ -152,21 +83,9 @@ Atom::Atom(int narg, char **arg)
   improper_type = improper_atom1 = improper_atom2 = NULL;
   improper_atom3 = improper_atom4 = NULL;
 
-  // set data and restart file header values to defaults
+  hybrid = NULL;
 
-  natoms = 0;
-  nbonds = nangles = ndihedrals = nimpropers = 0;
-  ntypes = 0;
-  nbondtypes = nangletypes = ndihedraltypes = nimpropertypes = 0;
-  bond_per_atom = angle_per_atom = dihedral_per_atom = improper_per_atom = 0;
-
-  // no atoms initially
-
-  nlocal = 0;
-  nghost = 0;
-  nmax = 0;
-
-  // ntype length arrays
+  // ntype-length arrays
 
   mass = NULL;
   mass_setflag = NULL;
@@ -181,11 +100,10 @@ Atom::Atom(int narg, char **arg)
   nextra_store = 0;
   extra = NULL;
 
-  // set default mapping values and hash table primes
+  // default mapping values and hash table primes
 
   tag_enable = 1;
-  if (molecular) map_style = 1;
-  else map_style = 0;
+  map_style = 0;
   map_tag_max = 0;
   map_nhash = 0;
   
@@ -198,16 +116,22 @@ Atom::Atom(int narg, char **arg)
 		 330017,340007,350003,362881,3628801};
   for (int i = 0; i < nprimes; i++) primes[i] = plist[i];
 
-  // constant
+  // default atom style = atomic
 
-  PI = 4.0*atan(1.0);
+  atom_style = NULL;
+  avec = NULL;
+  create_avec("atomic",0,NULL);
 }
 
 /* ---------------------------------------------------------------------- */
 
 Atom::~Atom()
 {
+  delete [] atom_style;
+  delete avec;
+
   // delete atom arrays
+  // customize by adding new array
 
   memory->sfree(tag);
   memory->sfree(type);
@@ -258,9 +182,9 @@ Atom::~Atom()
   memory->destroy_2d_int_array(improper_atom3);
   memory->destroy_2d_int_array(improper_atom4);
 
-  // delete auxiliary arrays
+  memory->sfree(hybrid);
 
-  delete [] style;
+  // delete per-type arrays
 
   delete [] mass;
   delete [] mass_setflag;
@@ -275,94 +199,43 @@ Atom::~Atom()
   delete [] primes;
 }
 
-/* ---------------------------------------------------------------------- */
-
-void Atom::set_style(char *name)
-{
-  if (strcmp(name,"angle") == 0) style_angle = 1;
-  else if (strcmp(name,"atomic") == 0) style_atomic = 1;
-  else if (strcmp(name,"bond") == 0) style_bond = 1;
-  else if (strcmp(name,"charge") == 0) style_charge = 1;
-  else if (strcmp(name,"dipole") == 0) style_dipole = 1;
-  else if (strcmp(name,"dpd") == 0) style_dpd = 1;
-  else if (strcmp(name,"full") == 0) style_full = 1;
-  else if (strcmp(name,"granular") == 0) style_granular = 1;
-  else if (strcmp(name,"molecular") == 0) style_molecular = 1;
-  else if (strcmp(name,"peri") == 0) style_peri = 1;
-  else if (strcmp(name,"hybrid") == 0) style_hybrid = 1;
-  else error->all("Illegal atom_style command");
-}
-
 /* ----------------------------------------------------------------------
-   return 1 if named atom style is set as pure style or sub-class of hybrid
-   else return 0
+   create an AtomVec style
+   called from input script, restart file, replicate
 ------------------------------------------------------------------------- */
 
-int Atom::check_style(char *name)
+void Atom::create_avec(char *style, int narg, char **arg)
 {
-  if (!strcmp(name,"angle") && style_angle) return 1;
-  else if (!strcmp(name,"atomic") && style_atomic) return 1;
-  else if (!strcmp(name,"bond") && style_bond) return 1;
-  else if (!strcmp(name,"charge") && style_charge) return 1;
-  else if (!strcmp(name,"dipole") && style_dipole) return 1;
-  else if (!strcmp(name,"dpd") && style_dpd) return 1;
-  else if (!strcmp(name,"full") && style_full) return 1;
-  else if (!strcmp(name,"granular") && style_granular) return 1;
-  else if (!strcmp(name,"molecular") && style_molecular) return 1;
-  else if (!strcmp(name,"peri") && style_peri) return 1;
-  else if (!strcmp(name,"hybrid") && style_hybrid) return 1;
-  return 0;
-}
+  delete [] atom_style;
+  if (avec) delete avec;
 
-/* ----------------------------------------------------------------------
-   convert style settings to list of keywords
-   put "hybrid" first if it is set
-   return list and number of words in list
-------------------------------------------------------------------------- */
+  avec = new_avec(style,narg,arg);
+  int n = strlen(style) + 1;
+  atom_style = new char[n];
+  strcpy(atom_style,style);
 
-int Atom::style2arg(char **&name)
-{
-  int n = style_angle + style_atomic + style_bond + style_charge +
-    style_dipole + style_dpd + style_full + 
-    style_granular + style_molecular + style_peri + style_hybrid;
-
-  name = new char*[n];
-
-  n = 0;
-  if (style_hybrid) name[n++] = style2word("hybrid");
-  if (style_angle) name[n++] = style2word("angle");
-  if (style_atomic) name[n++] = style2word("atomic");
-  if (style_bond) name[n++] = style2word("bond");
-  if (style_charge) name[n++] = style2word("charge");
-  if (style_dipole) name[n++] = style2word("dipole");
-  if (style_dpd) name[n++] = style2word("dpd");
-  if (style_full) name[n++] = style2word("full");
-  if (style_granular) name[n++] = style2word("granular");
-  if (style_molecular) name[n++] = style2word("molecular");
-  if (style_peri) name[n++] = style2word("peri");
+  // if molecular system, default is to have array map
 
-  return n;
+  molecular = avec->molecular;
+  if (map_style == 0 && molecular) map_style = 1;
 }
 
 /* ----------------------------------------------------------------------
-   copy modify settings from old Atom class to current Atom class
+   generate an AtomVec class
 ------------------------------------------------------------------------- */
 
-void Atom::settings(Atom *old)
+AtomVec *Atom::new_avec(char *style, int narg, char **arg)
 {
-  map_style = old->map_style;
-}
+  if (0) return NULL;
 
-/* ----------------------------------------------------------------------
-   copy name into new word string
-------------------------------------------------------------------------- */
+#define AtomClass
+#define AtomStyle(key,Class) \
+  else if (strcmp(style,#key) == 0) return new Class(lmp,narg,arg);
+#include "style.h"
+#undef AtomClass
 
-char *Atom::style2word(char *name)
-{
-  int n = strlen(name) + 1;
-  char *word = new char[n];
-  strcpy(word,name);
-  return word;
+  else error->all("Invalid atom style");
+  return NULL;
 }
 
 /* ---------------------------------------------------------------------- */
@@ -382,167 +255,25 @@ void Atom::init()
   check_mass();
   check_dipole();
 
-  // for dipole style:
-  // for dipole type atoms, check that dipole moment is set, normalize it
-  // for non-dipole type atoms, check that dipole moment is 0.0
-
-  if (style_dipole) {
-    double msq,scale;
-    int flag = 0;
-    for (int i = 0; i < nlocal; i++) {
-      msq = mu[i][0]*mu[i][0] + mu[i][1]*mu[i][1] + mu[i][2]*mu[i][2];
-      if (dipole[type[i]] > 0.0 && msq == 0.0) flag++;
-      else if (dipole[type[i]] > 0.0) {
-	scale = dipole[type[i]]/sqrt(msq);
-	mu[i][0] *= scale;
-	mu[i][1] *= scale;
-	mu[i][2] *= scale;
-      }
-      else if (dipole[type[i]] == 0.0 && msq > 0.0) flag++;
-    }
-    int flag_all;
-    MPI_Allreduce(&flag,&flag_all,1,MPI_INT,MPI_SUM,world);
-    if (flag) error->all("Inconsistent dipole settings for some atoms");
-  }
-
-  // for granular style:
-  // insure LJ units and thermo style granular or custom is used
+  // init sub-style
 
-  if (style_granular) {
-    if (strcmp(update->unit_style,"lj") != 0)
-      error->all("Must use lj units with atom style granular");
-    if ((strcmp(output->thermo->style,"granular") != 0) &&
-	(strcmp(output->thermo->style,"custom") != 0))
-      error->all("Must use atom style granular with granular thermo output");
-  }
-
-  // don't allow granular and dpd styles together
-  // only reason is that they both communicate v in pack_comm
-  // ok if use better logic for setting size_comm and atom_hybrid::pack_comm
-
-  if (style_granular && style_dpd)
-    error->all("Atom style granular and dpd cannot be used together");
+  avec->init();
 }
 
 /* ----------------------------------------------------------------------
-   grow atom arrays
-   n = 0 grows arrays by DELTA
-   n > 0 allocates arrays to size n 
+   check if atom style matches style
+   if hybrid, any sub-style can be a match
 ------------------------------------------------------------------------- */
 
-void Atom::grow(int n)
+int Atom::check_style(char *style)
 {
-  if (n == 0) nmax += DELTA;
-  else nmax = n;
-
-  tag = (int *) memory->srealloc(tag,nmax*sizeof(int),"atom:tag");
-  type = (int *) memory->srealloc(type,nmax*sizeof(int),"atom:type");
-  mask = (int *) memory->srealloc(mask,nmax*sizeof(int),"atom:mask");
-  image = (int *) memory->srealloc(image,nmax*sizeof(int),"atom:image");
-  x = memory->grow_2d_double_array(x,nmax,3,"atom:x");
-  v = memory->grow_2d_double_array(v,nmax,3,"atom:v");
-  f = memory->grow_2d_double_array(f,nmax,3,"atom:f");
-
-  if (charge_allow)
-    q = (double *) memory->srealloc(q,nmax*sizeof(double),"atom:q");
-  if (mass_allow)
-    rmass = (double *) memory->srealloc(rmass,nmax*sizeof(double),
-					"atom:rmass");
-
-  if (style_dipole) {
-    mu = memory->grow_2d_double_array(mu,nmax,3,"atom:mu");
-    omega = memory->grow_2d_double_array(omega,nmax,3,"atom:omega");
-    torque = memory->grow_2d_double_array(torque,nmax,3,"atom:torque");
-  }
-
-  if (style_granular) {
-    phix = memory->grow_2d_double_array(phix,nmax,3,"atom:phix");
-    phiv = memory->grow_2d_double_array(phiv,nmax,3,"atom:phiv");
-    phia = memory->grow_2d_double_array(phia,nmax,3,"atom:phia");
-    radius = (double *) memory->srealloc(radius,nmax*sizeof(double),
-					 "atom:radius");
-    density = (double *) memory->srealloc(density,nmax*sizeof(double),
-					  "atom:density");
+  if (strcmp(atom_style,style) == 0) return 1;
+  else if (strcmp(atom_style,"hybrid") == 0) {
+    AtomVecHybrid *avec_hybrid = (AtomVecHybrid *) avec;
+    for (int i = 0; i < avec_hybrid->nstyles; i++)
+      if (strcmp(avec_hybrid->keywords[i],style) == 0) return 1;
   }
-
-  if (style_peri)
-    vfrac = (double *) memory->srealloc(vfrac,nmax*sizeof(double),
-					"atom:vfrac");
-
-  if (molecular) {
-    molecule = (int *) 
-      memory->srealloc(molecule,nmax*sizeof(int),"atom:molecule");
-
-    nspecial = memory->grow_2d_int_array(nspecial,nmax,3,"atom:nspecial");
-    special = 
-      memory->grow_2d_int_array(special,nmax,maxspecial,"atom:special");
-
-    if (bonds_allow) {
-      num_bond = (int *) 
-	memory->srealloc(num_bond,nmax*sizeof(int),"atom:num_bond");
-      bond_type = memory->grow_2d_int_array(bond_type,nmax,bond_per_atom,
-					    "atom:bond_type");
-      bond_atom = memory->grow_2d_int_array(bond_atom,nmax,bond_per_atom,
-					    "atom:bond_atom");
-    }
-
-    if (angles_allow) {
-      num_angle = (int *) 
-	memory->srealloc(num_angle,nmax*sizeof(int),"atom:num_angle");
-      angle_type = memory->grow_2d_int_array(angle_type,nmax,angle_per_atom,
-					     "atom:angle_type");
-      angle_atom1 = memory->grow_2d_int_array(angle_atom1,nmax,angle_per_atom,
-					      "atom:angle_atom1");
-      angle_atom2 = memory->grow_2d_int_array(angle_atom2,nmax,angle_per_atom,
-					      "atom:angle_atom2");
-      angle_atom3 = memory->grow_2d_int_array(angle_atom3,nmax,angle_per_atom,
-					      "atom:angle_atom3");
-    }
-
-    if (dihedrals_allow) {
-      num_dihedral = (int *) 
-	memory->srealloc(num_dihedral,nmax*sizeof(int),"atom:num_dihedral");
-      dihedral_type = 
-	memory->grow_2d_int_array(dihedral_type,nmax,dihedral_per_atom,
-				  "atom:dihedral_type");
-      dihedral_atom1 = 
-	memory->grow_2d_int_array(dihedral_atom1,nmax,dihedral_per_atom,
-				  "atom:dihedral_atom1");
-      dihedral_atom2 = 
-	memory->grow_2d_int_array(dihedral_atom2,nmax,dihedral_per_atom,
-				  "atom:dihedral_atom2");
-      dihedral_atom3 = 
-	memory->grow_2d_int_array(dihedral_atom3,nmax,dihedral_per_atom,
-				  "atom:dihedral_atom3");
-      dihedral_atom4 = 
-	memory->grow_2d_int_array(dihedral_atom4,nmax,dihedral_per_atom,
-				  "atom:dihedral_atom4");
-    }
-    
-    if (impropers_allow) {
-      num_improper = (int *) 
-	memory->srealloc(num_improper,nmax*sizeof(int),"atom:num_improper");
-      improper_type = 
-	memory->grow_2d_int_array(improper_type,nmax,improper_per_atom,
-				  "atom:improper_type");
-      improper_atom1 = 
-	memory->grow_2d_int_array(improper_atom1,nmax,improper_per_atom,
-				  "atom:improper_atom1");
-      improper_atom2 = 
-	memory->grow_2d_int_array(improper_atom2,nmax,improper_per_atom,
-				  "atom:improper_atom2");
-      improper_atom3 = 
-	memory->grow_2d_int_array(improper_atom3,nmax,improper_per_atom,
-				  "atom:improper_atom3");
-      improper_atom4 = 
-	memory->grow_2d_int_array(improper_atom4,nmax,improper_per_atom,
-				  "atom:improper_atom4");
-    }
-  }
-
-  if (nextra_grow)
-    for (int iextra = 0; iextra < nextra_grow; iextra++) 
-      modify->fix[extra_grow[iextra]]->grow_arrays(nmax);
+  return 0;
 }
 
 /* ----------------------------------------------------------------------
@@ -856,18 +587,6 @@ int Atom::tag_consecutive()
   return 1;
 }
 
-/* ----------------------------------------------------------------------
-   parse one atom line from data file, check if valid for atom style 
-------------------------------------------------------------------------- */
-
-int Atom::parse_data(char *line)
-{
-  size_atom_actual = count_words(line);
-  if (size_atom_actual == size_atom_valid || 
-      size_atom_actual == size_atom_valid + 3) return 0;
-  else return 1;
-}
-
 /* ----------------------------------------------------------------------
    count and return words in a single line
    make copy of line before using strtok so as not to change line
@@ -895,26 +614,102 @@ int Atom::count_words(char *line)
 }
 
 /* ----------------------------------------------------------------------
+   unpack n lines from Atom section of data file
+   set all atom values and defaults
+------------------------------------------------------------------------- */
+
+void Atom::data_atoms(int n, char *buf, int ihybrid)
+{
+  int m,imagetmp,xptr,iptr;
+  double xtmp,ytmp,ztmp;
+  char *next;
+
+  next = strchr(buf,'\n');
+  *next = '\0';
+  int nwords = count_words(buf);
+  *next = '\n';
+
+  avec->data_params(ihybrid);
+  if (nwords != avec->size_data_atom && nwords != avec->size_data_atom + 3)
+    error->all("Incorrect atom format in data file");
+
+  char **values = new char*[nwords];
+
+  double subxlo = domain->subxlo;
+  double subxhi = domain->subxhi;
+  double subylo = domain->subylo;
+  double subyhi = domain->subyhi;
+  double subzlo = domain->subzlo;
+  double subzhi = domain->subzhi;
+
+  // xptr = which word in line starts xyz coords
+  // iptr = which word in line starts ix,iy,iz image flags
+
+  xptr = avec->xcol_data - 1;
+  int imageflag = 0;
+  if (nwords > avec->size_data_atom) imageflag = 1;
+  if (imageflag) iptr = nwords - 3;
+
+  // loop over lines of atom data
+  // tokenize the line into values
+  // extract xyz coords and image flags, remap them
+  // if atom is in my sub-domain, unpack its values
+
+  for (int i = 0; i < n; i++) {
+    next = strchr(buf,'\n');
+
+    values[0] = strtok(buf," \t\n\r\f");
+    for (m = 1; m < nwords; m++)
+      values[m] = strtok(NULL," \t\n\r\f");
+
+    xtmp = atof(values[xptr]);
+    ytmp = atof(values[xptr+1]);
+    ztmp = atof(values[xptr+2]);
+    if (imageflag)
+      imagetmp = ((atoi(values[iptr+2]) + 512 & 1023) << 20) |
+	((atoi(values[iptr+1]) + 512 & 1023) << 10) |
+	(atoi(values[iptr]) + 512 & 1023);
+    else imagetmp = (512 << 20) | (512 << 10) | 512;
+
+    domain->remap(xtmp,ytmp,ztmp,imagetmp);
+    if (xtmp >= subxlo && xtmp < subxhi &&
+	ytmp >= subylo && ytmp < subyhi &&
+	ztmp >= subzlo && ztmp < subzhi)
+      avec->data_atom(xtmp,ytmp,ztmp,imagetmp,values,ihybrid);
+
+    buf = next + 1;
+  }
+
+  delete [] values;
+}
+
+/* ----------------------------------------------------------------------
+   unpack n lines from Velocity section of data file
    check that atom IDs are > 0 and <= map_tag_max
+   call style-specific routine to parse line
 ------------------------------------------------------------------------- */
 
-void Atom::unpack_vels(int n, char *buf)
+void Atom::data_vels(int n, char *buf, int ihybrid)
 {
   int m,tagtmp;
-  double vxtmp,vytmp,vztmp;
   char *next;
 
+  next = strchr(buf,'\n');
+  *next = '\0';
+  int nwords = count_words(buf);
+  *next = '\n';
+
+  avec->data_params(ihybrid);
+  if (nwords != avec->size_data_vel)
+    error->all("Incorrect velocity format in data file");
+
   for (int i = 0; i < n; i++) {
     next = strchr(buf,'\n');
     *next = '\0';
-    sscanf(buf,"%d %lg %lg %lg",&tagtmp,&vxtmp,&vytmp,&vztmp);
+    sscanf(buf,"%d",&tagtmp);
     if (tagtmp <= 0 || tagtmp > map_tag_max)
       error->one("Invalid atom ID in Velocities section of data file");
-    if ((m = map(tagtmp)) >= 0) {
-      v[m][0] = vxtmp;
-      v[m][1] = vytmp;
-      v[m][2] = vztmp;
-    }
+    if ((m = map(tagtmp)) >= 0) avec->data_vel(m,buf,ihybrid);
     buf = next + 1;
   }
 }
@@ -923,7 +718,7 @@ void Atom::unpack_vels(int n, char *buf)
    check that atom IDs are > 0 and <= map_tag_max
 ------------------------------------------------------------------------- */
 
-void Atom::unpack_bonds(int n, char *buf)
+void Atom::data_bonds(int n, char *buf)
 {
   int m,tmp,itype,atom1,atom2;
   char *next;
@@ -958,7 +753,7 @@ void Atom::unpack_bonds(int n, char *buf)
    check that atom IDs are > 0 and <= map_tag_max
 ------------------------------------------------------------------------- */
 
-void Atom::unpack_angles(int n, char *buf)
+void Atom::data_angles(int n, char *buf)
 {
   int m,tmp,itype,atom1,atom2,atom3;
   char *next;
@@ -1005,7 +800,7 @@ void Atom::unpack_angles(int n, char *buf)
    check that atom IDs are > 0 and <= map_tag_max
 ------------------------------------------------------------------------- */
 
-void Atom::unpack_dihedrals(int n, char *buf)
+void Atom::data_dihedrals(int n, char *buf)
 {
   int m,tmp,itype,atom1,atom2,atom3,atom4;
   char *next;
@@ -1064,7 +859,7 @@ void Atom::unpack_dihedrals(int n, char *buf)
    check that atom IDs are > 0 and <= map_tag_max
 ------------------------------------------------------------------------- */
 
-void Atom::unpack_impropers(int n, char *buf)
+void Atom::data_impropers(int n, char *buf)
 {
   int m,tmp,itype,atom1,atom2,atom3,atom4;
   char *next;
@@ -1126,12 +921,12 @@ void Atom::unpack_impropers(int n, char *buf)
 
 void Atom::allocate_type_arrays()
 {
-  if (mass_require) {
+  if (avec->mass_type) {
     mass = new double[ntypes+1];
     mass_setflag = new int[ntypes+1];
     for (int itype = 1; itype <= ntypes; itype++) mass_setflag[itype] = 0;
   }
-  if (dipole_require) {
+  if (avec->dipole_type) {
     dipole = new double[ntypes+1];
     dipole_setflag = new int[ntypes+1];
     for (int itype = 1; itype <= ntypes; itype++) dipole_setflag[itype] = 0;
@@ -1145,7 +940,7 @@ void Atom::allocate_type_arrays()
 
 void Atom::set_mass(char *str)
 {
-  if (mass_require == 0) error->all("Cannot set mass for this atom style");
+  if (mass == NULL) error->all("Cannot set mass for this atom style");
 
   int itype;
   double mass_one;
@@ -1164,7 +959,7 @@ void Atom::set_mass(char *str)
 
 void Atom::set_mass(int itype, double value)
 {
-  if (mass_require == 0) error->all("Cannot set mass for this atom style");
+  if (mass == NULL) error->all("Cannot set mass for this atom style");
   if (itype < 1 || itype > ntypes) error->all("Invalid type for mass set");
 
   mass[itype] = value;
@@ -1178,7 +973,7 @@ void Atom::set_mass(int itype, double value)
 
 void Atom::set_mass(int narg, char **arg)
 {
-  if (mass_require == 0) error->all("Cannot set mass for this atom style");
+  if (mass == NULL) error->all("Cannot set mass for this atom style");
 
   int lo,hi;
   force->bounds(arg[0],ntypes,lo,hi);
@@ -1208,7 +1003,7 @@ void Atom::set_mass(double *values)
 
 void Atom::check_mass()
 {
-  if (!mass_require) return;
+  if (mass == NULL) return;
   for (int itype = 1; itype <= ntypes; itype++)
     if (mass_setflag[itype] == 0) error->all("All masses are not set");
 }
@@ -1220,8 +1015,7 @@ void Atom::check_mass()
 
 void Atom::set_dipole(char *str)
 {
-  if (dipole_require == 0) 
-    error->all("Cannot set dipole for this atom style");
+  if (dipole == NULL) error->all("Cannot set dipole for this atom style");
 
   int i;
   double dipole_one;
@@ -1238,8 +1032,7 @@ void Atom::set_dipole(char *str)
 
 void Atom::set_dipole(int narg, char **arg)
 {
-  if (dipole_require == 0) 
-    error->all("Cannot set dipole for this atom style");
+  if (dipole == NULL) error->all("Cannot set dipole for this atom style");
 
   int lo,hi;
   force->bounds(arg[0],ntypes,lo,hi);
@@ -1269,7 +1062,7 @@ void Atom::set_dipole(double *values)
 
 void Atom::check_dipole()
 {
-  if (!dipole_require) return;
+  if (dipole == NULL) return;
   for (int itype = 1; itype <= ntypes; itype++)
     if (dipole_setflag[itype] == 0)
       error->all("All dipole moments are not set");
@@ -1298,7 +1091,7 @@ void Atom::add_callback(int flag)
 
   if (flag == 0) {
     if (nextra_grow == nextra_grow_max) {
-      nextra_grow_max += DELTA_CALLBACK;
+      nextra_grow_max += DELTA;
       extra_grow = (int *) 
 	memory->srealloc(extra_grow,nextra_grow_max*sizeof(int),
 			 "atom:extra_grow");
@@ -1307,7 +1100,7 @@ void Atom::add_callback(int flag)
     nextra_grow++;
   } else if (flag == 1) {
     if (nextra_restart == nextra_restart_max) {
-      nextra_restart_max += DELTA_CALLBACK;
+      nextra_restart_max += DELTA;
       extra_restart = (int *) 
 	memory->srealloc(extra_restart,nextra_restart_max*sizeof(int),
 			 "atom:extra_restart");
@@ -1326,7 +1119,6 @@ void Atom::add_callback(int flag)
 void Atom::delete_callback(char *id, int flag)
 {
   int ifix;
-
   for (ifix = 0; ifix < modify->nfix; ifix++)
     if (strcmp(id,modify->fix[ifix]->id) == 0) break;
 
@@ -1357,469 +1149,18 @@ void Atom::update_callback(int ifix)
 }
 
 /* ----------------------------------------------------------------------
-   unpack n lines of atoms from buf
-   set all atom values and defaults
-------------------------------------------------------------------------- */
-
-void Atom::unpack_data(int n, char *buf)
-{
-  int m,imagetmp,xptr,iptr;
-  double xtmp,ytmp,ztmp;
-  char *next;
-
-  double subxlo = domain->subxlo;
-  double subxhi = domain->subxhi;
-  double subylo = domain->subylo;
-  double subyhi = domain->subyhi;
-  double subzlo = domain->subzlo;
-  double subzhi = domain->subzhi;
-
-  char **values = new char*[size_atom_actual];
-
-  // xptr = which word in line is start of xyz coords
-  // iptr = which word in line is start of ix,iy,iz image flags
-
-  xptr = 2;
-  if (molecular) xptr++;
-  if (charge_allow) xptr++;
-  if (style_granular) xptr += 2;
-  if (style_peri) xptr += 2;
-
-  int imageflag = 0;
-  if (size_atom_actual > size_atom_valid) imageflag = 1;
-  if (imageflag) iptr = size_atom_actual - 3;
-
-  // loop over lines of atom data
-  // tokenize the line into values
-  // extract xyz coords and image flags
-  // if atom is in my sub-domain, set its values
-  // scan thru values in ascending order, storing ones appropriate to style
-
-  for (int i = 0; i < n; i++) {
-    next = strchr(buf,'\n');
-
-    values[0] = strtok(buf," \t\n\r\f");
-    for (m = 1; m < size_atom_actual; m++)
-      values[m] = strtok(NULL," \t\n\r\f");
-
-    xtmp = atof(values[xptr]);
-    ytmp = atof(values[xptr+1]);
-    ztmp = atof(values[xptr+2]);
-    if (imageflag)
-      imagetmp = ((atoi(values[iptr+2]) + 512 & 1023) << 20) |
-	((atoi(values[iptr+1]) + 512 & 1023) << 10) |
-	(atoi(values[iptr]) + 512 & 1023);
-    else imagetmp = (512 << 20) | (512 << 10) | 512;
-
-    domain->remap(xtmp,ytmp,ztmp,imagetmp);
-    if (xtmp >= subxlo && xtmp < subxhi &&
-	ytmp >= subylo && ytmp < subyhi &&
-	ztmp >= subzlo && ztmp < subzhi) {
-
-      if (nlocal == nmax) grow(0);
-
-      // parse quantities in prescribed order depending on atom style(s)
-
-      m = 0;
-      tag[nlocal] = atoi(values[m++]);
-      if (tag[nlocal] <= 0)
-	error->one("Invalid atom ID in Atoms section of data file");
-
-      if (molecular) molecule[nlocal] = atoi(values[m++]);
-
-      type[nlocal] = atoi(values[m++]);
-      if (type[nlocal] <= 0 || type[nlocal] > ntypes)
-	error->one("Invalid atom type in Atoms section of data file");
-
-      if (charge_allow) q[nlocal] = atof(values[m++]);
-      if (style_granular) {
-	radius[nlocal] = 0.5 * atof(values[m++]);
-	density[nlocal] = atof(values[m++]);
-	if (force->dimension == 3)
-	  rmass[nlocal] = 4.0*PI/3.0 *
-	    radius[nlocal]*radius[nlocal]*radius[nlocal] * density[nlocal];
-	else
-	  rmass[nlocal] = PI * radius[nlocal]*radius[nlocal] * density[nlocal];
-      }
-      if (style_peri) {
-	vfrac[nlocal] = atof(values[m++]);
-	rmass[nlocal] = atof(values[m++]);
-      }
-
-      x[nlocal][0] = xtmp;
-      x[nlocal][1] = ytmp;
-      x[nlocal][2] = ztmp;
-      m += 3;
-
-      if (style_dipole) {
-	mu[nlocal][0] = atof(values[m++]);
-	mu[nlocal][1] = atof(values[m++]);
-	mu[nlocal][2] = atof(values[m++]);
-      }
-      image[nlocal] = imagetmp;
-
-      // initialize quantities not included in Atom section of data file
-
-      mask[nlocal] = 1;
-      v[nlocal][0] = 0.0;
-      v[nlocal][1] = 0.0;
-      v[nlocal][2] = 0.0;
-
-      if (style_dipole) {
-	omega[nlocal][0] = 0.0;
-	omega[nlocal][1] = 0.0;
-	omega[nlocal][2] = 0.0;
-      }
-
-      if (style_granular) {
-	phix[nlocal][0] = 0.0;
-	phix[nlocal][1] = 0.0;
-	phix[nlocal][2] = 0.0;
-	phiv[nlocal][0] = 0.0;
-	phiv[nlocal][1] = 0.0;
-	phiv[nlocal][2] = 0.0;
-      }
-
-      if (bonds_allow) num_bond[nlocal] = 0;
-      if (angles_allow) num_angle[nlocal] = 0;
-      if (dihedrals_allow) num_dihedral[nlocal] = 0;
-      if (impropers_allow) num_improper[nlocal] = 0;
-      
-      nlocal++;
-    }
-
-    buf = next + 1;
-  }
-
-  delete [] values;
-}
-
-/* ----------------------------------------------------------------------
-   create one atom of type itype at x0,y0,z0
-   set all other values to defaults
-------------------------------------------------------------------------- */
-
-void Atom::create_one(int itype, double x0, double y0, double z0)
-{
-  if (nlocal == nmax) grow(0);
-
-  tag[nlocal] = 0;
-  type[nlocal] = itype;
-  x[nlocal][0] = x0;
-  x[nlocal][1] = y0;
-  x[nlocal][2] = z0;
-  mask[nlocal] = 1;
-  image[nlocal] = (512 << 20) | (512 << 10) | 512;
-  v[nlocal][0] = 0.0;
-  v[nlocal][1] = 0.0;
-  v[nlocal][2] = 0.0;
-
-  if (charge_allow) q[nlocal] = 0.0;
-
-  if (style_dipole) {
-    mu[nlocal][0] = 0.0;
-    mu[nlocal][1] = 0.0;
-    mu[nlocal][2] = 0.0;
-    omega[nlocal][0] = 0.0;
-    omega[nlocal][1] = 0.0;
-    omega[nlocal][2] = 0.0;
-  }
-
-  if (style_granular) {
-    radius[nlocal] = 0.5;
-    density[nlocal] = 1.0;
-    if (force->dimension == 3)
-      rmass[nlocal] = 4.0*PI/3.0 *
-	radius[nlocal]*radius[nlocal]*radius[nlocal] * density[nlocal];
-    else
-      rmass[nlocal] = PI * radius[nlocal]*radius[nlocal] * density[nlocal];
-    phix[nlocal][0] = 0.0;
-    phix[nlocal][1] = 0.0;
-    phix[nlocal][2] = 0.0;
-    phiv[nlocal][0] = 0.0;
-    phiv[nlocal][1] = 0.0;
-    phiv[nlocal][2] = 0.0;
-  }
-
-  if (style_peri) {
-    vfrac[nlocal] = 1.0;
-    rmass[nlocal] = 1.0;
-  }
-
-  if (molecular) {
-    molecule[nlocal] = 0;
-    if (bonds_allow) num_bond[nlocal] = 0;
-    if (angles_allow) num_angle[nlocal] = 0;
-    if (dihedrals_allow) num_dihedral[nlocal] = 0;
-    if (impropers_allow) num_improper[nlocal] = 0;
-  }
-
-  nlocal++;
-}
-
-/* ---------------------------------------------------------------------- */
-
-int Atom::size_restart()
-{
-  int i;
-
-  int n = 0;
-  for (i = 0; i < nlocal; i++) {
-    n += 11;
-    if (charge_allow) n++;
-    if (style_dipole) n += 6;
-    if (style_granular) n += 8;
-    if (style_peri) n += 5;
-    if (molecular) {
-      n++;
-      if (bonds_allow) n += 1 + 2*num_bond[i];
-      if (angles_allow) n += 1 + 4*num_angle[i];
-      if (dihedrals_allow) n += 1 + 5*num_dihedral[i];
-      if (impropers_allow) n += 1 + 5*num_improper[i];
-    }
-  }
-
-  if (nextra_restart)
-    for (int iextra = 0; iextra < nextra_restart; iextra++) 
-      for (i = 0; i < nlocal; i++)
-	n += modify->fix[extra_restart[iextra]]->size_restart(i);
-
-  return n;
-}
-
-/* ----------------------------------------------------------------------
-   pack all atom quantities for restart file including extra quantities
-   xyz must be 1st 3 values, so that read_restart can test on them
-   interaction types may be negative, but write as positive   
-------------------------------------------------------------------------- */
-
-int Atom::pack_restart(int i, double *buf)
-{
-  int k;
-
-  int m = 1;
-  buf[m++] = x[i][0];
-  buf[m++] = x[i][1];
-  buf[m++] = x[i][2];
-  buf[m++] = tag[i];
-  buf[m++] = type[i];
-  buf[m++] = mask[i];
-  buf[m++] = image[i];
-  buf[m++] = v[i][0];
-  buf[m++] = v[i][1];
-  buf[m++] = v[i][2];
-
-  if (charge_allow) buf[m++] = q[i];
-
-  if (style_dipole) {
-    buf[m++] = mu[i][0];
-    buf[m++] = mu[i][1];
-    buf[m++] = mu[i][2];
-    buf[m++] = omega[i][0];
-    buf[m++] = omega[i][1];
-    buf[m++] = omega[i][2];
-  }
-
-  if (style_granular) {
-    buf[m++] = phix[i][0];
-    buf[m++] = phix[i][1];
-    buf[m++] = phix[i][2];
-    buf[m++] = phiv[i][0];
-    buf[m++] = phiv[i][1];
-    buf[m++] = phiv[i][2];
-    buf[m++] = radius[i];
-    buf[m++] = density[i];
-  }
-
-  if (style_peri) {
-    buf[m++] = vfrac[i];
-    buf[m++] = rmass[i];
-  }
-
-  if (molecular) {
-    buf[m++] = molecule[i];
-
-    if (bonds_allow) {
-      buf[m++] = num_bond[i];
-      for (k = 0; k < num_bond[i]; k++) {
-	buf[m++] = MAX(bond_type[i][k],-bond_type[i][k]);
-	buf[m++] = bond_atom[i][k];
-      }
-    }
-
-    if (angles_allow) {
-      buf[m++] = num_angle[i];
-      for (k = 0; k < num_angle[i]; k++) {
-	buf[m++] = MAX(angle_type[i][k],-angle_type[i][k]);
-	buf[m++] = angle_atom1[i][k];
-	buf[m++] = angle_atom2[i][k];
-	buf[m++] = angle_atom3[i][k];
-      }
-    }
-
-    if (dihedrals_allow) {
-      buf[m++] = num_dihedral[i];
-      for (k = 0; k < num_dihedral[i]; k++) {
-	buf[m++] = MAX(dihedral_type[i][k],-dihedral_type[i][k]);
-	buf[m++] = dihedral_atom1[i][k];
-	buf[m++] = dihedral_atom2[i][k];
-	buf[m++] = dihedral_atom3[i][k];
-	buf[m++] = dihedral_atom4[i][k];
-      }
-    }
-
-    if (impropers_allow) {
-      buf[m++] = num_improper[i];
-      for (k = 0; k < num_improper[i]; k++) {
-	buf[m++] = MAX(improper_type[i][k],-improper_type[i][k]);
-	buf[m++] = improper_atom1[i][k];
-	buf[m++] = improper_atom2[i][k];
-	buf[m++] = improper_atom3[i][k];
-	buf[m++] = improper_atom4[i][k];
-      }
-    }
-  }
-
-  if (nextra_restart)
-    for (int iextra = 0; iextra < nextra_restart; iextra++) 
-      m += modify->fix[extra_restart[iextra]]->pack_restart(i,&buf[m]);
-
-  buf[0] = m;
-  return m;
-}
-
-/* ----------------------------------------------------------------------
-   unpack all atom quantities from restart file including extra quantities
-------------------------------------------------------------------------- */
-
-int Atom::unpack_restart(double *buf)
-{
-  int k;
-
-  if (nlocal == nmax) {
-    grow(0);
-    if (nextra_store)
-      extra = memory->grow_2d_double_array(extra,nmax,nextra_store,
-					   "atom:extra");
-  }
-
-  int m = 1;
-  x[nlocal][0] = buf[m++];
-  x[nlocal][1] = buf[m++];
-  x[nlocal][2] = buf[m++];
-  tag[nlocal] = static_cast<int> (buf[m++]);
-  type[nlocal] = static_cast<int> (buf[m++]);
-  mask[nlocal] = static_cast<int> (buf[m++]);
-  image[nlocal] = static_cast<int> (buf[m++]);
-  v[nlocal][0] = buf[m++];
-  v[nlocal][1] = buf[m++];
-  v[nlocal][2] = buf[m++];
-
-  if (charge_allow) q[nlocal] = buf[m++];
-
-  if (style_dipole) {
-    mu[nlocal][0] = buf[m++];
-    mu[nlocal][1] = buf[m++];
-    mu[nlocal][2] = buf[m++];
-    omega[nlocal][0] = buf[m++];
-    omega[nlocal][1] = buf[m++];
-    omega[nlocal][2] = buf[m++];
-  }
-
-  if (style_granular) {
-    phix[nlocal][0] = buf[m++];
-    phix[nlocal][1] = buf[m++];
-    phix[nlocal][2] = buf[m++];
-    phiv[nlocal][0] = buf[m++];
-    phiv[nlocal][1] = buf[m++];
-    phiv[nlocal][2] = buf[m++];
-    radius[nlocal] = buf[m++];
-    density[nlocal] = buf[m++];
-    if (force->dimension == 3) 
-      rmass[nlocal] = 4.0*PI/3.0 * 
-	radius[nlocal]*radius[nlocal]*radius[nlocal] * density[nlocal];
-    else
-      rmass[nlocal] = PI * radius[nlocal]*radius[nlocal] * density[nlocal];
-  }
-
-  if (style_peri) {
-    vfrac[nlocal] = buf[m++];
-    rmass[nlocal] = buf[m++];
-  }
-
-  if (molecular) {
-    molecule[nlocal] = static_cast<int> (buf[m++]);
-
-    if (bonds_allow) {
-      num_bond[nlocal] = static_cast<int> (buf[m++]);
-      for (k = 0; k < num_bond[nlocal]; k++) {
-	bond_type[nlocal][k] = static_cast<int> (buf[m++]);
-	bond_atom[nlocal][k] = static_cast<int> (buf[m++]);
-      }
-    }
-
-    if (angles_allow) {
-      num_angle[nlocal] = static_cast<int> (buf[m++]);
-      for (k = 0; k < num_angle[nlocal]; k++) {
-	angle_type[nlocal][k] = static_cast<int> (buf[m++]);
-	angle_atom1[nlocal][k] = static_cast<int> (buf[m++]);
-	angle_atom2[nlocal][k] = static_cast<int> (buf[m++]);
-	angle_atom3[nlocal][k] = static_cast<int> (buf[m++]);
-      }
-    }
-
-    if (dihedrals_allow) {
-      num_dihedral[nlocal] = static_cast<int> (buf[m++]);
-      for (k = 0; k < num_dihedral[nlocal]; k++) {
-	dihedral_type[nlocal][k] = static_cast<int> (buf[m++]);
-	dihedral_atom1[nlocal][k] = static_cast<int> (buf[m++]);
-	dihedral_atom2[nlocal][k] = static_cast<int> (buf[m++]);
-	dihedral_atom3[nlocal][k] = static_cast<int> (buf[m++]);
-	dihedral_atom4[nlocal][k] = static_cast<int> (buf[m++]);
-      }
-    }
-
-    if (impropers_allow) {
-      num_improper[nlocal] = static_cast<int> (buf[m++]);
-      for (k = 0; k < num_improper[nlocal]; k++) {
-	improper_type[nlocal][k] = static_cast<int> (buf[m++]);
-	improper_atom1[nlocal][k] = static_cast<int> (buf[m++]);
-	improper_atom2[nlocal][k] = static_cast<int> (buf[m++]);
-	improper_atom3[nlocal][k] = static_cast<int> (buf[m++]);
-	improper_atom4[nlocal][k] = static_cast<int> (buf[m++]);
-      }
-    }
-  }
-
-  if (nextra_store) {
-    int size = static_cast<int> (buf[0]) - m;
-    for (int i = 0; i < size; i++) extra[nlocal][i] = buf[m++];
-  }
-
-  nlocal++;
-  return m;
-}
-
-/* ----------------------------------------------------------------------
-   return # of bytes of allocated memory 
+   return # of bytes of allocated memory
+   call to avec sums per-atom vectors
+   add in global to local mapping storage
 ------------------------------------------------------------------------- */
 
 int Atom::memory_usage()
 {
-  int bytes = 0;
-
-  bytes += 4 * nmax * sizeof(int);
-  bytes += 3 * nmax*3 * sizeof(double);
-
-  if (charge_allow) bytes += 1 * nmax * sizeof(double);     // q
-  if (mass_allow) bytes += 1 * nmax * sizeof(double);       // rmass
-  if (style_dipole) bytes += 3 * nmax*3 * sizeof(double);   // mu,omega,torque
-  if (style_granular) {
-    bytes += 3 * nmax*3 * sizeof(double);                   // phix,phiv,phia
-    bytes += 2 * nmax * sizeof(double);                     // radius,density
-  }
-  if (style_peri) bytes += nmax * sizeof(double);           // vfrac
+  memlength = DELTA_MEMSTR;
+  memstr = (char *) memory->smalloc(memlength*sizeof(char),"atom:memstr");
+  memstr[0] = '\0';
 
+  int bytes = avec->memory_usage();
   if (map_style == 1)
     bytes += map_tag_max * sizeof(int);
   else if (map_style == 2) {
@@ -1827,31 +1168,35 @@ int Atom::memory_usage()
     bytes += map_nhash*sizeof(HashElem);
   }
 
-  if (molecular) {
-    bytes += nmax * sizeof(int);
-    bytes += nmax*3 * sizeof(int);
-    bytes += nmax*maxspecial * sizeof(int);
-
-    if (bonds_allow) {
-      bytes += nmax * sizeof(int);
-      bytes += 2 * nmax*bond_per_atom * sizeof(int);
-    }
+  memory->sfree(memstr);
+  return bytes;
+}
 
-    if (angles_allow) {
-      bytes += nmax * sizeof(int);
-      bytes += 4 * nmax*angle_per_atom * sizeof(int);
-    }
+/* ----------------------------------------------------------------------
+   accumulate per-atom vec names in memstr, padded by spaces
+   return 1 if padded str is not already in memlist, else 0
+------------------------------------------------------------------------- */
 
-    if (dihedrals_allow) {
-      bytes += nmax * sizeof(int);
-      bytes += 5 * nmax*dihedral_per_atom * sizeof(int);
-    }
+int Atom::memcheck(const char *str)
+{
+  int n = strlen(str) + 3;
+  char *padded = new char[n];
+  strcpy(padded," ");
+  strcat(padded,str);
+  strcat(padded," ");
+  
+  if (strstr(memstr,padded)) {
+    delete [] padded;
+    return 0;
+  }
 
-    if (impropers_allow) {
-      bytes += nmax * sizeof(int);
-      bytes += 5 * nmax*improper_per_atom * sizeof(int);
-    }
+  if (strlen(memstr) + n >= memlength) {
+    memlength += DELTA_MEMSTR;
+    memstr = (char *) memory->srealloc(memstr,memlength*sizeof(char),
+				       "atom:memstr");
   }
 
-  return bytes;
+  strcat(memstr,padded);
+  delete [] padded;
+  return 1;
 }
diff --git a/src/atom.h b/src/atom.h
index 21aec0124a3e01688982f466ed8050eddef4a477..fd9ce8132f2773fdf4de789c19d65f76db847332 100644
--- a/src/atom.h
+++ b/src/atom.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -14,71 +14,39 @@
 #ifndef ATOM_H
 #define ATOM_H
 
-#include "lammps.h"
+#include "pointers.h"
 
-class Atom : public LAMMPS {
+namespace LAMMPS_NS {
+
+class Atom : protected Pointers {
  public:
-  char *style;
-  double PI;
+  char *atom_style;
+  class AtomVec *avec;
 
   // atom counts
 
   double natoms;                // total # of atoms in system, could be 0
   int nlocal,nghost;            // # of owned and ghost atoms on this proc
   int nmax;                     // max # of owned+ghost in arrays on this proc
-
-  // # of atom and topology types
+  int tag_enable;               // 0/1 if atom ID tags are defined
+  int molecular;                // 0 = atomic, 1 = molecular system
 
   int ntypes,nbondtypes,nangletypes,ndihedraltypes,nimpropertypes;
-
-  // molecular counts
-
   int nbonds,nangles,ndihedrals,nimpropers;
   int bond_per_atom,angle_per_atom,dihedral_per_atom,improper_per_atom;
 
-  // atom styles
-
-  int style_angle,style_atomic,style_bond,style_charge,style_dipole,style_dpd;
-  int style_eam,style_full,style_granular,style_molecular,style_peri;
-  int style_hybrid;
-
-  // flags set by atom styles
-
-  int molecular;                       // 0 = atomic, 1 = molecular system
-  int bonds_allow,angles_allow;        // 0/1 if bonds, angles are used
-  int dihedrals_allow,impropers_allow; // 0/1 if dihedrals, impropers used
-  int charge_allow;                    // 0/1 if charges used
-  int mass_allow;                      // 0/1 if per-atom rmass array
-  int mass_require;                    // 0/1 if per-type masses
-  int dipole_require;                  // 0/1 if per-type dipole moments
-  int tag_enable;                      // 0/1 if atom ID tags are defined
-
-  // communication sizes - set by each atom style
-
-  int size_comm,size_reverse,size_border;
-  int size_atom_valid,size_atom_actual;
-
-  // arrays of length ntypes and flags if set
-
-  double *mass;
-  int *mass_setflag;
-  double *dipole;
-  int *dipole_setflag;
-
-  // arrays common to all atom classes
+  // per-atom arrays
+  // customize by adding new array
 
   int *tag,*type,*mask,*image;
   double **x,**v,**f;
 
-  // arrays specific to some atom classes
-
+  int *molecule;
   double *q,**mu;
   double **omega,**torque;
   double *radius,*density,*rmass,*vfrac;
   double **phix,**phiv,**phia;
 
-  int *molecule;
-
   int maxspecial;
   int **nspecial,**special;
 
@@ -97,11 +65,20 @@ class Atom : public LAMMPS {
   int *num_improper;
   int **improper_type;
   int **improper_atom1,**improper_atom2,**improper_atom3,**improper_atom4;
- 
-  // array for extra peratom info in restart file destined for fix & diag 
+
+  int *hybrid;
+
+  // extra peratom info in restart file destined for fix & diag 
 
   double **extra;
 
+  // per-type arrays
+
+  double *mass;
+  int *mass_setflag;
+  double *dipole;
+  int *dipole_setflag;
+
   // callback ptrs for atom arrays managed by fix classes
 
   int nextra_grow,nextra_restart;             // # of callbacks of each type
@@ -109,40 +86,20 @@ class Atom : public LAMMPS {
   int nextra_grow_max,nextra_restart_max;     // size of callback lists
   int nextra_store;
 
-  // data for global to local ID mapping
-
   int map_style;                  // default or user-specified style of map
                                   // 0 = none, 1 = array, 2 = hash
-  int map_tag_max;
-  int *map_array;
 
-  struct HashElem {
-    int global;                   // key to search on = global ID
-    int local;                    // value associated with key = local index
-    int next;                     // next entry in this bucket, -1 if last
-  };
-  int map_nhash;                  // # of entries hash table can hold
-  int map_nused;                  // # of actual entries in hash table
-  int map_free;                   // ptr to 1st unused entry in hash table
-  int map_nbucket;                // # of hash buckets
-  int *map_bucket;                // ptr to 1st entry in each bucket
-  HashElem *map_hash;             // hash table
-  int *primes;                    // table of prime #s for hashing
-  int nprimes;                    // # of primes
+  // functions
 
-  // functions common to all atom styles
-
-  Atom(int, char **);
-  virtual ~Atom();
-  void set_style(char *);
-  int check_style(char *);
-  int style2arg(char **&);
-  char *style2word(char *);
-  void settings(Atom *);
+  Atom(class LAMMPS *);
+  ~Atom();
 
+  void create_avec(char *, int, char **);
+  class AtomVec *new_avec(char *, int, char **);
   void init();
-  void grow(int);
 
+  int check_style(char *);
+  int style2arg(char **);
   void modify_params(int, char **);
   void tag_extend();
   int tag_consecutive();
@@ -150,13 +107,12 @@ class Atom : public LAMMPS {
   int parse_data(char *);
   int count_words(char *);
 
-  void unpack_data(int, char *);
-  void create_one(int, double, double, double);
-  virtual void unpack_vels(int, char *);     // can be overwritten by child
-  void unpack_bonds(int, char *);
-  void unpack_angles(int, char *);
-  void unpack_dihedrals(int, char *);
-  void unpack_impropers(int, char *);
+  void data_atoms(int, char *, int);
+  void data_vels(int, char *, int);
+  void data_bonds(int, char *);
+  void data_angles(int, char *);
+  void data_dihedrals(int, char *);
+  void data_impropers(int, char *);
 
   void allocate_type_arrays();
   void set_mass(char *);
@@ -173,14 +129,11 @@ class Atom : public LAMMPS {
   void delete_callback(char *, int);
   void update_callback(int);
 
-  int size_restart();
-  int pack_restart(int, double *);
-  int unpack_restart(double *);
-
   int memory_usage();
+  int memcheck(const char *);
 
-  // functions for global ID to local index atom mapping
-  // map lookup function is inlined right here for efficiency
+  // functions for global to local ID mapping
+  // map lookup function inlined for efficiency
   
   inline int map(int global) {
     if (map_style == 1) return map_array[global];
@@ -194,19 +147,31 @@ class Atom : public LAMMPS {
   void map_delete();
   int map_find_hash(int);
 
-  // pure virtual functions, must be defined in child class
+ private:
 
-  virtual void copy(int, int) = 0;
+  // data for global to local ID mapping
 
-  virtual void pack_comm(int, int *, double *, int *) = 0;
-  virtual void unpack_comm(int, int, double *) = 0;
-  virtual void pack_reverse(int, int, double *) = 0;
-  virtual void unpack_reverse(int, int *, double *) = 0;
+  int map_tag_max;
+  int *map_array;
+
+  struct HashElem {
+    int global;                   // key to search on = global ID
+    int local;                    // value associated with key = local index
+    int next;                     // next entry in this bucket, -1 if last
+  };
+  int map_nhash;                  // # of entries hash table can hold
+  int map_nused;                  // # of actual entries in hash table
+  int map_free;                   // ptr to 1st unused entry in hash table
+  int map_nbucket;                // # of hash buckets
+  int *map_bucket;                // ptr to 1st entry in each bucket
+  HashElem *map_hash;             // hash table
+  int *primes;                    // table of prime #s for hashing
+  int nprimes;                    // # of primes
 
-  virtual void pack_border(int, int *, double *, int *) = 0;
-  virtual void unpack_border(int, int, double *) = 0;
-  virtual int pack_exchange(int, double *) = 0;
-  virtual int unpack_exchange(double *) = 0;
+  int memlength;                  // allocated size of memstr
+  char *memstr;                   // string of array names already counted
 };
 
+}
+
 #endif
diff --git a/src/atom_atomic.cpp b/src/atom_atomic.cpp
deleted file mode 100644
index 97f4488b452fab1508de6145494050cb89d9120a..0000000000000000000000000000000000000000
--- a/src/atom_atomic.cpp
+++ /dev/null
@@ -1,218 +0,0 @@
-/* ----------------------------------------------------------------------
-   LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
-
-   Copyright (2003) Sandia Corporation.  Under the terms of Contract
-   DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
-   certain rights in this software.  This software is distributed under 
-   the GNU General Public License.
-
-   See the README file in the top-level LAMMPS directory.
-------------------------------------------------------------------------- */
-
-#include "atom_atomic.h"
-#include "domain.h"
-#include "modify.h"
-#include "fix.h"
-
-/* ---------------------------------------------------------------------- */
-
-AtomAtomic::AtomAtomic(int narg, char **arg) : Atom(narg, arg) {}
-
-/* ---------------------------------------------------------------------- */
-
-void AtomAtomic::copy(int i, int j)
-{
-  tag[j] = tag[i];
-  type[j] = type[i];
-  mask[j] = mask[i];
-  image[j] = image[i];
-  x[j][0] = x[i][0];
-  x[j][1] = x[i][1];
-  x[j][2] = x[i][2];
-  v[j][0] = v[i][0];
-  v[j][1] = v[i][1];
-  v[j][2] = v[i][2];
-
-  if (nextra_grow)
-    for (int iextra = 0; iextra < nextra_grow; iextra++) 
-      modify->fix[extra_grow[iextra]]->copy_arrays(i,j);
-}
-
-/* ---------------------------------------------------------------------- */
-
-void AtomAtomic::pack_comm(int n, int *list, double *buf, int *pbc_flags)
-{
-  int i,j,m;
-
-  m = 0;
-  if (pbc_flags[0] == 0) {
-    for (i = 0; i < n; i++) {
-      j = list[i];
-      buf[m++] = x[j][0];
-      buf[m++] = x[j][1];
-      buf[m++] = x[j][2];
-    }
-  } else {
-    double xprd = domain->xprd;
-    double yprd = domain->yprd;
-    double zprd = domain->zprd;
-    for (i = 0; i < n; i++) {
-      j = list[i];
-      buf[m++] = x[j][0] + pbc_flags[1]*xprd;
-      buf[m++] = x[j][1] + pbc_flags[2]*yprd;
-      buf[m++] = x[j][2] + pbc_flags[3]*zprd;
-    }
-  }
-}
-
-/* ---------------------------------------------------------------------- */
-
-void AtomAtomic::unpack_comm(int n, int first, double *buf)
-{
-  int i,m,last;
-
-  m = 0;
-  last = first + n;
-  for (i = first; i < last; i++) {
-    x[i][0] = buf[m++];
-    x[i][1] = buf[m++];
-    x[i][2] = buf[m++];
-  }
-}
-
-/* ---------------------------------------------------------------------- */
-
-void AtomAtomic::pack_reverse(int n, int first, double *buf)
-{
-  int i,m,last;
-
-  m = 0;
-  last = first + n;
-  for (i = first; i < last; i++) {
-    buf[m++] = f[i][0];
-    buf[m++] = f[i][1];
-    buf[m++] = f[i][2];
-  }
-}
-
-/* ---------------------------------------------------------------------- */
-
-void AtomAtomic::unpack_reverse(int n, int *list, double *buf)
-{
-  int i,j,m;
-
-  m = 0;
-  for (i = 0; i < n; i++) {
-    j = list[i];
-    f[j][0] += buf[m++];
-    f[j][1] += buf[m++];
-    f[j][2] += buf[m++];
-  }
-}
-
-/* ---------------------------------------------------------------------- */
-
-void AtomAtomic::pack_border(int n, int *list, double *buf, int *pbc_flags)
-{
-  int i,j,m;
-
-  m = 0;
-  if (pbc_flags[0] == 0) {
-    for (i = 0; i < n; i++) {
-      j = list[i];
-      buf[m++] = x[j][0];
-      buf[m++] = x[j][1];
-      buf[m++] = x[j][2];
-      buf[m++] = tag[j];
-      buf[m++] = type[j];
-      buf[m++] = mask[j];
-    }
-  } else {
-    double xprd = domain->xprd;
-    double yprd = domain->yprd;
-    double zprd = domain->zprd;
-    for (i = 0; i < n; i++) {
-      j = list[i];
-      buf[m++] = x[j][0] + pbc_flags[1]*xprd;
-      buf[m++] = x[j][1] + pbc_flags[2]*yprd;
-      buf[m++] = x[j][2] + pbc_flags[3]*zprd;
-      buf[m++] = tag[j];
-      buf[m++] = type[j];
-      buf[m++] = mask[j];
-    }
-  }
-}
-
-/* ---------------------------------------------------------------------- */
-
-void AtomAtomic::unpack_border(int n, int first, double *buf)
-{
-  int i,m,last;
-
-  m = 0;
-  last = first + n;
-  for (i = first; i < last; i++) {
-    if (i == nmax) grow(0);
-    x[i][0] = buf[m++];
-    x[i][1] = buf[m++];
-    x[i][2] = buf[m++];
-    tag[i] = static_cast<int> (buf[m++]);
-    type[i] = static_cast<int> (buf[m++]);
-    mask[i] = static_cast<int> (buf[m++]);
-  }
-}
-
-/* ----------------------------------------------------------------------
-   pack all atom quantities for shipping to another proc
-   xyz must be 1st 3 values, so that comm::exchange can test on them 
-------------------------------------------------------------------------- */
-
-int AtomAtomic::pack_exchange(int i, double *buf)
-{
-  int m = 1;
-  buf[m++] = x[i][0];
-  buf[m++] = x[i][1];
-  buf[m++] = x[i][2];
-  buf[m++] = v[i][0];
-  buf[m++] = v[i][1];
-  buf[m++] = v[i][2];
-  buf[m++] = tag[i];
-  buf[m++] = type[i];
-  buf[m++] = mask[i];
-  buf[m++] = image[i];
-
-  if (nextra_grow)
-    for (int iextra = 0; iextra < nextra_grow; iextra++) 
-      m += modify->fix[extra_grow[iextra]]->pack_exchange(i,&buf[m]);
-
-  buf[0] = m;
-  return m;
-}
-
-/* ---------------------------------------------------------------------- */
-
-int AtomAtomic::unpack_exchange(double *buf)
-{
-  if (nlocal == nmax) grow(0);
-
-  int m = 1;
-  x[nlocal][0] = buf[m++];
-  x[nlocal][1] = buf[m++];
-  x[nlocal][2] = buf[m++];
-  v[nlocal][0] = buf[m++];
-  v[nlocal][1] = buf[m++];
-  v[nlocal][2] = buf[m++];
-  tag[nlocal] = static_cast<int> (buf[m++]);
-  type[nlocal] = static_cast<int> (buf[m++]);
-  mask[nlocal] = static_cast<int> (buf[m++]);
-  image[nlocal] = static_cast<int> (buf[m++]);
-
-  if (nextra_grow)
-    for (int iextra = 0; iextra < nextra_grow; iextra++) 
-      m += modify->fix[extra_grow[iextra]]->unpack_exchange(nlocal,&buf[m]);
-
-  nlocal++;
-  return m;
-}
diff --git a/src/atom_atomic.h b/src/atom_atomic.h
deleted file mode 100644
index ba15feda921383cb7db2f47cebd4aa8f1827d173..0000000000000000000000000000000000000000
--- a/src/atom_atomic.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/* ----------------------------------------------------------------------
-   LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
-
-   Copyright (2003) Sandia Corporation.  Under the terms of Contract
-   DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
-   certain rights in this software.  This software is distributed under 
-   the GNU General Public License.
-
-   See the README file in the top-level LAMMPS directory.
-------------------------------------------------------------------------- */
-
-#ifndef ATOM_ATOMIC_H
-#define ATOM_ATOMIC_H
-
-#include "atom.h"
-
-class AtomAtomic : public Atom {
- public:
-  AtomAtomic(int, char **);
-  ~AtomAtomic() {}
-  void copy(int, int);
-  void pack_comm(int, int *, double *, int *);
-  void unpack_comm(int, int, double *);
-  void pack_reverse(int, int, double *);
-  void unpack_reverse(int, int *, double *);
-  void pack_border(int, int *, double *, int *);
-  void unpack_border(int, int, double *);
-  int pack_exchange(int, double *);
-  int unpack_exchange(double *);
-};
-
-#endif
diff --git a/src/atom_charge.cpp b/src/atom_charge.cpp
deleted file mode 100644
index 7b6a0a3ea5a7e59756ec7ccd98f81ae018c8f95b..0000000000000000000000000000000000000000
--- a/src/atom_charge.cpp
+++ /dev/null
@@ -1,227 +0,0 @@
-/* ----------------------------------------------------------------------
-   LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
-
-   Copyright (2003) Sandia Corporation.  Under the terms of Contract
-   DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
-   certain rights in this software.  This software is distributed under 
-   the GNU General Public License.
-
-   See the README file in the top-level LAMMPS directory.
-------------------------------------------------------------------------- */
-
-#include "atom_charge.h"
-#include "domain.h"
-#include "modify.h"
-#include "fix.h"
-
-/* ---------------------------------------------------------------------- */
-
-AtomCharge::AtomCharge(int narg, char **arg) : Atom(narg, arg) {}
-
-/* ---------------------------------------------------------------------- */
-
-void AtomCharge::copy(int i, int j)
-{
-  tag[j] = tag[i];
-  type[j] = type[i];
-  mask[j] = mask[i];
-  image[j] = image[i];
-  x[j][0] = x[i][0];
-  x[j][1] = x[i][1];
-  x[j][2] = x[i][2];
-  v[j][0] = v[i][0];
-  v[j][1] = v[i][1];
-  v[j][2] = v[i][2];
-
-  q[j] = q[i];
-
-  if (nextra_grow)
-    for (int iextra = 0; iextra < nextra_grow; iextra++) 
-      modify->fix[extra_grow[iextra]]->copy_arrays(i,j);
-}
-
-/* ---------------------------------------------------------------------- */
-
-void AtomCharge::pack_comm(int n, int *list, double *buf, int *pbc_flags)
-{
-  int i,j,m;
-
-  m = 0;
-  if (pbc_flags[0] == 0) {
-    for (i = 0; i < n; i++) {
-      j = list[i];
-      buf[m++] = x[j][0];
-      buf[m++] = x[j][1];
-      buf[m++] = x[j][2];
-    }
-  } else {
-    double xprd = domain->xprd;
-    double yprd = domain->yprd;
-    double zprd = domain->zprd;
-    for (i = 0; i < n; i++) {
-      j = list[i];
-      buf[m++] = x[j][0] + pbc_flags[1]*xprd;
-      buf[m++] = x[j][1] + pbc_flags[2]*yprd;
-      buf[m++] = x[j][2] + pbc_flags[3]*zprd;
-    }
-  }
-}
-
-/* ---------------------------------------------------------------------- */
-
-void AtomCharge::unpack_comm(int n, int first, double *buf)
-{
-  int i,m,last;
-
-  m = 0;
-  last = first + n;
-  for (i = first; i < last; i++) {
-    x[i][0] = buf[m++];
-    x[i][1] = buf[m++];
-    x[i][2] = buf[m++];
-  }
-}
-
-/* ---------------------------------------------------------------------- */
-
-void AtomCharge::pack_reverse(int n, int first, double *buf)
-{
-  int i,m,last;
-
-  m = 0;
-  last = first + n;
-  for (i = first; i < last; i++) {
-    buf[m++] = f[i][0];
-    buf[m++] = f[i][1];
-    buf[m++] = f[i][2];
-  }
-}
-
-/* ---------------------------------------------------------------------- */
-
-void AtomCharge::unpack_reverse(int n, int *list, double *buf)
-{
-  int i,j,m;
-
-  m = 0;
-  for (i = 0; i < n; i++) {
-    j = list[i];
-    f[j][0] += buf[m++];
-    f[j][1] += buf[m++];
-    f[j][2] += buf[m++];
-  }
-}
-
-/* ---------------------------------------------------------------------- */
-
-void AtomCharge::pack_border(int n, int *list, double *buf, int *pbc_flags)
-{
-  int i,j,m;
-
-  m = 0;
-  if (pbc_flags[0] == 0) {
-    for (i = 0; i < n; i++) {
-      j = list[i];
-      buf[m++] = x[j][0];
-      buf[m++] = x[j][1];
-      buf[m++] = x[j][2];
-      buf[m++] = tag[j];
-      buf[m++] = type[j];
-      buf[m++] = mask[j];
-      buf[m++] = q[j];
-    }
-  } else {
-    double xprd = domain->xprd;
-    double yprd = domain->yprd;
-    double zprd = domain->zprd;
-    for (i = 0; i < n; i++) {
-      j = list[i];
-      buf[m++] = x[j][0] + pbc_flags[1]*xprd;
-      buf[m++] = x[j][1] + pbc_flags[2]*yprd;
-      buf[m++] = x[j][2] + pbc_flags[3]*zprd;
-      buf[m++] = tag[j];
-      buf[m++] = type[j];
-      buf[m++] = mask[j];
-      buf[m++] = q[j];
-    }
-  }
-}
-
-/* ---------------------------------------------------------------------- */
-
-void AtomCharge::unpack_border(int n, int first, double *buf)
-{
-  int i,m,last;
-
-  m = 0;
-  last = first + n;
-  for (i = first; i < last; i++) {
-    if (i == nmax) grow(0);
-    x[i][0] = buf[m++];
-    x[i][1] = buf[m++];
-    x[i][2] = buf[m++];
-    tag[i] = static_cast<int> (buf[m++]);
-    type[i] = static_cast<int> (buf[m++]);
-    mask[i] = static_cast<int> (buf[m++]);
-    q[i] = buf[m++];
-  }
-}
-
-/* ----------------------------------------------------------------------
-   pack all atom quantities for shipping to another proc
-   xyz must be 1st 3 values, so that comm::exchange can test on them
-------------------------------------------------------------------------- */
-
-int AtomCharge::pack_exchange(int i, double *buf)
-{
-  int m = 1;
-  buf[m++] = x[i][0];
-  buf[m++] = x[i][1];
-  buf[m++] = x[i][2];
-  buf[m++] = tag[i];
-  buf[m++] = type[i];
-  buf[m++] = mask[i];
-  buf[m++] = image[i];
-  buf[m++] = v[i][0];
-  buf[m++] = v[i][1];
-  buf[m++] = v[i][2];
-
-  buf[m++] = q[i];
-
-  if (nextra_grow)
-    for (int iextra = 0; iextra < nextra_grow; iextra++) 
-      m += modify->fix[extra_grow[iextra]]->pack_exchange(i,&buf[m]);
-
-  buf[0] = m;
-  return m;
-}
-
-/* ---------------------------------------------------------------------- */
-
-int AtomCharge::unpack_exchange(double *buf)
-{
-  if (nlocal == nmax) grow(0);
-
-  int m = 1;
-  x[nlocal][0] = buf[m++];
-  x[nlocal][1] = buf[m++];
-  x[nlocal][2] = buf[m++];
-  tag[nlocal] = static_cast<int> (buf[m++]);
-  type[nlocal] = static_cast<int> (buf[m++]);
-  mask[nlocal] = static_cast<int> (buf[m++]);
-  image[nlocal] = static_cast<int> (buf[m++]);
-  v[nlocal][0] = buf[m++];
-  v[nlocal][1] = buf[m++];
-  v[nlocal][2] = buf[m++];
-
-  q[nlocal] = buf[m++];
-
-  if (nextra_grow)
-    for (int iextra = 0; iextra < nextra_grow; iextra++) 
-      m += modify->fix[extra_grow[iextra]]->unpack_exchange(nlocal,&buf[m]);
-
-  nlocal++;
-  return m;
-}
diff --git a/src/atom_charge.h b/src/atom_charge.h
deleted file mode 100644
index 46b9848c987b7fe7c825c4c2e7df78cbdfe5a439..0000000000000000000000000000000000000000
--- a/src/atom_charge.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/* ----------------------------------------------------------------------
-   LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
-
-   Copyright (2003) Sandia Corporation.  Under the terms of Contract
-   DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
-   certain rights in this software.  This software is distributed under 
-   the GNU General Public License.
-
-   See the README file in the top-level LAMMPS directory.
-------------------------------------------------------------------------- */
-
-#ifndef ATOM_CHARGE_H
-#define ATOM_CHARGE_H
-
-#include "atom.h"
-
-class AtomCharge : public Atom {
- public:
-  AtomCharge(int, char **);
-  ~AtomCharge() {}
-  void copy(int, int);
-  void pack_comm(int, int *, double *, int *);
-  void unpack_comm(int, int, double *);
-  void pack_reverse(int, int, double *);
-  void unpack_reverse(int, int *, double *);
-  void pack_border(int, int *, double *, int *);
-  void unpack_border(int, int, double *);
-  int pack_exchange(int, double *);
-  int unpack_exchange(double *);
-};
-
-#endif
diff --git a/src/atom_hybrid.cpp b/src/atom_hybrid.cpp
deleted file mode 100644
index 2520632d00d6f6ee1e59b0472d67d61942826901..0000000000000000000000000000000000000000
--- a/src/atom_hybrid.cpp
+++ /dev/null
@@ -1,584 +0,0 @@
-/* ----------------------------------------------------------------------
-   LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
-
-   Copyright (2003) Sandia Corporation.  Under the terms of Contract
-   DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
-   certain rights in this software.  This software is distributed under 
-   the GNU General Public License.
-
-   See the README file in the top-level LAMMPS directory.
-------------------------------------------------------------------------- */
-
-#include "atom_hybrid.h"
-#include "domain.h"
-#include "modify.h"
-#include "fix.h"
-
-/* ---------------------------------------------------------------------- */
-
-AtomHybrid::AtomHybrid(int narg, char **arg) : Atom(narg, arg) {}
-
-/* ---------------------------------------------------------------------- */
-
-void AtomHybrid::copy(int i, int j)
-{
-  int k;
-
-  tag[j] = tag[i];
-  type[j] = type[i];
-  mask[j] = mask[i];
-  image[j] = image[i];
-  x[j][0] = x[i][0];
-  x[j][1] = x[i][1];
-  x[j][2] = x[i][2];
-  v[j][0] = v[i][0];
-  v[j][1] = v[i][1];
-  v[j][2] = v[i][2];
-
-  if (charge_allow) q[j] = q[i];
-  if (mass_allow) rmass[j] = rmass[i];
-
-  if (style_dipole) {
-    mu[j][0] = mu[i][0];
-    mu[j][1] = mu[i][1];
-    mu[j][2] = mu[i][2];
-    omega[j][0] = omega[i][0];
-    omega[j][1] = omega[i][1];
-    omega[j][2] = omega[i][2];
-  }
-
-  if (style_granular) {
-    phix[j][0] = phix[i][0];
-    phix[j][1] = phix[i][1];
-    phix[j][2] = phix[i][2];
-    phiv[j][0] = phiv[i][0];
-    phiv[j][1] = phiv[i][1];
-    phiv[j][2] = phiv[i][2];
-    radius[j] = radius[i];
-    density[j] = density[i];
-  }
-
-  if (style_peri) vfrac[j] = vfrac[i];
-
-  if (molecular) {
-    molecule[j] = molecule[i];
-    nspecial[j][0] = nspecial[i][0];
-    nspecial[j][1] = nspecial[i][1];
-    nspecial[j][2] = nspecial[i][2];
-    for (k = 0; k < nspecial[j][2]; k++) special[j][k] = special[i][k];
-
-    if (bonds_allow) {
-      num_bond[j] = num_bond[i];
-      for (k = 0; k < num_bond[j]; k++) {
-	bond_type[j][k] = bond_type[i][k];
-	bond_atom[j][k] = bond_atom[i][k];
-      }
-    }
-
-    if (angles_allow) {
-      num_angle[j] = num_angle[i];
-      for (k = 0; k < num_angle[j]; k++) {
-	angle_type[j][k] = angle_type[i][k];
-	angle_atom1[j][k] = angle_atom1[i][k];
-	angle_atom2[j][k] = angle_atom2[i][k];
-	angle_atom3[j][k] = angle_atom3[i][k];
-      }
-    }
-
-    if (dihedrals_allow) {
-      num_dihedral[j] = num_dihedral[i];
-      for (k = 0; k < num_dihedral[j]; k++) {
-	dihedral_type[j][k] = dihedral_type[i][k];
-	dihedral_atom1[j][k] = dihedral_atom1[i][k];
-	dihedral_atom2[j][k] = dihedral_atom2[i][k];
-	dihedral_atom3[j][k] = dihedral_atom3[i][k];
-	dihedral_atom4[j][k] = dihedral_atom4[i][k];
-      }
-    }
-
-    if (impropers_allow) {
-      num_improper[j] = num_improper[i];
-      for (k = 0; k < num_improper[j]; k++) {
-	improper_type[j][k] = improper_type[i][k];
-	improper_atom1[j][k] = improper_atom1[i][k];
-	improper_atom2[j][k] = improper_atom2[i][k];
-	improper_atom3[j][k] = improper_atom3[i][k];
-	improper_atom4[j][k] = improper_atom4[i][k];
-      }
-    }
-  }
-
-  if (nextra_grow)
-    for (int iextra = 0; iextra < nextra_grow; iextra++) 
-      modify->fix[extra_grow[iextra]]->copy_arrays(i,j);
-}
-
-/* ---------------------------------------------------------------------- */
-
-void AtomHybrid::pack_comm(int n, int *list, double *buf, int *pbc_flags)
-{
-  int i,j,m;
-
-  m = 0;
-  if (pbc_flags[0] == 0) {
-    for (i = 0; i < n; i++) {
-      j = list[i];
-      buf[m++] = x[j][0];
-      buf[m++] = x[j][1];
-      buf[m++] = x[j][2];
-      if (style_dpd) {
-	buf[m++] = v[j][0];
-	buf[m++] = v[j][1];
-	buf[m++] = v[j][2];
-      }
-      if (style_dipole) {
-	buf[m++] = mu[j][0];
-	buf[m++] = mu[j][1];
-	buf[m++] = mu[j][2];
-      }
-      if (style_granular) {
-	buf[m++] = v[j][0];
-	buf[m++] = v[j][1];
-	buf[m++] = v[j][2];
-	buf[m++] = phiv[j][0];
-	buf[m++] = phiv[j][1];
-	buf[m++] = phiv[j][2];
-      }
-    }
-  } else {
-    double xprd = domain->xprd;
-    double yprd = domain->yprd;
-    double zprd = domain->zprd;
-    for (i = 0; i < n; i++) {
-      j = list[i];
-      buf[m++] = x[j][0] + pbc_flags[1]*xprd;
-      buf[m++] = x[j][1] + pbc_flags[2]*yprd;
-      buf[m++] = x[j][2] + pbc_flags[3]*zprd;
-      if (style_dpd) {
-	buf[m++] = v[j][0];
-	buf[m++] = v[j][1];
-	buf[m++] = v[j][2];
-      }
-      if (style_dipole) {
-	buf[m++] = mu[j][0];
-	buf[m++] = mu[j][1];
-	buf[m++] = mu[j][2];
-      }
-      if (style_granular) {
-	buf[m++] = v[j][0];
-	buf[m++] = v[j][1];
-	buf[m++] = v[j][2];
-	buf[m++] = phiv[j][0];
-	buf[m++] = phiv[j][1];
-	buf[m++] = phiv[j][2];
-      }
-    }
-  }
-}
-
-/* ---------------------------------------------------------------------- */
-
-void AtomHybrid::unpack_comm(int n, int first, double *buf)
-{
-  int i,m,last;
-
-  m = 0;
-  last = first + n;
-  for (i = first; i < last; i++) {
-    x[i][0] = buf[m++];
-    x[i][1] = buf[m++];
-    x[i][2] = buf[m++];
-    if (style_dpd) {
-      v[i][0] = buf[m++];
-      v[i][1] = buf[m++];
-      v[i][2] = buf[m++];
-    }
-    if (style_dipole) {
-      mu[i][0] = buf[m++];
-      mu[i][1] = buf[m++];
-      mu[i][2] = buf[m++];
-    }
-    if (style_granular) {
-      v[i][0] = buf[m++];
-      v[i][1] = buf[m++];
-      v[i][2] = buf[m++];
-      phiv[i][0] = buf[m++];
-      phiv[i][1] = buf[m++];
-      phiv[i][2] = buf[m++];
-    }
-  }
-}
-
-/* ---------------------------------------------------------------------- */
-
-void AtomHybrid::pack_reverse(int n, int first, double *buf)
-{
-  int i,m,last;
-
-  m = 0;
-  last = first + n;
-  for (i = first; i < last; i++) {
-    buf[m++] = f[i][0];
-    buf[m++] = f[i][1];
-    buf[m++] = f[i][2];
-    if (style_dipole) {
-      buf[m++] = torque[i][0];
-      buf[m++] = torque[i][1];
-      buf[m++] = torque[i][2];
-    }
-    if (style_granular) {
-      buf[m++] = phia[i][0];
-      buf[m++] = phia[i][1];
-      buf[m++] = phia[i][2];
-    }
-  }
-}
-
-/* ---------------------------------------------------------------------- */
-
-void AtomHybrid::unpack_reverse(int n, int *list, double *buf)
-{
-  int i,j,m;
-
-  m = 0;
-  for (i = 0; i < n; i++) {
-    j = list[i];
-    f[j][0] += buf[m++];
-    f[j][1] += buf[m++];
-    f[j][2] += buf[m++];
-    if (style_dipole) {
-      torque[j][0] += buf[m++];
-      torque[j][1] += buf[m++];
-      torque[j][2] += buf[m++];
-    }
-    if (style_granular) {
-      phia[j][0] += buf[m++];
-      phia[j][1] += buf[m++];
-      phia[j][2] += buf[m++];
-    }
-  }
-}
-
-/* ---------------------------------------------------------------------- */
-
-void AtomHybrid::pack_border(int n, int *list, double *buf, int *pbc_flags)
-{
-  int i,j,m;
-
-  m = 0;
-  if (pbc_flags[0] == 0) {
-    for (i = 0; i < n; i++) {
-      j = list[i];
-      buf[m++] = x[j][0];
-      buf[m++] = x[j][1];
-      buf[m++] = x[j][2];
-      buf[m++] = tag[j];
-      buf[m++] = type[j];
-      buf[m++] = mask[j];
-      if (charge_allow) buf[m++] = q[j];
-      if (style_dpd) {
-	buf[m++] = v[j][0];
-	buf[m++] = v[j][1];
-	buf[m++] = v[j][2];
-      }
-      if (style_dipole) {
-	buf[m++] = mu[j][0];
-	buf[m++] = mu[j][1];
-	buf[m++] = mu[j][2];
-      }
-      if (style_granular) {
-	buf[m++] = v[j][0];
-	buf[m++] = v[j][1];
-	buf[m++] = v[j][2];
-	buf[m++] = phiv[j][0];
-	buf[m++] = phiv[j][1];
-	buf[m++] = phiv[j][2];
-	buf[m++] = radius[j];
-	buf[m++] = rmass[j];
-      }
-      if (molecular) buf[m++] = molecule[j];
-    }
-  } else {
-    double xprd = domain->xprd;
-    double yprd = domain->yprd;
-    double zprd = domain->zprd;
-    for (i = 0; i < n; i++) {
-      j = list[i];
-      buf[m++] = x[j][0] + pbc_flags[1]*xprd;
-      buf[m++] = x[j][1] + pbc_flags[2]*yprd;
-      buf[m++] = x[j][2] + pbc_flags[3]*zprd;
-      buf[m++] = tag[j];
-      buf[m++] = type[j];
-      buf[m++] = mask[j];
-      if (charge_allow) buf[m++] = q[j];
-      if (style_dpd) {
-	buf[m++] = v[j][0];
-	buf[m++] = v[j][1];
-	buf[m++] = v[j][2];
-      }
-      if (style_dipole) {
-	buf[m++] = mu[j][0];
-	buf[m++] = mu[j][1];
-	buf[m++] = mu[j][2];
-      }
-      if (style_granular) {
-	buf[m++] = v[j][0];
-	buf[m++] = v[j][1];
-	buf[m++] = v[j][2];
-	buf[m++] = phiv[j][0];
-	buf[m++] = phiv[j][1];
-	buf[m++] = phiv[j][2];
-	buf[m++] = radius[j];
-	buf[m++] = rmass[j];
-      }
-      if (molecular) buf[m++] = molecule[j];
-    }
-  }
-}
-
-/* ---------------------------------------------------------------------- */
-
-void AtomHybrid::unpack_border(int n, int first, double *buf)
-{
-  int i,m,last;
-
-  m = 0;
-  last = first + n;
-  for (i = first; i < last; i++) {
-    if (i == nmax) grow(0);
-    x[i][0] = buf[m++];
-    x[i][1] = buf[m++];
-    x[i][2] = buf[m++];
-    tag[i] = static_cast<int> (buf[m++]);
-    type[i] = static_cast<int> (buf[m++]);
-    mask[i] = static_cast<int> (buf[m++]);
-    if (charge_allow) q[i] = buf[m++];
-    if (style_dpd) {
-      v[i][0] = buf[m++];
-      v[i][1] = buf[m++];
-      v[i][2] = buf[m++];
-    }
-    if (style_dipole) {
-      mu[i][0] = buf[m++];
-      mu[i][1] = buf[m++];
-      mu[i][2] = buf[m++];
-    }
-    if (style_granular) {
-      v[i][0] = buf[m++];
-      v[i][1] = buf[m++];
-      v[i][2] = buf[m++];
-      phiv[i][0] = buf[m++];
-      phiv[i][1] = buf[m++];
-      phiv[i][2] = buf[m++];
-      radius[i] = buf[m++];
-      rmass[i] = buf[m++];
-    }
-    if (molecular) molecule[i] = static_cast<int> (buf[m++]);
-  }
-}
-
-/* ----------------------------------------------------------------------
-   pack all atom quantities for shipping to another proc
-   xyz must be 1st 3 values, so that comm::exchange can test on them
-------------------------------------------------------------------------- */
-
-int AtomHybrid::pack_exchange(int i, double *buf)
-{
-  int k;
-
-  int m = 1;
-  buf[m++] = x[i][0];
-  buf[m++] = x[i][1];
-  buf[m++] = x[i][2];
-  buf[m++] = tag[i];
-  buf[m++] = type[i];
-  buf[m++] = mask[i];
-  buf[m++] = image[i];
-  buf[m++] = v[i][0];
-  buf[m++] = v[i][1];
-  buf[m++] = v[i][2];
-
-  if (charge_allow) buf[m++] = q[i];
-  if (mass_allow) buf[m++] = rmass[i];
-
-  if (style_dipole) {
-    buf[m++] = mu[i][0];
-    buf[m++] = mu[i][1];
-    buf[m++] = mu[i][2];
-    buf[m++] = omega[i][0];
-    buf[m++] = omega[i][1];
-    buf[m++] = omega[i][2];
-  }
-
-  if (style_granular) {
-    buf[m++] = phix[i][0];
-    buf[m++] = phix[i][1];
-    buf[m++] = phix[i][2];
-    buf[m++] = phiv[i][0];
-    buf[m++] = phiv[i][1];
-    buf[m++] = phiv[i][2];
-    buf[m++] = radius[i];
-    buf[m++] = density[i];
-  }
-
-  if (style_peri) buf[m++] = vfrac[i];
-
-  if (molecular) {
-    buf[m++] = molecule[i];
-    buf[m++] = nspecial[i][0];
-    buf[m++] = nspecial[i][1];
-    buf[m++] = nspecial[i][2];
-    for (k = 0; k < nspecial[i][2]; k++) buf[m++] = special[i][k];
-    
-    if (bonds_allow) {
-      buf[m++] = num_bond[i];
-      for (k = 0; k < num_bond[i]; k++) {
-	buf[m++] = bond_type[i][k];
-	buf[m++] = bond_atom[i][k];
-      }
-    }
-
-    if (angles_allow) {
-      buf[m++] = num_angle[i];
-      for (k = 0; k < num_angle[i]; k++) {
-	buf[m++] = angle_type[i][k];
-	buf[m++] = angle_atom1[i][k];
-	buf[m++] = angle_atom2[i][k];
-	buf[m++] = angle_atom3[i][k];
-      }
-    }
-
-    if (dihedrals_allow) {
-      buf[m++] = num_dihedral[i];
-      for (k = 0; k < num_dihedral[i]; k++) {
-	buf[m++] = dihedral_type[i][k];
-	buf[m++] = dihedral_atom1[i][k];
-	buf[m++] = dihedral_atom2[i][k];
-	buf[m++] = dihedral_atom3[i][k];
-	buf[m++] = dihedral_atom4[i][k];
-      }
-    }
-
-    if (impropers_allow) {
-      buf[m++] = num_improper[i];
-      for (k = 0; k < num_improper[i]; k++) {
-	buf[m++] = improper_type[i][k];
-	buf[m++] = improper_atom1[i][k];
-	buf[m++] = improper_atom2[i][k];
-	buf[m++] = improper_atom3[i][k];
-	buf[m++] = improper_atom4[i][k];
-      }
-    }
-  }
-
-  if (nextra_grow)
-    for (int iextra = 0; iextra < nextra_grow; iextra++) 
-      m += modify->fix[extra_grow[iextra]]->pack_exchange(i,&buf[m]);
-
-  buf[0] = m;
-  return m;
-}
-
-/* ---------------------------------------------------------------------- */
-
-int AtomHybrid::unpack_exchange(double *buf)
-{
-  int k;
-  if (nlocal == nmax) grow(0);
-
-  int m = 1;
-  x[nlocal][0] = buf[m++];
-  x[nlocal][1] = buf[m++];
-  x[nlocal][2] = buf[m++];
-  tag[nlocal] = static_cast<int> (buf[m++]);
-  type[nlocal] = static_cast<int> (buf[m++]);
-  mask[nlocal] = static_cast<int> (buf[m++]);
-  image[nlocal] = static_cast<int> (buf[m++]);
-  v[nlocal][0] = buf[m++];
-  v[nlocal][1] = buf[m++];
-  v[nlocal][2] = buf[m++];
-
-  if (charge_allow) q[nlocal] = buf[m++];
-  if (mass_allow) rmass[nlocal] = buf[m++];
-
-  if (style_dipole) {
-    mu[nlocal][0] = buf[m++];
-    mu[nlocal][1] = buf[m++];
-    mu[nlocal][2] = buf[m++];
-    omega[nlocal][0] = buf[m++];
-    omega[nlocal][1] = buf[m++];
-    omega[nlocal][2] = buf[m++];
-  }
-
-  if (style_granular) {
-    phix[nlocal][0] = buf[m++];
-    phix[nlocal][1] = buf[m++];
-    phix[nlocal][2] = buf[m++];
-    phiv[nlocal][0] = buf[m++];
-    phiv[nlocal][1] = buf[m++];
-    phiv[nlocal][2] = buf[m++];
-    radius[nlocal] = buf[m++];
-    density[nlocal] = buf[m++];
-    rmass[nlocal] = buf[m++];
-  }
-
-  if (style_peri) vfrac[nlocal] = buf[m++];
-
-  if (molecular) {
-    molecule[nlocal] = static_cast<int> (buf[m++]);
-    nspecial[nlocal][0] = static_cast<int> (buf[m++]);
-    nspecial[nlocal][1] = static_cast<int> (buf[m++]);
-    nspecial[nlocal][2] = static_cast<int> (buf[m++]);
-    for (k = 0; k < nspecial[nlocal][2]; k++) 
-      special[nlocal][k] = static_cast<int> (buf[m++]);
-    
-    if (bonds_allow) {
-      num_bond[nlocal] = static_cast<int> (buf[m++]);
-      for (k = 0; k < num_bond[nlocal]; k++) {
-	bond_type[nlocal][k] = static_cast<int> (buf[m++]);
-	bond_atom[nlocal][k] = static_cast<int> (buf[m++]);
-      }
-    }
-
-    if (angles_allow) {
-      num_angle[nlocal] = static_cast<int> (buf[m++]);
-      for (k = 0; k < num_angle[nlocal]; k++) {
-	angle_type[nlocal][k] = static_cast<int> (buf[m++]);
-	angle_atom1[nlocal][k] = static_cast<int> (buf[m++]);
-	angle_atom2[nlocal][k] = static_cast<int> (buf[m++]);
-	angle_atom3[nlocal][k] = static_cast<int> (buf[m++]);
-      }
-    }
-
-    if (dihedrals_allow) {
-      num_dihedral[nlocal] = static_cast<int> (buf[m++]);
-      for (k = 0; k < num_dihedral[nlocal]; k++) {
-	dihedral_type[nlocal][k] = static_cast<int> (buf[m++]);
-	dihedral_atom1[nlocal][k] = static_cast<int> (buf[m++]);
-	dihedral_atom2[nlocal][k] = static_cast<int> (buf[m++]);
-	dihedral_atom3[nlocal][k] = static_cast<int> (buf[m++]);
-	dihedral_atom4[nlocal][k] = static_cast<int> (buf[m++]);
-      }
-    }
-
-    if (impropers_allow) {
-      num_improper[nlocal] = static_cast<int> (buf[m++]);
-      for (k = 0; k < num_improper[nlocal]; k++) {
-	improper_type[nlocal][k] = static_cast<int> (buf[m++]);
-	improper_atom1[nlocal][k] = static_cast<int> (buf[m++]);
-	improper_atom2[nlocal][k] = static_cast<int> (buf[m++]);
-	improper_atom3[nlocal][k] = static_cast<int> (buf[m++]);
-	improper_atom4[nlocal][k] = static_cast<int> (buf[m++]);
-      }
-    }
-  }
-
-  if (nextra_grow)
-    for (int iextra = 0; iextra < nextra_grow; iextra++) 
-      m += modify->fix[extra_grow[iextra]]->unpack_exchange(nlocal,&buf[m]);
-
-  nlocal++;
-  return m;
-}
diff --git a/src/atom_hybrid.h b/src/atom_hybrid.h
deleted file mode 100644
index 7180cb424be47f738b941a524e6c2770f224c67a..0000000000000000000000000000000000000000
--- a/src/atom_hybrid.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/* ----------------------------------------------------------------------
-   LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
-
-   Copyright (2003) Sandia Corporation.  Under the terms of Contract
-   DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
-   certain rights in this software.  This software is distributed under 
-   the GNU General Public License.
-
-   See the README file in the top-level LAMMPS directory.
-------------------------------------------------------------------------- */
-
-#ifndef ATOM_HYBRID_H
-#define ATOM_HYBRID_H
-
-#include "atom.h"
-
-class AtomHybrid : public Atom {
- public:
-  AtomHybrid(int, char **);
-  ~AtomHybrid() {}
-  void copy(int, int);
-  void pack_comm(int, int *, double *, int *);
-  void unpack_comm(int, int, double *);
-  void pack_reverse(int, int, double *);
-  void unpack_reverse(int, int *, double *);
-  void pack_border(int, int *, double *, int *);
-  void unpack_border(int, int, double *);
-  int pack_exchange(int, double *);
-  int unpack_exchange(double *);
-};
-
-#endif
diff --git a/src/bond.h b/src/bond.h
index 6d75b0d512ce600c495512b6e8950621938e10ea..1c13ba181d271883b1487de70748687ec7390cea 100644
--- a/src/bond.h
+++ b/src/bond.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -15,9 +15,11 @@
 #define BOND_H
 
 #include "stdio.h"
-#include "lammps.h"
+#include "pointers.h"
 
-class Bond : public LAMMPS {
+namespace LAMMPS_NS {
+
+class Bond : protected Pointers {
  public:
   int allocated;
   int *setflag;
@@ -25,7 +27,7 @@ class Bond : public LAMMPS {
   double eng_vdwl;
   double virial[6];
 
-  Bond();
+  Bond(class LAMMPS *);
   virtual ~Bond() {}
   virtual void init();
   virtual void init_style() {}
@@ -41,4 +43,6 @@ class Bond : public LAMMPS {
   virtual int memory_usage() {return 0;}
 };
 
+}
+
 #endif
diff --git a/src/bond_hybrid.h b/src/bond_hybrid.h
index fa77bd845ccc8175b4324f96c7d066f80e69ae61..d1f1f2738ed0031d4541d0c0cb648f1c12d34732 100644
--- a/src/bond_hybrid.h
+++ b/src/bond_hybrid.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -17,11 +17,13 @@
 #include "stdio.h"
 #include "bond.h"
 
+namespace LAMMPS_NS {
+
 class BondHybrid : public Bond {
   friend class Force;
 
  public:
-  BondHybrid();
+  BondHybrid(class LAMMPS *);
   ~BondHybrid();
   void compute(int, int);
   void settings(int, char **);
@@ -46,4 +48,6 @@ class BondHybrid : public Bond {
   void allocate();
 };
 
+}
+
 #endif
diff --git a/src/comm.cpp b/src/comm.cpp
index f3568b86708bfb582a0ef46124908d5d97bdb237..fab58a1dd74fe15e6e68e888addf5ca71ee45c73 100644
--- a/src/comm.cpp
+++ b/src/comm.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -17,15 +17,19 @@
 #include "stdlib.h"
 #include "comm.h"
 #include "atom.h"
+#include "atom_vec.h"
 #include "force.h"
 #include "pair.h"
 #include "domain.h"
 #include "neighbor.h"
 #include "modify.h"
 #include "fix.h"
+#include "compute.h"
 #include "error.h"
 #include "memory.h"
 
+using namespace LAMMPS_NS;
+
 #define BUFFACTOR 1.5
 #define BUFMIN 1000
 #define BUFEXTRA 1000
@@ -38,7 +42,7 @@
    setup MPI and allocate buffer space 
 ------------------------------------------------------------------------- */
 
-Comm::Comm()
+Comm::Comm(LAMMPS *lmp) : Pointers(lmp)
 {
   MPI_Comm_rank(world,&me);
   MPI_Comm_size(world,&nprocs);
@@ -87,26 +91,34 @@ Comm::~Comm()
 
 void Comm::init()
 {
-  // direct_flag = 1 if only x,f are exchanged in forward/reverse comm
+  map_style = atom->map_style;
+
+  // comm_only = 1 if only x,f are exchanged in forward/reverse comm
 
-  direct_flag = 1;
-  if (atom->check_style("dipole") || atom->check_style("dpd") ||
-      atom->check_style("granular")) direct_flag = 0;
+  comm_x_only = atom->avec->comm_x_only;
+  comm_f_only = atom->avec->comm_f_only;
 
   // maxforward = # of datums in largest forward communication
   // maxreverse = # of datums in largest reverse communication
-  // pair,fix values are set by init() of force,modify
+  // query pair,fix,compute for their requirements
 
-  maxforward = MAX(atom->size_comm,atom->size_border);
-  maxforward = MAX(maxforward,maxforward_pair);
-  maxforward = MAX(maxforward,maxforward_fix);
+  maxforward = MAX(atom->avec->size_comm,atom->avec->size_border);
+  maxreverse = atom->avec->size_reverse;
 
-  maxreverse = atom->size_reverse;
-  maxreverse = MAX(maxreverse,maxreverse_pair);
-  maxreverse = MAX(maxreverse,maxreverse_fix);
-  if (force->newton == 0) maxreverse = 0;
+  if (force->pair) maxforward = MAX(maxforward,force->pair->comm_forward);
+  if (force->pair) maxreverse = MAX(maxreverse,force->pair->comm_reverse);
 
-  map_style = atom->map_style;
+  for (int i = 0; i < modify->nfix; i++) {
+    maxforward = MAX(maxforward,modify->fix[i]->comm_forward);
+    maxreverse = MAX(maxreverse,modify->fix[i]->comm_reverse);
+  }
+
+  for (int i = 0; i < modify->ncompute; i++) {
+    maxforward = MAX(maxforward,modify->compute[i]->comm_forward);
+    maxreverse = MAX(maxreverse,modify->compute[i]->comm_reverse);
+  }
+
+  if (force->newton == 0) maxreverse = 0;
 }
 
 /* ----------------------------------------------------------------------
@@ -246,47 +258,47 @@ void Comm::setup()
 
 void Comm::communicate()
 {
+  int n;
   MPI_Request request;
   MPI_Status status;
+  AtomVec *avec = atom->avec;
   double **x = atom->x;
   double *buf;
 
   // exchange data with another proc
   // if other proc is self, just copy
-  // if direct_flag is set, exchange or copy directly to x, don't unpack
+  // if comm_x_only set, exchange or copy directly to x, don't unpack
 
   for (int iswap = 0; iswap < nswap; iswap++) {
     if (sendproc[iswap] != me) {
-      if (direct_flag) {
+      if (comm_x_only) {
 	if (size_comm_recv[iswap]) buf = x[firstrecv[iswap]];
 	else buf = NULL;
 	MPI_Irecv(buf,size_comm_recv[iswap],MPI_DOUBLE,
 		  recvproc[iswap],0,world,&request);
-	atom->pack_comm(sendnum[iswap],sendlist[iswap],
-			buf_send,pbc_flags[iswap]);
-	MPI_Send(buf_send,size_comm_send[iswap],MPI_DOUBLE,
-		 sendproc[iswap],0,world);
+	n = avec->pack_comm(sendnum[iswap],sendlist[iswap],
+			    buf_send,pbc_flags[iswap]);
+	MPI_Send(buf_send,n,MPI_DOUBLE,sendproc[iswap],0,world);
 	MPI_Wait(&request,&status);
       } else {
 	MPI_Irecv(buf_recv,size_comm_recv[iswap],MPI_DOUBLE,
 		  recvproc[iswap],0,world,&request);
-	atom->pack_comm(sendnum[iswap],sendlist[iswap],
-			buf_send,pbc_flags[iswap]);
-	MPI_Send(buf_send,size_comm_send[iswap],MPI_DOUBLE,
-		 sendproc[iswap],0,world);
+	n = avec->pack_comm(sendnum[iswap],sendlist[iswap],
+			    buf_send,pbc_flags[iswap]);
+	MPI_Send(buf_send,n,MPI_DOUBLE,sendproc[iswap],0,world);
 	MPI_Wait(&request,&status);
-	atom->unpack_comm(recvnum[iswap],firstrecv[iswap],buf_recv);
+	avec->unpack_comm(recvnum[iswap],firstrecv[iswap],buf_recv);
       }
 
     } else {
-      if (direct_flag) {
+      if (comm_x_only) {
 	if (sendnum[iswap])
-	  atom->pack_comm(sendnum[iswap],sendlist[iswap],
-			  x[firstrecv[iswap]],pbc_flags[iswap]);
+	  n = avec->pack_comm(sendnum[iswap],sendlist[iswap],
+			      x[firstrecv[iswap]],pbc_flags[iswap]);
       } else {
-	atom->pack_comm(sendnum[iswap],sendlist[iswap],
-			buf_send,pbc_flags[iswap]);
-	atom->unpack_comm(recvnum[iswap],firstrecv[iswap],buf_send);
+	n = avec->pack_comm(sendnum[iswap],sendlist[iswap],
+			    buf_send,pbc_flags[iswap]);
+	avec->unpack_comm(recvnum[iswap],firstrecv[iswap],buf_send);
       }
     }
   }
@@ -299,18 +311,20 @@ void Comm::communicate()
       
 void Comm::reverse_communicate()
 {
+  int n;
   MPI_Request request;
   MPI_Status status;
+  AtomVec *avec = atom->avec;
   double **f = atom->f;
   double *buf;
 
   // exchange data with another proc
   // if other proc is self, just copy
-  // if direct_flag is set, exchange or copy directly from f, don't pack
+  // if comm_f_only set, exchange or copy directly from f, don't pack
 
   for (int iswap = nswap-1; iswap >= 0; iswap--) {
     if (sendproc[iswap] != me) {
-      if (direct_flag) {
+      if (comm_f_only) {
 	MPI_Irecv(buf_recv,size_reverse_recv[iswap],MPI_DOUBLE,
 		  sendproc[iswap],0,world,&request);
 	if (size_reverse_send[iswap]) buf = f[firstrecv[iswap]];
@@ -321,21 +335,20 @@ void Comm::reverse_communicate()
       } else {
 	MPI_Irecv(buf_recv,size_reverse_recv[iswap],MPI_DOUBLE,
 		  sendproc[iswap],0,world,&request);
-	atom->pack_reverse(recvnum[iswap],firstrecv[iswap],buf_send);
-	MPI_Send(buf_send,size_reverse_send[iswap],MPI_DOUBLE,
-		 recvproc[iswap],0,world);
+	n = avec->pack_reverse(recvnum[iswap],firstrecv[iswap],buf_send);
+	MPI_Send(buf_send,n,MPI_DOUBLE,recvproc[iswap],0,world);
 	MPI_Wait(&request,&status);
       }
-      atom->unpack_reverse(sendnum[iswap],sendlist[iswap],buf_recv);
+      avec->unpack_reverse(sendnum[iswap],sendlist[iswap],buf_recv);
 
     } else {
-      if (direct_flag) {
+      if (comm_f_only) {
 	if (sendnum[iswap])
-	    atom->unpack_reverse(sendnum[iswap],sendlist[iswap],
-				 f[firstrecv[iswap]]);
+	    avec->unpack_reverse(sendnum[iswap],sendlist[iswap],
+				f[firstrecv[iswap]]);
       } else {
-	atom->pack_reverse(recvnum[iswap],firstrecv[iswap],buf_send);
-	atom->unpack_reverse(sendnum[iswap],sendlist[iswap],buf_send);
+	n = avec->pack_reverse(recvnum[iswap],firstrecv[iswap],buf_send);
+	avec->unpack_reverse(sendnum[iswap],sendlist[iswap],buf_send);
       }
     }
   }
@@ -360,6 +373,7 @@ void Comm::exchange()
   double *buf;
   MPI_Request request;
   MPI_Status status;
+  AtomVec *avec = atom->avec;
 
   // clear global->local map since atoms move & new ghosts are created
 
@@ -381,8 +395,8 @@ void Comm::exchange()
     while (i < nlocal) {
       if (x[i][dim] < lo || x[i][dim] >= hi) {
 	if (nsend > maxsend) grow_send(nsend,1);
-	nsend += atom->pack_exchange(i,&buf_send[nsend]);
-	atom->copy(nlocal-1,i);
+	nsend += avec->pack_exchange(i,&buf_send[nsend]);
+	avec->copy(nlocal-1,i);
 	nlocal--;
       } else i++;
     }
@@ -429,7 +443,7 @@ void Comm::exchange()
     m = 0;
     while (m < nrecv) {
       value = buf[m+dim+1];
-      if (value >= lo && value < hi) m += atom->unpack_exchange(&buf[m]);
+      if (value >= lo && value < hi) m += avec->unpack_exchange(&buf[m]);
       else m += static_cast<int> (buf[m]);
     }
   }
@@ -447,12 +461,14 @@ void Comm::exchange()
 
 void Comm::borders()
 {
-  int i,iswap,dim,ineed,maxneed,nsend,nrecv,nfirst,nlast,smax,rmax;
+  int i,n,iswap,dim,ineed,maxneed,nsend,nrecv,nfirst,nlast,smax,rmax;
   double lo,hi;
   double **x;
   double *buf;
   MPI_Request request;
   MPI_Status status;
+  AtomVec *avec = atom->avec;
+  int size_border = avec->size_border;
 
   // clear old ghosts
 
@@ -491,9 +507,9 @@ void Comm::borders()
       
       // pack up list of border atoms
 
-      if (nsend*atom->size_border > maxsend)
-	grow_send(nsend*atom->size_border,0);
-      atom->pack_border(nsend,sendlist[iswap],buf_send,pbc_flags[iswap]);
+      if (nsend*size_border > maxsend)
+	grow_send(nsend*size_border,0);
+      n = avec->pack_border(nsend,sendlist[iswap],buf_send,pbc_flags[iswap]);
 
       // swap atoms with other proc
       // put incoming ghosts at end of my atom arrays
@@ -502,12 +518,11 @@ void Comm::borders()
       if (sendproc[iswap] != me) {
 	MPI_Sendrecv(&nsend,1,MPI_INT,sendproc[iswap],0,
 		     &nrecv,1,MPI_INT,recvproc[iswap],0,world,&status);
-	if (nrecv*atom->size_border > maxrecv) 
-	  grow_recv(nrecv*atom->size_border);
-	MPI_Irecv(buf_recv,nrecv*atom->size_border,MPI_DOUBLE,
+	if (nrecv*size_border > maxrecv) 
+	  grow_recv(nrecv*size_border);
+	MPI_Irecv(buf_recv,nrecv*size_border,MPI_DOUBLE,
 		  recvproc[iswap],0,world,&request);
-	MPI_Send(buf_send,nsend*atom->size_border,MPI_DOUBLE,
-		 sendproc[iswap],0,world);
+	MPI_Send(buf_send,n,MPI_DOUBLE,sendproc[iswap],0,world);
 	MPI_Wait(&request,&status);
 	buf = buf_recv;
       } else {
@@ -517,7 +532,7 @@ void Comm::borders()
 
       // unpack buffer
 
-      atom->unpack_border(nrecv,atom->nlocal+atom->nghost,buf);
+      avec->unpack_border(nrecv,atom->nlocal+atom->nghost,buf);
 
       // set all pointers & counters
 
@@ -525,10 +540,9 @@ void Comm::borders()
       rmax = MAX(rmax,nrecv);
       sendnum[iswap] = nsend;
       recvnum[iswap] = nrecv;
-      size_comm_send[iswap] = nsend * atom->size_comm;
-      size_comm_recv[iswap] = nrecv * atom->size_comm;
-      size_reverse_send[iswap] = nrecv * atom->size_reverse;
-      size_reverse_recv[iswap] = nsend * atom->size_reverse;
+      size_comm_recv[iswap] = nrecv * avec->size_comm;
+      size_reverse_send[iswap] = nrecv * avec->size_reverse;
+      size_reverse_recv[iswap] = nsend * avec->size_reverse;
       firstrecv[iswap] = atom->nlocal + atom->nghost;
       atom->nghost += nrecv;
       iswap++;
@@ -548,172 +562,74 @@ void Comm::borders()
 }
 
 /* ----------------------------------------------------------------------
-   realloc the size of the send buffer as needed with BUFFACTOR & BUFEXTRA 
-   if flag = 1, realloc
-   if flag = 0, don't need to realloc with copy, just free/malloc
+   forward communication invoked by a Pair
 ------------------------------------------------------------------------- */
 
-void Comm::grow_send(int n, int flag)
+void Comm::comm_pair(Pair *pair)
 {
-  maxsend = static_cast<int> (BUFFACTOR * n);
-  if (flag)
-    buf_send = (double *) 
-      memory->srealloc(buf_send,(maxsend+BUFEXTRA)*sizeof(double),
-		       "comm:buf_send");
-  else {
-    memory->sfree(buf_send);
-    buf_send = (double *) memory->smalloc((maxsend+BUFEXTRA)*sizeof(double),
-					  "comm:buf_send");
-  }
-}
+  int iswap,n;
+  double *buf;
+  MPI_Request request;
+  MPI_Status status;
 
-/* ----------------------------------------------------------------------
-   free/malloc the size of the recv buffer as needed with BUFFACTOR 
-------------------------------------------------------------------------- */
+  for (iswap = 0; iswap < nswap; iswap++) {
 
-void Comm::grow_recv(int n)
-{
-  maxrecv = static_cast<int> (BUFFACTOR * n);
-  memory->sfree(buf_recv);
-  buf_recv = (double *) memory->smalloc(maxrecv*sizeof(double),
-					"comm:buf_recv");
-}
+    // pack buffer
 
-/* ----------------------------------------------------------------------
-   realloc the size of the iswap sendlist as needed with BUFFACTOR 
-------------------------------------------------------------------------- */
+    n = pair->pack_comm(sendnum[iswap],sendlist[iswap],
+			buf_send,pbc_flags[iswap]);
 
-void Comm::grow_list(int iswap, int n)
-{
-  maxsendlist[iswap] = static_cast<int> (BUFFACTOR * n);
-  sendlist[iswap] = (int *) 
-    memory->srealloc(sendlist[iswap],maxsendlist[iswap]*sizeof(int),
-		     "comm:sendlist[iswap]");
-}
+    // exchange with another proc
+    // if self, set recv buffer to send buffer
 
-/* ----------------------------------------------------------------------
-   realloc the buffers needed for swaps 
-------------------------------------------------------------------------- */
+    if (sendproc[iswap] != me) {
+      MPI_Irecv(buf_recv,n*recvnum[iswap],MPI_DOUBLE,recvproc[iswap],0,
+		world,&request);
+      MPI_Send(buf_send,n*sendnum[iswap],MPI_DOUBLE,sendproc[iswap],0,world);
+      MPI_Wait(&request,&status);
+      buf = buf_recv;
+    } else buf = buf_send;
 
-void Comm::grow_swap()
-{
-  free_swap();
-  allocate_swap(nswap);
+    // unpack buffer
 
-  sendlist = (int **) memory->srealloc(sendlist,nswap*sizeof(int *),
-				       "comm:sendlist");
-  maxsendlist = (int *) memory->srealloc(maxsendlist,nswap*sizeof(int),
-					 "comm:maxsendlist");
-  for (int i = maxswap; i < nswap; i++) {
-    maxsendlist[i] = BUFMIN;
-    sendlist[i] = (int *) memory->smalloc(BUFMIN*sizeof(int),
-					  "comm:sendlist[i]");
+    pair->unpack_comm(recvnum[iswap],firstrecv[iswap],buf);
   }
-  maxswap = nswap;
 }
 
 /* ----------------------------------------------------------------------
-   initial allocation of swap info 
+   reverse communication invoked by a Pair
 ------------------------------------------------------------------------- */
 
-void Comm::allocate_swap(int n)
+void Comm::reverse_comm_pair(Pair *pair)
 {
-  sendnum = (int *) memory->smalloc(n*sizeof(int),"comm:sendnum");
-  recvnum = (int *) memory->smalloc(n*sizeof(int),"comm:recvnum");
-  sendproc = (int *) memory->smalloc(n*sizeof(int),"comm:sendproc");
-  recvproc = (int *) memory->smalloc(n*sizeof(int),"comm:recvproc");
-  size_comm_send = (int *) memory->smalloc(n*sizeof(int),"comm:size");
-  size_comm_recv = (int *) memory->smalloc(n*sizeof(int),"comm:size");
-  size_reverse_send = (int *) memory->smalloc(n*sizeof(int),"comm:size");
-  size_reverse_recv = (int *) memory->smalloc(n*sizeof(int),"comm:size");
-  slablo = (double *) memory->smalloc(n*sizeof(double),"comm:slablo");
-  slabhi = (double *) memory->smalloc(n*sizeof(double),"comm:slabhi");
-  firstrecv = (int *) memory->smalloc(n*sizeof(int),"comm:firstrecv");
-  pbc_flags = (int **) memory->create_2d_int_array(n,4,"comm:pbc_flags");
-}
-
-/* ----------------------------------------------------------------------
-   free memory for swaps 
-------------------------------------------------------------------------- */
+  int iswap,n;
+  double *buf;
+  MPI_Request request;
+  MPI_Status status;
 
-void Comm::free_swap()
-{
-  memory->sfree(sendnum);
-  memory->sfree(recvnum);
-  memory->sfree(sendproc);
-  memory->sfree(recvproc);
-  memory->sfree(size_comm_send);
-  memory->sfree(size_comm_recv);
-  memory->sfree(size_reverse_send);
-  memory->sfree(size_reverse_recv);
-  memory->sfree(slablo);
-  memory->sfree(slabhi);
-  memory->sfree(firstrecv);
-  memory->destroy_2d_int_array(pbc_flags);
-}
+  for (iswap = nswap-1; iswap >= 0; iswap--) {
 
-/* ----------------------------------------------------------------------
-   assign nprocs to 3d xprd,yprd,zprd box so as to minimize surface area 
-------------------------------------------------------------------------- */
+    // pack buffer
 
-void Comm::procs2box()
-{
-  int ipx,ipy,ipz,nremain;
-  double boxx,boxy,boxz,surf;
+    n = pair->pack_reverse_comm(recvnum[iswap],firstrecv[iswap],buf_send);
 
-  double xprd = domain->xprd;
-  double yprd = domain->yprd;
-  double zprd = domain->zprd;
+    // exchange with another proc 
+    // if self, set recv buffer to send buffer
 
-  double bestsurf = 2.0 * (xprd*yprd + yprd*zprd + zprd*xprd);
+    if (sendproc[iswap] != me) {
+      MPI_Irecv(buf_recv,n*sendnum[iswap],MPI_DOUBLE,sendproc[iswap],0,
+		world,&request);
+      MPI_Send(buf_send,n*recvnum[iswap],MPI_DOUBLE,recvproc[iswap],0,world);
+      MPI_Wait(&request,&status);
+      buf = buf_recv;
+    } else buf = buf_send;
 
-  // loop thru all possible factorizations of nprocs
-  // surf = surface area of a proc sub-domain
-  // for 2d, insure ipz = 1
+    // unpack buffer
 
-  ipx = 1;
-  while (ipx <= nprocs) {
-    if (nprocs % ipx == 0) {
-      nremain = nprocs/ipx;
-      ipy = 1;
-      while (ipy <= nremain) {
-	if (nremain % ipy == 0) {
-	  ipz = nremain/ipy;
-	  if (force->dimension == 3 || ipz == 1) {
-	    boxx = xprd/ipx;
-	    boxy = yprd/ipy;
-	    boxz = zprd/ipz;
-	    surf = boxx*boxy + boxy*boxz + boxz*boxx;
-	    if (surf < bestsurf) {
-	      bestsurf = surf;
-	      procgrid[0] = ipx;
-	      procgrid[1] = ipy;
-	      procgrid[2] = ipz;
-	    }
-	  }
-	}
-	ipy++;
-      }
-    }
-    ipx++;
+    pair->unpack_reverse_comm(sendnum[iswap],sendlist[iswap],buf);
   }
 }
 
-/* ----------------------------------------------------------------------
-   return # of bytes of allocated memory 
-------------------------------------------------------------------------- */
-
-int Comm::memory_usage()
-{
-  int bytes = 0;
-
-  for (int i = 0; i < nswap; i++) bytes += maxsendlist[i] * sizeof(int);
-  bytes += maxsend * sizeof(double);
-  bytes += maxrecv * sizeof(double);
-
-  return bytes;
-}
-
 /* ----------------------------------------------------------------------
    forward communication invoked by a Fix
 ------------------------------------------------------------------------- */
@@ -784,10 +700,10 @@ void Comm::reverse_comm_fix(Fix *fix)
 }
 
 /* ----------------------------------------------------------------------
-   forward communication invoked by a Pair
+   forward communication invoked by a Compute
 ------------------------------------------------------------------------- */
 
-void Comm::comm_pair(Pair *pair)
+void Comm::comm_compute(Compute *compute)
 {
   int iswap,n;
   double *buf;
@@ -798,8 +714,8 @@ void Comm::comm_pair(Pair *pair)
 
     // pack buffer
 
-    n = pair->pack_comm(sendnum[iswap],sendlist[iswap],
-			buf_send,pbc_flags[iswap]);
+    n = compute->pack_comm(sendnum[iswap],sendlist[iswap],
+			   buf_send,pbc_flags[iswap]);
 
     // exchange with another proc
     // if self, set recv buffer to send buffer
@@ -814,15 +730,15 @@ void Comm::comm_pair(Pair *pair)
 
     // unpack buffer
 
-    pair->unpack_comm(recvnum[iswap],firstrecv[iswap],buf);
+    compute->unpack_comm(recvnum[iswap],firstrecv[iswap],buf);
   }
 }
 
 /* ----------------------------------------------------------------------
-   reverse communication invoked by a Pair
+   reverse communication invoked by a Compute
 ------------------------------------------------------------------------- */
 
-void Comm::reverse_comm_pair(Pair *pair)
+void Comm::reverse_comm_compute(Compute *compute)
 {
   int iswap,n;
   double *buf;
@@ -833,7 +749,7 @@ void Comm::reverse_comm_pair(Pair *pair)
 
     // pack buffer
 
-    n = pair->pack_reverse_comm(recvnum[iswap],firstrecv[iswap],buf_send);
+    n = compute->pack_reverse_comm(recvnum[iswap],firstrecv[iswap],buf_send);
 
     // exchange with another proc 
     // if self, set recv buffer to send buffer
@@ -848,6 +764,171 @@ void Comm::reverse_comm_pair(Pair *pair)
 
     // unpack buffer
 
-    pair->unpack_reverse_comm(sendnum[iswap],sendlist[iswap],buf);
+    compute->unpack_reverse_comm(sendnum[iswap],sendlist[iswap],buf);
+  }
+}
+
+/* ----------------------------------------------------------------------
+   assign nprocs to 3d xprd,yprd,zprd box so as to minimize surface area 
+------------------------------------------------------------------------- */
+
+void Comm::procs2box()
+{
+  int ipx,ipy,ipz,nremain;
+  double boxx,boxy,boxz,surf;
+
+  double xprd = domain->xprd;
+  double yprd = domain->yprd;
+  double zprd = domain->zprd;
+
+  double bestsurf = 2.0 * (xprd*yprd + yprd*zprd + zprd*xprd);
+
+  // loop thru all possible factorizations of nprocs
+  // surf = surface area of a proc sub-domain
+  // for 2d, insure ipz = 1
+
+  ipx = 1;
+  while (ipx <= nprocs) {
+    if (nprocs % ipx == 0) {
+      nremain = nprocs/ipx;
+      ipy = 1;
+      while (ipy <= nremain) {
+	if (nremain % ipy == 0) {
+	  ipz = nremain/ipy;
+	  if (force->dimension == 3 || ipz == 1) {
+	    boxx = xprd/ipx;
+	    boxy = yprd/ipy;
+	    boxz = zprd/ipz;
+	    surf = boxx*boxy + boxy*boxz + boxz*boxx;
+	    if (surf < bestsurf) {
+	      bestsurf = surf;
+	      procgrid[0] = ipx;
+	      procgrid[1] = ipy;
+	      procgrid[2] = ipz;
+	    }
+	  }
+	}
+	ipy++;
+      }
+    }
+    ipx++;
+  }
+}
+
+/* ----------------------------------------------------------------------
+   realloc the size of the send buffer as needed with BUFFACTOR & BUFEXTRA 
+   if flag = 1, realloc
+   if flag = 0, don't need to realloc with copy, just free/malloc
+------------------------------------------------------------------------- */
+
+void Comm::grow_send(int n, int flag)
+{
+  maxsend = static_cast<int> (BUFFACTOR * n);
+  if (flag)
+    buf_send = (double *) 
+      memory->srealloc(buf_send,(maxsend+BUFEXTRA)*sizeof(double),
+		       "comm:buf_send");
+  else {
+    memory->sfree(buf_send);
+    buf_send = (double *) memory->smalloc((maxsend+BUFEXTRA)*sizeof(double),
+					  "comm:buf_send");
   }
 }
+
+/* ----------------------------------------------------------------------
+   free/malloc the size of the recv buffer as needed with BUFFACTOR 
+------------------------------------------------------------------------- */
+
+void Comm::grow_recv(int n)
+{
+  maxrecv = static_cast<int> (BUFFACTOR * n);
+  memory->sfree(buf_recv);
+  buf_recv = (double *) memory->smalloc(maxrecv*sizeof(double),
+					"comm:buf_recv");
+}
+
+/* ----------------------------------------------------------------------
+   realloc the size of the iswap sendlist as needed with BUFFACTOR 
+------------------------------------------------------------------------- */
+
+void Comm::grow_list(int iswap, int n)
+{
+  maxsendlist[iswap] = static_cast<int> (BUFFACTOR * n);
+  sendlist[iswap] = (int *) 
+    memory->srealloc(sendlist[iswap],maxsendlist[iswap]*sizeof(int),
+		     "comm:sendlist[iswap]");
+}
+
+/* ----------------------------------------------------------------------
+   realloc the buffers needed for swaps 
+------------------------------------------------------------------------- */
+
+void Comm::grow_swap()
+{
+  free_swap();
+  allocate_swap(nswap);
+
+  sendlist = (int **) memory->srealloc(sendlist,nswap*sizeof(int *),
+				       "comm:sendlist");
+  maxsendlist = (int *) memory->srealloc(maxsendlist,nswap*sizeof(int),
+					 "comm:maxsendlist");
+  for (int i = maxswap; i < nswap; i++) {
+    maxsendlist[i] = BUFMIN;
+    sendlist[i] = (int *) memory->smalloc(BUFMIN*sizeof(int),
+					  "comm:sendlist[i]");
+  }
+  maxswap = nswap;
+}
+
+/* ----------------------------------------------------------------------
+   initial allocation of swap info 
+------------------------------------------------------------------------- */
+
+void Comm::allocate_swap(int n)
+{
+  sendnum = (int *) memory->smalloc(n*sizeof(int),"comm:sendnum");
+  recvnum = (int *) memory->smalloc(n*sizeof(int),"comm:recvnum");
+  sendproc = (int *) memory->smalloc(n*sizeof(int),"comm:sendproc");
+  recvproc = (int *) memory->smalloc(n*sizeof(int),"comm:recvproc");
+  size_comm_recv = (int *) memory->smalloc(n*sizeof(int),"comm:size");
+  size_reverse_send = (int *) memory->smalloc(n*sizeof(int),"comm:size");
+  size_reverse_recv = (int *) memory->smalloc(n*sizeof(int),"comm:size");
+  slablo = (double *) memory->smalloc(n*sizeof(double),"comm:slablo");
+  slabhi = (double *) memory->smalloc(n*sizeof(double),"comm:slabhi");
+  firstrecv = (int *) memory->smalloc(n*sizeof(int),"comm:firstrecv");
+  pbc_flags = (int **) memory->create_2d_int_array(n,4,"comm:pbc_flags");
+}
+
+/* ----------------------------------------------------------------------
+   free memory for swaps 
+------------------------------------------------------------------------- */
+
+void Comm::free_swap()
+{
+  memory->sfree(sendnum);
+  memory->sfree(recvnum);
+  memory->sfree(sendproc);
+  memory->sfree(recvproc);
+  memory->sfree(size_comm_recv);
+  memory->sfree(size_reverse_send);
+  memory->sfree(size_reverse_recv);
+  memory->sfree(slablo);
+  memory->sfree(slabhi);
+  memory->sfree(firstrecv);
+  memory->destroy_2d_int_array(pbc_flags);
+}
+
+/* ----------------------------------------------------------------------
+   return # of bytes of allocated memory 
+------------------------------------------------------------------------- */
+
+int Comm::memory_usage()
+{
+  int bytes = 0;
+
+  for (int i = 0; i < nswap; i++) bytes += maxsendlist[i] * sizeof(int);
+  bytes += maxsend * sizeof(double);
+  bytes += maxrecv * sizeof(double);
+
+  return bytes;
+}
diff --git a/src/comm.h b/src/comm.h
index 4abfc5810b30c62b16257713c75e91283e861e68..232a6aec3116aa93cf4f2e54ea043da15021ec65 100644
--- a/src/comm.h
+++ b/src/comm.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -11,17 +11,14 @@
    See the README file in the top-level LAMMPS directory.
 ------------------------------------------------------------------------- */
 
-// interprocessor communication
-
 #ifndef COMM_H
 #define COMM_H
 
-#include "lammps.h"
+#include "pointers.h"
 
-class Fix;
-class Pair;
+namespace LAMMPS_NS {
 
-class Comm : public LAMMPS {
+class Comm : protected Pointers {
  public:
   int me,nprocs;                    // proc info
   int procgrid[3];                  // assigned # of procs in each dim
@@ -30,10 +27,10 @@ class Comm : public LAMMPS {
   int procneigh[3][2];              // my 6 neighboring procs
   int nswap;                        // # of swaps to perform
   int need[3];                      // procs I need atoms from in each dim
-  int maxforward_fix,maxreverse_fix; // comm sizes called from Fix,Pair
+  int maxforward_fix,maxreverse_fix;   // comm sizes called from Fix,Pair
   int maxforward_pair,maxreverse_pair;
   
-  Comm();
+  Comm(class LAMMPS *);
   ~Comm();
 
   void init();
@@ -43,25 +40,28 @@ class Comm : public LAMMPS {
   void reverse_communicate();       // reverse communication of forces
   void exchange();                  // move atoms to new procs
   void borders();                   // setup list of atoms to communicate
+
+  void comm_pair(class Pair *);                // forward comm from a Pair
+  void reverse_comm_pair(class Pair *);        // reverse comm from a Pair
+  void comm_fix(class Fix *);                  // forward comm from a Fix
+  void reverse_comm_fix(class Fix *);          // reverse comm from a Fix
+  void comm_compute(class Compute *);          // forward comm from a Compute
+  void reverse_comm_compute(class Compute *);  // reverse comm from a Compute
+
   int memory_usage();               // tally memory usage
-  void comm_fix(Fix *);             // forward comm from a Fix
-  void reverse_comm_fix(Fix *);     // reverse comm from a Fix
-  void comm_pair(Pair *);           // forward comm from a Pair
-  void reverse_comm_pair(Pair *);   // reverse comm from a Pair
 
  private:
   int maxswap;                      // max # of swaps memory is allocated for
   int *sendnum,*recvnum;            // # of atoms to send/recv in each swap
   int *sendproc,*recvproc;          // proc to send/recv to/from at each swap
-  int *size_comm_send;              // # of values to send in each comm
-  int *size_comm_recv;              // # of values to recv in each comm
+  int *size_comm_recv;              // # of values to recv in each forward comm
   int *size_reverse_send;           // # to send in each reverse comm
   int *size_reverse_recv;           // # to recv in each reverse comm
   double *slablo,*slabhi;           // bounds of slab to send at each swap
   int **pbc_flags;                  // flags for sending atoms thru PBC
                                     // [0] = 1 if any dim is across PBC
                                     // [123] = 1 if dim 012 is across PBC
-  int direct_flag;                  // 1 if only x,f are forward/reverse comm
+  int comm_x_only,comm_f_only;      // 1 if only exchange x,f in for/rev comm
   int map_style;                    // non-0 if global->local mapping is done
 
   int *firstrecv;                   // where to put 1st recv atom in each swap
@@ -82,4 +82,6 @@ class Comm : public LAMMPS {
   void free_swap();                 // free swap arrays
 };
 
+}
+
 #endif
diff --git a/src/create_atoms.cpp b/src/create_atoms.cpp
index 78f9946fab22f61767a72c40cfd834c55d279c19..ad7c53226eaab5e0e4122ac1aaa89ea2566f7b21 100644
--- a/src/create_atoms.cpp
+++ b/src/create_atoms.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,18 +16,26 @@
 #include "string.h"
 #include "create_atoms.h"
 #include "atom.h"
+#include "atom_vec.h"
+#include "atom_vec_hybrid.h"
 #include "comm.h"
 #include "domain.h"
 #include "lattice.h"
 #include "region.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define MAXATOMS 0x7FFFFFFF
 #define BIG      1.0e30
 #define EPSILON  1.0e-6
 
 /* ---------------------------------------------------------------------- */
 
+CreateAtoms::CreateAtoms(LAMMPS *lmp) : Pointers(lmp) {}
+
+/* ---------------------------------------------------------------------- */
+
 void CreateAtoms::command(int narg, char **arg)
 {
   if (domain->box_exist == 0) 
@@ -47,6 +55,7 @@ void CreateAtoms::command(int narg, char **arg)
   for (int i = 0; i < nbasis; i++) basistype[i] = itype;
 
   regionflag = -1;
+  nhybrid = 0;
 
   int iarg = 1;
   while (iarg < narg) {
@@ -68,6 +77,16 @@ void CreateAtoms::command(int narg, char **arg)
 	error->all("Illegal create_atoms command");
       basistype[ibasis-1] = itype;
       iarg += 3;
+    } else if (strcmp(arg[iarg],"hybrid") == 0) {
+      if (iarg+3 > narg) error->all("Illegal create_atoms command");
+      AtomVecHybrid *avec_hybrid = (AtomVecHybrid *) atom->avec;
+      int ihybrid;
+      for (ihybrid = 0; ihybrid < avec_hybrid->nstyles; ihybrid++)
+	if (strcmp(avec_hybrid->keywords[ihybrid],arg[iarg+1]) == 0) break;
+      if (ihybrid == avec_hybrid->nstyles)
+	error->all("Create atoms hybrid sub-style does not exist");
+      nhybrid = ihybrid;
+      iarg += 3;
     } else error->all("Illegal create_atoms command");
   }
 
@@ -175,7 +194,7 @@ void CreateAtoms::command(int narg, char **arg)
    add an atom of type at lattice coords x,y,z if it meets all criteria 
 ------------------------------------------------------------------------- */
 
-void CreateAtoms::add_atom(int type, double x, double y, double z)
+void CreateAtoms::add_atom(int ntype, double x, double y, double z)
 {
   // convert from lattice coords to box coords
 
@@ -201,5 +220,5 @@ void CreateAtoms::add_atom(int type, double x, double y, double z)
 
   // add the atom to my list of atoms
 
-  atom->create_one(type,x,y,z);
+  atom->avec->create_atom(ntype,x,y,z,nhybrid);
 }
diff --git a/src/create_atoms.h b/src/create_atoms.h
index 7b9e7ceba4368c3c7241576fb7bf81be57368e09..a5b3b513141e8313509b78a311d72d34bd7d967d 100644
--- a/src/create_atoms.h
+++ b/src/create_atoms.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -14,20 +14,23 @@
 #ifndef CREATE_ATOMS_H
 #define CREATE_ATOMS_H
 
-#include "lammps.h"
+#include "pointers.h"
 
-class CreateAtoms : public LAMMPS {
+namespace LAMMPS_NS {
+
+class CreateAtoms : protected Pointers {
  public:
-  CreateAtoms() {}
-  ~CreateAtoms() {}
+  CreateAtoms(class LAMMPS *);
   void command(int, char **);
 
  private:
-  int regionflag;
+  int regionflag,nhybrid;
   double boxxhi,boxyhi,boxzhi;
   double subxlo,subxhi,subylo,subyhi,subzlo,subzhi;
 
   void add_atom(int, double, double, double);
 };
 
+}
+
 #endif
diff --git a/src/create_box.cpp b/src/create_box.cpp
index eee4763fb07e735e438c0b4583cc5d215dcf07cb..19c88aaf51278a103e5ef60a9a239eb284f4f3d3 100644
--- a/src/create_box.cpp
+++ b/src/create_box.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -22,16 +22,20 @@
 #include "update.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
+/* ---------------------------------------------------------------------- */
+
+CreateBox::CreateBox(LAMMPS *lmp) : Pointers(lmp) {}
+
 /* ---------------------------------------------------------------------- */
 
 void CreateBox::command(int narg, char **arg)
 {
-  if (atom == NULL)
-    error->all("Cannot create_box until atom_style is defined");
-  if (domain->box_exist) 
-    error->all("Cannot create_box after simulation box is defined");
   if (narg != 2) error->all("Illegal create_box command");
 
+  if (domain->box_exist) 
+    error->all("Cannot create_box after simulation box is defined");
   if (force->dimension == 2 && domain->zperiodic == 0)
     error->all("Cannot run 2d simulation with nonperiodic Z dimension");
 
@@ -90,7 +94,7 @@ void CreateBox::command(int narg, char **arg)
   atom->nimpropertypes = 0;
 
   // problem setup using info from header
-  // no call to atom->grow since create_atoms or insertion will do that
+  // no call to atom->grow since create_atoms or fixes will do it
 
   update->ntimestep = 0;
 
diff --git a/src/create_box.h b/src/create_box.h
index 31b8f50c1ae55aa79b989084fd4eda25799e9335..3c4f85ffbb41c22a0539ba535edabeb7f0956782 100644
--- a/src/create_box.h
+++ b/src/create_box.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -14,13 +14,16 @@
 #ifndef CREATE_BOX_H
 #define CREATE_BOX_H
 
-#include "lammps.h"
+#include "pointers.h"
 
-class CreateBox : public LAMMPS {
+namespace LAMMPS_NS {
+
+class CreateBox : protected Pointers {
  public:
-  CreateBox() {}
-  ~CreateBox() {}
+  CreateBox(class LAMMPS *);
   void command(int, char **);
 };
 
+}
+
 #endif
diff --git a/src/delete_atoms.cpp b/src/delete_atoms.cpp
index ce881b4d0db2f15b97d47aeacff1c964097365e4..d21893c1c91b7ab00ba43777406ef0319e1b7ced 100644
--- a/src/delete_atoms.cpp
+++ b/src/delete_atoms.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -14,8 +14,8 @@
 #include "stdlib.h"
 #include "string.h"
 #include "delete_atoms.h"
-#include "system.h"
 #include "atom.h"
+#include "atom_vec.h"
 #include "comm.h"
 #include "domain.h"
 #include "force.h"
@@ -26,11 +26,17 @@
 #include "force.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define MIN(a,b) ((a) < (b) ? (a) : (b))
 #define MAX(a,b) ((a) > (b) ? (a) : (b))
 
 /* ---------------------------------------------------------------------- */
 
+DeleteAtoms::DeleteAtoms(LAMMPS *lmp) : Pointers(lmp) {}
+
+/* ---------------------------------------------------------------------- */
+
 void DeleteAtoms::command(int narg, char **arg)
 {
   if (domain->box_exist == 0) 
@@ -61,12 +67,12 @@ void DeleteAtoms::command(int narg, char **arg)
   // delete local atoms in list
   // reset nlocal
 
-  int *tag = atom->tag;
+  AtomVec *avec = atom->avec;
 
   int i = 0;
   while (i < nlocal) {
     if (list[i]) {
-      atom->copy(nlocal-1,i);
+      avec->copy(nlocal-1,i);
       list[i] = list[nlocal-1];
       nlocal--;
     } else i++;
@@ -185,7 +191,7 @@ void DeleteAtoms::delete_overlap(int narg, char **arg, int *list)
   if (comm->me == 0 && screen)
     fprintf(screen,"System init for delete_atoms ...\n");
   neighbor->half_command = 1;
-  sys->init();
+  lmp->init();
   neighbor->half_command = 0;
 
   // setup domain, communication and neighboring
diff --git a/src/delete_atoms.h b/src/delete_atoms.h
index 5def81bbf62f1f12a851f5ca39f3864219f3bad7..e33ab7d007449409520c828e8c3125b23b48a2c8 100644
--- a/src/delete_atoms.h
+++ b/src/delete_atoms.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -14,12 +14,13 @@
 #ifndef DELETE_ATOMS_H
 #define DELETE_ATOMS_H
 
-#include "lammps.h"
+#include "pointers.h"
 
-class DeleteAtoms : public LAMMPS {
+namespace LAMMPS_NS {
+
+class DeleteAtoms : protected Pointers {
  public:
-  DeleteAtoms() {}
-  ~DeleteAtoms() {}
+  DeleteAtoms(class LAMMPS *);
   void command(int, char **);
 
  private:
@@ -28,4 +29,6 @@ class DeleteAtoms : public LAMMPS {
   void delete_overlap(int, char **, int *);
 };
 
+}
+
 #endif
diff --git a/src/delete_bonds.cpp b/src/delete_bonds.cpp
index 9f03f4d63ef2f34cb62945dae96dd557bfdc43cc..79b964aebd976e02366c6981a3d2d220ac6f9380 100644
--- a/src/delete_bonds.cpp
+++ b/src/delete_bonds.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -15,8 +15,8 @@
 #include "stdlib.h"
 #include "string.h"
 #include "delete_bonds.h"
-#include "system.h"
 #include "atom.h"
+#include "atom_vec.h"
 #include "domain.h"
 #include "neighbor.h"
 #include "comm.h"
@@ -26,6 +26,8 @@
 #include "special.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define MULTI    1
 #define ATOM     2
 #define BOND     3
@@ -36,6 +38,10 @@
 
 /* ---------------------------------------------------------------------- */
 
+DeleteBonds::DeleteBonds(LAMMPS *lmp) : Pointers(lmp) {}
+
+/* ---------------------------------------------------------------------- */
+
 void DeleteBonds::command(int narg, char **arg)
 {
   if (domain->box_exist == 0) 
@@ -51,7 +57,7 @@ void DeleteBonds::command(int narg, char **arg)
 
   if (comm->me == 0 && screen)
     fprintf(screen,"System init for delete_bonds ...\n");
-  sys->init();
+  lmp->init();
 
   if (comm->me == 0 && screen) fprintf(screen,"Deleting bonds ...\n");
 
@@ -122,7 +128,7 @@ void DeleteBonds::command(int narg, char **arg)
   int i,m,n,flag;
   int atom1,atom2,atom3,atom4;
 
-  if (atom->bonds_allow) {
+  if (atom->avec->bonds_allow) {
     int *num_bond = atom->num_bond;
     int **bond_type = atom->bond_type;
 
@@ -147,7 +153,7 @@ void DeleteBonds::command(int narg, char **arg)
     }
   }
 
-  if (atom->angles_allow) {
+  if (atom->avec->angles_allow) {
     int *num_angle = atom->num_angle;
     int **angle_type = atom->angle_type;
 
@@ -177,7 +183,7 @@ void DeleteBonds::command(int narg, char **arg)
     }
   }
 
-  if (atom->dihedrals_allow) {
+  if (atom->avec->dihedrals_allow) {
     int *num_dihedral = atom->num_dihedral;
     int **dihedral_type = atom->dihedral_type;
 
@@ -208,7 +214,7 @@ void DeleteBonds::command(int narg, char **arg)
     }
   }
 
-  if (atom->impropers_allow) {
+  if (atom->avec->impropers_allow) {
     int *num_improper = atom->num_improper;
     int **improper_type = atom->improper_type;
 
@@ -244,7 +250,7 @@ void DeleteBonds::command(int narg, char **arg)
 
   if (remove_flag) {
 
-    if (atom->bonds_allow) {
+    if (atom->avec->bonds_allow) {
       for (i = 0; i < nlocal; i++) {
 	m = 0;
 	while (m < atom->num_bond[i]) {
@@ -261,7 +267,7 @@ void DeleteBonds::command(int narg, char **arg)
       }
     }
 
-    if (atom->angles_allow) {
+    if (atom->avec->angles_allow) {
       for (i = 0; i < nlocal; i++) {
 	m = 0;
 	while (m < atom->num_angle[i]) {
@@ -283,7 +289,7 @@ void DeleteBonds::command(int narg, char **arg)
       }
     }
 
-    if (atom->dihedrals_allow) {
+    if (atom->avec->dihedrals_allow) {
       for (i = 0; i < nlocal; i++) {
 	m = 0;
 	while (m < atom->num_dihedral[i]) {
@@ -307,7 +313,7 @@ void DeleteBonds::command(int narg, char **arg)
       }
     }
 
-    if (atom->impropers_allow) {
+    if (atom->avec->impropers_allow) {
       for (i = 0; i < nlocal; i++) {
 	m = 0;
 	while (m < atom->num_improper[i]) {
@@ -337,28 +343,28 @@ void DeleteBonds::command(int narg, char **arg)
 
   if (remove_flag) {
 
-    if (atom->bonds_allow) {
+    if (atom->avec->bonds_allow) {
       int nbonds = 0;
       for (i = 0; i < nlocal; i++) nbonds += atom->num_bond[i];
       MPI_Allreduce(&nbonds,&atom->nbonds,1,MPI_INT,MPI_SUM,world);
       if (force->newton_bond == 0) atom->nbonds /= 2;
     }
 
-    if (atom->angles_allow) {
+    if (atom->avec->angles_allow) {
       int nangles = 0;
       for (i = 0; i < nlocal; i++) nangles += atom->num_angle[i];
       MPI_Allreduce(&nangles,&atom->nangles,1,MPI_INT,MPI_SUM,world);
       if (force->newton_bond == 0) atom->nangles /= 3;
     }
 
-    if (atom->dihedrals_allow) {
+    if (atom->avec->dihedrals_allow) {
       int ndihedrals = 0;
       for (i = 0; i < nlocal; i++) ndihedrals += atom->num_dihedral[i];
       MPI_Allreduce(&ndihedrals,&atom->ndihedrals,1,MPI_INT,MPI_SUM,world);
       if (force->newton_bond == 0) atom->ndihedrals /= 4;
     }
 
-    if (atom->impropers_allow) {
+    if (atom->avec->impropers_allow) {
       int nimpropers = 0;
       for (i = 0; i < nlocal; i++) nimpropers += atom->num_improper[i];
       MPI_Allreduce(&nimpropers,&atom->nimpropers,1,MPI_INT,MPI_SUM,world);
@@ -375,7 +381,7 @@ void DeleteBonds::command(int narg, char **arg)
   int dihedral_on,dihedral_off;
   int improper_on,improper_off;
 
-  if (atom->bonds_allow) {
+  if (atom->avec->bonds_allow) {
     bond_on = bond_off = 0;
     for (i = 0; i < nlocal; i++)
       for (m = 0; m < atom->num_bond[i]; m++)
@@ -391,7 +397,7 @@ void DeleteBonds::command(int narg, char **arg)
     }
   }
 
-  if (atom->angles_allow) {
+  if (atom->avec->angles_allow) {
     angle_on = angle_off = 0;
     for (i = 0; i < nlocal; i++)
       for (m = 0; m < atom->num_angle[i]; m++)
@@ -407,7 +413,7 @@ void DeleteBonds::command(int narg, char **arg)
     }
   }
 
-  if (atom->dihedrals_allow) {
+  if (atom->avec->dihedrals_allow) {
     dihedral_on = dihedral_off = 0;
     for (i = 0; i < nlocal; i++)
       for (m = 0; m < atom->num_dihedral[i]; m++)
@@ -423,7 +429,7 @@ void DeleteBonds::command(int narg, char **arg)
     }
   }
 
-  if (atom->impropers_allow) {
+  if (atom->avec->impropers_allow) {
     improper_on = improper_off = 0;
     for (i = 0; i < nlocal; i++)
       for (m = 0; m < atom->num_improper[i]; m++)
@@ -441,30 +447,30 @@ void DeleteBonds::command(int narg, char **arg)
 
   if (comm->me == 0) {
     if (screen) {
-      if (atom->bonds_allow)
+      if (atom->avec->bonds_allow)
 	fprintf(screen,"  %d total bonds, %d turned on, %d turned off\n",
 		atom->nbonds,bond_on,bond_off);
-      if (atom->angles_allow)
+      if (atom->avec->angles_allow)
 	fprintf(screen,"  %d total angles, %d turned on, %d turned off\n",
 		atom->nangles,angle_on,angle_off);
-      if (atom->dihedrals_allow)
+      if (atom->avec->dihedrals_allow)
 	fprintf(screen,"  %d total dihedrals, %d turned on, %d turned off\n",
 		atom->ndihedrals,dihedral_on,dihedral_off);
-      if (atom->impropers_allow)
+      if (atom->avec->impropers_allow)
 	fprintf(screen,"  %d total impropers, %d turned on, %d turned off\n",
 		atom->nimpropers,improper_on,improper_off);
     }
     if (logfile) {
-      if (atom->bonds_allow)
+      if (atom->avec->bonds_allow)
 	fprintf(logfile,"  %d total bonds, %d turned on, %d turned off\n",
 		atom->nbonds,bond_on,bond_off);
-      if (atom->angles_allow)
+      if (atom->avec->angles_allow)
 	fprintf(logfile,"  %d total angles, %d turned on, %d turned off\n",
 		atom->nangles,angle_on,angle_off);
-      if (atom->dihedrals_allow)
+      if (atom->avec->dihedrals_allow)
 	fprintf(logfile,"  %d total dihedrals, %d turned on, %d turned off\n",
 		atom->ndihedrals,dihedral_on,dihedral_off);
-      if (atom->impropers_allow)
+      if (atom->avec->impropers_allow)
 	fprintf(logfile,"  %d total impropers, %d turned on, %d turned off\n",
 		atom->nimpropers,improper_on,improper_off);
     }
@@ -473,7 +479,7 @@ void DeleteBonds::command(int narg, char **arg)
   // re-compute special list if requested
 
   if (special_flag) {
-    Special special;
+    Special special(lmp);
     special.build();
   }
 }
diff --git a/src/delete_bonds.h b/src/delete_bonds.h
index 3f57a3fa16c1666bea8093d983fcdea61dda582b..2f9e5ba391206bb15fc36729dee5aeb953fa457c 100644
--- a/src/delete_bonds.h
+++ b/src/delete_bonds.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -14,13 +14,16 @@
 #ifndef DELETE_BONDS_H
 #define DELETE_BONDS_H
 
-#include "lammps.h"
+#include "pointers.h"
 
-class DeleteBonds : public LAMMPS {
+namespace LAMMPS_NS {
+
+class DeleteBonds : protected Pointers {
  public:
-  DeleteBonds() {}
-  ~DeleteBonds() {}
+  DeleteBonds(class LAMMPS *);
   void command(int, char **);
 };
 
+}
+
 #endif
diff --git a/src/dihedral.h b/src/dihedral.h
index db9296a678228e5146065dc2130132710d080b34..eddeaa35585c918742bcd6b9c75a4a855406276a 100644
--- a/src/dihedral.h
+++ b/src/dihedral.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -15,9 +15,11 @@
 #define DIHEDRAL_H
 
 #include "stdio.h"
-#include "lammps.h"
+#include "pointers.h"
 
-class Dihedral : public LAMMPS {
+namespace LAMMPS_NS {
+
+class Dihedral : protected Pointers {
  public:
   int allocated;
   int *setflag;
@@ -26,7 +28,7 @@ class Dihedral : public LAMMPS {
   double virial[6];
   double PI;
 
-  Dihedral();
+  Dihedral(class LAMMPS *);
   virtual ~Dihedral() {}
   virtual void init();
   virtual void init_style() {}
@@ -39,4 +41,6 @@ class Dihedral : public LAMMPS {
   virtual int memory_usage() {return 0;}
 };
 
+}
+
 #endif
diff --git a/src/displace_atoms.cpp b/src/displace_atoms.cpp
index 2f73bdc46ec0444092609950b82e5f13867b378a..a88279ef845198f64676739bffe0e063a03d0d77 100644
--- a/src/displace_atoms.cpp
+++ b/src/displace_atoms.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -15,7 +15,6 @@
 #include "stdlib.h"
 #include "string.h"
 #include "displace_atoms.h"
-#include "system.h"
 #include "atom.h"
 #include "domain.h"
 #include "lattice.h"
@@ -23,6 +22,8 @@
 #include "group.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define MOVE 1
 #define RAMP 2
 
@@ -31,6 +32,10 @@
 
 /* ---------------------------------------------------------------------- */
 
+DisplaceAtoms::DisplaceAtoms(LAMMPS *lmp) : Pointers(lmp) {}
+
+/* ---------------------------------------------------------------------- */
+
 void DisplaceAtoms::command(int narg, char **arg)
 {
   if (domain->box_exist == 0) 
@@ -42,7 +47,7 @@ void DisplaceAtoms::command(int narg, char **arg)
 
   if (comm->me == 0 && screen)
     fprintf(screen,"System init for displace_atoms ...\n");
-  sys->init();
+  lmp->init();
 
   if (comm->me == 0 && screen) fprintf(screen,"Displacing atoms ...\n");
 
diff --git a/src/displace_atoms.h b/src/displace_atoms.h
index c60f74b22ca71ba0135fc88195f2dc6a27b62f56..6ddf79c42866a8f96a993d4f984c0953e5871651 100644
--- a/src/displace_atoms.h
+++ b/src/displace_atoms.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -14,12 +14,13 @@
 #ifndef DISPLACE_ATOMS_H
 #define DISPLACE_ATOMS_H
 
-#include "lammps.h"
+#include "pointers.h"
 
-class DisplaceAtoms : public LAMMPS {
+namespace LAMMPS_NS {
+
+class DisplaceAtoms : protected Pointers {
  public:
-  DisplaceAtoms() {}
-  ~DisplaceAtoms() {}
+  DisplaceAtoms(class LAMMPS *);
   void command(int, char **);
 
  private:
@@ -27,4 +28,6 @@ class DisplaceAtoms : public LAMMPS {
   void options(int, char **);
 };
 
+}
+
 #endif
diff --git a/src/domain.cpp b/src/domain.cpp
index 2456bf4f9d1446bf44a76c81c109424496151283..fa62258e1c509e1ee26fe9fcfb38216234b0b4aa 100644
--- a/src/domain.cpp
+++ b/src/domain.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -32,6 +32,8 @@
 #include "style.h"
 #undef RegionInclude
 
+using namespace LAMMPS_NS;
+
 #define BIG   1.0e20
 #define SMALL 1.0e-4
 #define DELTA 1
@@ -42,7 +44,7 @@
    default is periodic 
 ------------------------------------------------------------------------- */
 
-Domain::Domain()
+Domain::Domain(LAMMPS *lmp) : Pointers(lmp)
 {
   box_exist = 0;
 
@@ -458,7 +460,7 @@ void Domain::unmap(double &x, double &y, double &z, int image)
 void Domain::set_lattice(int narg, char **arg)
 {
   delete lattice;
-  lattice = new Lattice(narg,arg);
+  lattice = new Lattice(lmp,narg,arg);
   if (lattice->style == 0) {
     delete lattice;
     lattice = NULL;
@@ -493,7 +495,8 @@ void Domain::add_region(int narg, char **arg)
 
 #define RegionClass
 #define RegionStyle(key,Class) \
-  else if (strcmp(arg[1],#key) == 0) regions[nregion] = new Class(narg,arg);
+  else if (strcmp(arg[1],#key) == 0) \
+    regions[nregion] = new Class(lmp,narg,arg);
 #include "style.h"
 #undef RegionClass
 
diff --git a/src/domain.h b/src/domain.h
index 31cddeb8ccfd68dec513cb332325057c49910533..11f88ec6b4d2f1bb83b4f593e6135566fd4aded2 100644
--- a/src/domain.h
+++ b/src/domain.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -14,11 +14,11 @@
 #ifndef DOMAIN_H
 #define DOMAIN_H
 
-#include "lammps.h"
-class Lattice;
-class Region;
+#include "pointers.h"
 
-class Domain : public LAMMPS {
+namespace LAMMPS_NS {
+
+class Domain : protected Pointers {
  public:
   int box_exist;                            // 0 = not yet created, 1 = exists
 
@@ -54,13 +54,13 @@ class Domain : public LAMMPS {
 
   int box_change;            // 1 if box bounds ever change, 0 if fixed
 
-  Lattice *lattice;              // user-defined lattice
+  class Lattice *lattice;        // user-defined lattice
 
   int nregion;                   // # of defined Regions
   int maxregion;                 // max # list can hold
-  Region **regions;              // list of defined Regions
+  class Region **regions;        // list of defined Regions
 
-  Domain();
+  Domain(class LAMMPS *);
   ~Domain();
   void init();
   void set_initial_box();
@@ -77,4 +77,6 @@ class Domain : public LAMMPS {
   void set_boundary(int, char **);
 };
 
+}
+
 #endif
diff --git a/src/dump.cpp b/src/dump.cpp
index 8a8aa746319af4e9831d6f5385370a10be98f004..8b269f69c1c59b6d462fb286c04c55f21af6cf2e 100644
--- a/src/dump.cpp
+++ b/src/dump.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -23,9 +23,11 @@
 #include "memory.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 /* ---------------------------------------------------------------------- */
 
-Dump::Dump(int narg, char **arg)
+Dump::Dump(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp)
 {
   MPI_Comm_rank(world,&me);
   MPI_Comm_size(world,&nprocs);
diff --git a/src/dump.h b/src/dump.h
index 0db98105199afe9c9cce7450f919d41c8b750a11..906fc69368d45e1821dbffe59ae14f3a35e2c193 100644
--- a/src/dump.h
+++ b/src/dump.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -15,9 +15,11 @@
 #define DUMP_H
 
 #include "stdio.h"
-#include "lammps.h"
+#include "pointers.h"
 
-class Dump : public LAMMPS {
+namespace LAMMPS_NS {
+
+class Dump : protected Pointers {
  public:
   char *id;                  // user-defined name of Dump
   char *style;               // style of Dump
@@ -41,7 +43,7 @@ class Dump : public LAMMPS {
   FILE *fp;                  // file to write dump to
   int size_one;              // # of quantities for one atom
 
-  Dump(int, char **);
+  Dump(class LAMMPS *, int, char **);
   virtual ~Dump();
   virtual void init() {}
   void write();
@@ -58,4 +60,6 @@ class Dump : public LAMMPS {
   virtual void write_data(int, double *) = 0;
 };
 
+}
+
 #endif
diff --git a/src/dump_atom.cpp b/src/dump_atom.cpp
index 72d339f2b794bd0f4478173a39c0e4440dbb7026..ea7b25eed96026ca510c21b66c3a69be79ea65af 100644
--- a/src/dump_atom.cpp
+++ b/src/dump_atom.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -19,9 +19,11 @@
 #include "group.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 /* ---------------------------------------------------------------------- */
 
-DumpAtom::DumpAtom(int narg, char **arg) : Dump(narg, arg)
+DumpAtom::DumpAtom(LAMMPS *lmp, int narg, char **arg) : Dump(lmp, narg, arg)
 {
   if (narg != 5) error->all("Illegal dump atom command");
 
diff --git a/src/dump_atom.h b/src/dump_atom.h
index 4a0d1cdbe60991b26bb8759e038bf64f4db140fa..9b01d07831322da1781c466fa24a1c413e967a1a 100644
--- a/src/dump_atom.h
+++ b/src/dump_atom.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,10 +16,11 @@
 
 #include "dump.h"
 
+namespace LAMMPS_NS {
+
 class DumpAtom : public Dump {
  public:
-  DumpAtom(int, char**);
-  ~DumpAtom() {}
+  DumpAtom(LAMMPS *, int, char**);
   void init();
 
  private:
@@ -51,4 +52,6 @@ class DumpAtom : public Dump {
   void write_noimage(int, double *);
 };
 
+}
+
 #endif
diff --git a/src/dump_custom.cpp b/src/dump_custom.cpp
index aa0bd1af42a301702c0558f249f17253d1c2621b..147ffdeae601210413c512e39364affbe9e1f393 100644
--- a/src/dump_custom.cpp
+++ b/src/dump_custom.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -21,34 +21,32 @@
 #include "group.h"
 #include "update.h"
 #include "modify.h"
-#include "fix.h"
-#include "fix_centro.h"
-#include "fix_energy.h"
-#include "fix_stress.h"
+#include "compute.h"
 #include "memory.h"
 #include "error.h"
 
-// customize by adding to 1st enum
+using namespace LAMMPS_NS;
 
-enum{TAG,MOL,TYPE,X,Y,Z,XS,YS,ZS,XU,YU,ZU,IX,IY,IZ,VX,VY,VZ,FX,FY,FZ,
-       Q,MUX,MUY,MUZ,TQX,TQY,TQZ,
-       ETOTAL,KE,EPAIR,CENTRO,SXX,SYY,SZZ,SXY,SXZ,SYZ};
+// customize by adding keyword to 1st enum
+
+enum{TAG,MOL,TYPE,X,Y,Z,XS,YS,ZS,XU,YU,ZU,IX,IY,IZ,
+     VX,VY,VZ,FX,FY,FZ,
+     Q,MUX,MUY,MUZ,TQX,TQY,TQZ,
+     EPAIR,KE,ETOTAL,CENTRO,SXX,SYY,SZZ,SXY,SXZ,SYZ,
+     COMPUTE};
 enum{LT,LE,GT,GE,EQ,NEQ};
 enum{INT,DOUBLE};
 
 /* ---------------------------------------------------------------------- */
 
-DumpCustom::DumpCustom(int narg, char **arg) : Dump(narg, arg)
+DumpCustom::DumpCustom(LAMMPS *lmp, int narg, char **arg) :
+  Dump(lmp, narg, arg)
 {
-  int i;
-
   if (narg == 5) error->all("No dump custom arguments specified");
 
-  nevery = atoi(arg[3]);
-
-  size_one = narg-5;
-  pack_choice = new FnPtrPack[size_one];
-  vtype = new int[size_one];
+  size_one = nfield = narg-5;
+  pack_choice = new FnPtrPack[nfield];
+  vtype = new int[nfield];
 
   iregion = -1;
   nthresh = 0;
@@ -56,174 +54,41 @@ DumpCustom::DumpCustom(int narg, char **arg) : Dump(narg, arg)
   thresh_op = NULL;
   thresh_value = NULL;
 
-  fixflag_epair = 0;
-  fixflag_centro = 0;
-  fixflag_stress = 0;
+  // flags, IDs, and memory for compute objects dump may create
 
-  computeflag_etotal = 0;
-  computeflag_ke = 0;
+  index_epair = index_ke = index_etotal = index_centro = index_stress = -1;
 
-  // process command args
-  // customize by adding to if statement
+  style_epair = "epair/atom";
+  style_ke = "ke/atom";
+  style_etotal = "etotal/atom";
+  style_centro = "centro/atom";
+  style_stress = "stress/atom";
 
-  for (int iarg = 5; iarg < narg; iarg++) {
-    i = iarg-5;
-    if (strcmp(arg[iarg],"tag") == 0) {
-      pack_choice[i] = &DumpCustom::pack_tag;
-      vtype[i] = INT;
-    } else if (strcmp(arg[iarg],"mol") == 0) {
-      if (atom->molecule == NULL)
-	error->all("Dumping an atom quantity that isn't allocated");
-      pack_choice[i] = &DumpCustom::pack_molecule;
-      vtype[i] = INT;
-    } else if (strcmp(arg[iarg],"type") == 0) {
-      pack_choice[i] = &DumpCustom::pack_type;
-      vtype[i] = INT;
-    } else if (strcmp(arg[iarg],"x") == 0) {
-      pack_choice[i] = &DumpCustom::pack_x;
-      vtype[i] = DOUBLE;
-    } else if (strcmp(arg[iarg],"y") == 0) {
-      pack_choice[i] = &DumpCustom::pack_y;
-      vtype[i] = DOUBLE;
-    } else if (strcmp(arg[iarg],"z") == 0) {
-      pack_choice[i] = &DumpCustom::pack_z;
-      vtype[i] = DOUBLE;
-    } else if (strcmp(arg[iarg],"xs") == 0) {
-      pack_choice[i] = &DumpCustom::pack_xs;
-      vtype[i] = DOUBLE;
-    } else if (strcmp(arg[iarg],"ys") == 0) {
-      pack_choice[i] = &DumpCustom::pack_ys;
-      vtype[i] = DOUBLE;
-    } else if (strcmp(arg[iarg],"zs") == 0) {
-      pack_choice[i] = &DumpCustom::pack_zs;
-      vtype[i] = DOUBLE;
-    } else if (strcmp(arg[iarg],"xu") == 0) {
-      pack_choice[i] = &DumpCustom::pack_xu;
-      vtype[i] = DOUBLE;
-    } else if (strcmp(arg[iarg],"yu") == 0) {
-      pack_choice[i] = &DumpCustom::pack_yu;
-      vtype[i] = DOUBLE;
-    } else if (strcmp(arg[iarg],"zu") == 0) {
-      pack_choice[i] = &DumpCustom::pack_zu;
-      vtype[i] = DOUBLE;
-    } else if (strcmp(arg[iarg],"ix") == 0) {
-      pack_choice[i] = &DumpCustom::pack_ix;
-      vtype[i] = INT;
-    } else if (strcmp(arg[iarg],"iy") == 0) {
-      pack_choice[i] = &DumpCustom::pack_iy;
-      vtype[i] = INT;
-    } else if (strcmp(arg[iarg],"iz") == 0) {
-      pack_choice[i] = &DumpCustom::pack_iz;
-      vtype[i] = INT;
-    } else if (strcmp(arg[iarg],"vx") == 0) {
-      pack_choice[i] = &DumpCustom::pack_vx;
-      vtype[i] = DOUBLE;
-    } else if (strcmp(arg[iarg],"vy") == 0) {
-      pack_choice[i] = &DumpCustom::pack_vy;
-      vtype[i] = DOUBLE;
-    } else if (strcmp(arg[iarg],"vz") == 0) {
-      pack_choice[i] = &DumpCustom::pack_vz;
-      vtype[i] = DOUBLE;
-    } else if (strcmp(arg[iarg],"fx") == 0) {
-      pack_choice[i] = &DumpCustom::pack_fx;
-      vtype[i] = DOUBLE;
-    } else if (strcmp(arg[iarg],"fy") == 0) {
-      pack_choice[i] = &DumpCustom::pack_fy;
-      vtype[i] = DOUBLE;
-    } else if (strcmp(arg[iarg],"fz") == 0) {
-      pack_choice[i] = &DumpCustom::pack_fz;
-      vtype[i] = DOUBLE;
-    } else if (strcmp(arg[iarg],"q") == 0) {
-      if (atom->q == NULL)
-	error->all("Dumping an atom quantity that isn't allocated");
-      pack_choice[i] = &DumpCustom::pack_q;
-      vtype[i] = DOUBLE;
-    } else if (strcmp(arg[iarg],"mux") == 0) {
-      if (atom->mu == NULL)
-	error->all("Dumping an atom quantity that isn't allocated");
-      pack_choice[i] = &DumpCustom::pack_mux;
-      vtype[i] = DOUBLE;
-    } else if (strcmp(arg[iarg],"muy") == 0) {
-      if (atom->mu == NULL)
-	error->all("Dumping an atom quantity that isn't allocated");
-      pack_choice[i] = &DumpCustom::pack_muy;
-      vtype[i] = DOUBLE;
-    } else if (strcmp(arg[iarg],"muz") == 0) {
-      if (atom->mu == NULL)
-	error->all("Dumping an atom quantity that isn't allocated");
-      pack_choice[i] = &DumpCustom::pack_muz;
-      vtype[i] = DOUBLE;
-    } else if (strcmp(arg[iarg],"tqx") == 0) {
-      if (atom->torque == NULL)
-	error->all("Dumping an atom quantity that isn't allocated");
-      pack_choice[i] = &DumpCustom::pack_tqx;
-      vtype[i] = DOUBLE;
-    } else if (strcmp(arg[iarg],"tqy") == 0) {
-      if (atom->torque == NULL)
-	error->all("Dumping an atom quantity that isn't allocated");
-      pack_choice[i] = &DumpCustom::pack_tqy;
-      vtype[i] = DOUBLE;
-    } else if (strcmp(arg[iarg],"tqz") == 0) {
-      if (atom->torque == NULL)
-	error->all("Dumping an atom quantity that isn't allocated");
-      pack_choice[i] = &DumpCustom::pack_tqz;
-      vtype[i] = DOUBLE;
-    } else if (strcmp(arg[iarg],"etotal") == 0) {
-      pack_choice[i] = &DumpCustom::pack_etotal;
-      vtype[i] = DOUBLE;
-      computeflag_etotal = 1;
-      computeflag_ke = 1;
-      fixflag_epair = 1;
-    } else if (strcmp(arg[iarg],"ke") == 0) {
-      pack_choice[i] = &DumpCustom::pack_ke;
-      vtype[i] = DOUBLE;
-      computeflag_ke = 1;
-    } else if (strcmp(arg[iarg],"epair") == 0) {
-      pack_choice[i] = &DumpCustom::pack_epair;
-      vtype[i] = DOUBLE;
-      fixflag_epair = 1;
-    } else if (strcmp(arg[iarg],"centro") == 0) {
-      pack_choice[i] = &DumpCustom::pack_centro;
-      vtype[i] = DOUBLE;
-      fixflag_centro = 1;
-    } else if (strcmp(arg[iarg],"sxx") == 0) {
-      pack_choice[i] = &DumpCustom::pack_sxx;
-      vtype[i] = DOUBLE;
-      fixflag_stress = 1;
-    } else if (strcmp(arg[iarg],"syy") == 0) {
-      pack_choice[i] = &DumpCustom::pack_syy;
-      vtype[i] = DOUBLE;
-      fixflag_stress = 1;
-    } else if (strcmp(arg[iarg],"szz") == 0) {
-      pack_choice[i] = &DumpCustom::pack_szz;
-      vtype[i] = DOUBLE;
-      fixflag_stress = 1;
-    } else if (strcmp(arg[iarg],"sxy") == 0) {
-      pack_choice[i] = &DumpCustom::pack_sxy;
-      vtype[i] = DOUBLE;
-      fixflag_stress = 1;
-    } else if (strcmp(arg[iarg],"sxz") == 0) {
-      pack_choice[i] = &DumpCustom::pack_sxz;
-      vtype[i] = DOUBLE;
-      fixflag_stress = 1;
-    } else if (strcmp(arg[iarg],"syz") == 0) {
-      pack_choice[i] = &DumpCustom::pack_syz;
-      vtype[i] = DOUBLE;
-      fixflag_stress = 1;
-    } else error->all("Invalid keyword in dump custom command");
-  }
+  ncompute = 0;
+  id_compute = NULL;
+  compute = NULL;
+  field2compute = (int *) memory->smalloc(nfield*sizeof(int),
+					  "dump:field2compute");
+  arg_compute = (int *) memory->smalloc(nfield*sizeof(int),"dump:arg_compute");
+
+  // process keywords
 
-  if (fixflag_epair) fix_create("ENERGY");
-  if (fixflag_centro) fix_create("CENTRO");
-  if (fixflag_stress) fix_create("STRESS");
+  parse_fields(narg,arg);
+
+  // create the requested Computes
+
+  if (index_epair >= 0) create_compute(style_epair,NULL);
+  if (index_ke >= 0) create_compute(style_ke,NULL);
+  if (index_etotal >= 0) create_compute(style_etotal,style_epair);
+  if (index_centro >= 0) create_compute(style_centro,NULL);
+  if (index_stress >= 0) create_compute(style_stress,NULL);
+
+  // atom selection arrays
 
   maxlocal = 0;
   choose = NULL;
   dchoose = NULL;
 
-  if (computeflag_etotal) etotal = NULL;
-  if (computeflag_ke) ke = NULL;
-
   // setup format strings
 
   vformat = new char*[size_one];
@@ -231,7 +96,7 @@ DumpCustom::DumpCustom(int narg, char **arg) : Dump(narg, arg)
   format_default = new char[3*size_one+1];
   format_default[0] = '\0';
 
-  for (i = 0; i < size_one; i++) {
+  for (int i = 0; i < size_one; i++) {
     if (vtype[i] == INT) format_default = strcat(format_default,"%d ");
     else format_default = strcat(format_default,"%g ");
     vformat[i] = NULL;
@@ -242,36 +107,36 @@ DumpCustom::DumpCustom(int narg, char **arg) : Dump(narg, arg)
   if (multifile == 0) openfile();
 }
 
-/* ----------------------------------------------------------------------
-   free memory
-------------------------------------------------------------------------- */
+/* ---------------------------------------------------------------------- */
 
 DumpCustom::~DumpCustom()
 {
   delete [] pack_choice;
   delete [] vtype;
-  for (int i = 0; i < size_one; i++) delete [] vformat[i];
-  delete [] vformat;
 
-  if (nthresh) {
-    memory->sfree(thresh_array);
-    memory->sfree(thresh_op);
-    memory->sfree(thresh_value);
-  }
+  memory->sfree(thresh_array);
+  memory->sfree(thresh_op);
+  memory->sfree(thresh_value);
 
-  // delete fixes for computing per-atom custom quantities if they exist
+  // delete Compute classes if dump custom created them
 
-  if (fixflag_epair) fix_delete("ENERGY");
-  if (fixflag_centro) fix_delete("CENTRO");
-  if (fixflag_stress) fix_delete("STRESS");
+  if (index_epair >= 0)  modify->delete_compute(id_compute[index_epair]);
+  if (index_ke >= 0)  modify->delete_compute(id_compute[index_ke]);
+  if (index_etotal >= 0)  modify->delete_compute(id_compute[index_etotal]);
+  if (index_centro >= 0)  modify->delete_compute(id_compute[index_centro]);
+  if (index_stress >= 0)  modify->delete_compute(id_compute[index_stress]);
 
-  // delete choose arrays and local compute arrys if they exist
+  for (int i = 0; i < ncompute; i++) delete [] id_compute[i];
+  memory->sfree(id_compute);
+  memory->sfree(compute);
+  memory->sfree(field2compute);
+  memory->sfree(arg_compute);
 
   delete [] choose;
   delete [] dchoose;
 
-  if (computeflag_etotal) delete [] etotal;
-  if (computeflag_ke) delete [] ke;
+  for (int i = 0; i < size_one; i++) delete [] vformat[i];
+  delete [] vformat;
 }
 
 /* ---------------------------------------------------------------------- */
@@ -307,160 +172,55 @@ void DumpCustom::init()
   if (binary) write_choice = &DumpCustom::write_binary;
   else write_choice = &DumpCustom::write_text;
 
-  // set fixflag if dump invokes any fixes
+  // find current ptr for each Compute ID
 
-  fixflag = 0;
-  if (fixflag_epair || fixflag_centro || fixflag_stress) fixflag = 1;
-
-  // find associated fixes that must exist
-  // could have changed locations in fix list since created
-
-  if (fixflag_epair) ifix_epair = fix_match("ENERGY");
-  if (fixflag_centro) ifix_centro = fix_match("CENTRO");
-  if (fixflag_stress) ifix_stress = fix_match("STRESS");
-
-  // set computeflag if dump invokes any local computation
-
-  computeflag = 0;
-  if (computeflag_etotal || computeflag_ke) computeflag = 1;
+  int icompute;
+  for (int i = 0; i < ncompute; i++) {
+    icompute = modify->find_compute(id_compute[i]);
+    if (icompute < 0) error->all("Could not find dump custom compute ID");
+    compute[i] = modify->compute[icompute];
+  }
 }
 
-/* ----------------------------------------------------------------------
-   return # of bytes of allocated memory in buf and choose and local arrays
-------------------------------------------------------------------------- */
+/* ---------------------------------------------------------------------- */
 
-int DumpCustom::memory_usage()
+void DumpCustom::write_header(int ndump)
 {
-  int bytes = maxbuf * sizeof(double);
-  bytes += maxlocal * sizeof(int);
-  bytes += maxlocal * sizeof(double);
-  if (computeflag_etotal) bytes += maxlocal * sizeof(double);
-  if (computeflag_ke) bytes += maxlocal * sizeof(double);
-  return bytes;
+  (this->*header_choice)(ndump);
 }
 
 /* ---------------------------------------------------------------------- */
 
-int DumpCustom::modify_param(int narg, char **arg)
+void DumpCustom::header_binary(int ndump)
 {
-  if (strcmp(arg[0],"region") == 0) {
-    if (narg < 2) error->all("Illegal dump_modify command");
-    if (strcmp(arg[1],"none") == 0) iregion = -1;
-    else {
-      for (iregion = 0; iregion < domain->nregion; iregion++)
-	if (strcmp(arg[1],domain->regions[iregion]->id) == 0) break;
-      if (iregion == domain->nregion)
-	error->all("Dump_modify region ID does not exist");
-    }
-    return 2;
-
-  } else if (strcmp(arg[0],"thresh") == 0) {
-    if (narg < 2) error->all("Illegal dump_modify command");
-    if (strcmp(arg[1],"none") == 0) {
-      if (nthresh) {
-	memory->sfree(thresh_array);
-	memory->sfree(thresh_op);
-	memory->sfree(thresh_value);
-	thresh_array = NULL;
-	thresh_op = NULL;
-	thresh_value = NULL;
-      }
-      nthresh = 0;
-      return 2;
-    }
-    
-    if (narg < 4) error->all("Illegal dump_modify command");
-    thresh_array = (int *)
-      memory->srealloc(thresh_array,(nthresh+1)*sizeof(int),
-		       "dump:thresh_array");
-    thresh_op = (int *)
-      memory->srealloc(thresh_op,(nthresh+1)*sizeof(int),
-		       "dump:thresh_op");
-    thresh_value = (double *)
-      memory->srealloc(thresh_value,(nthresh+1)*sizeof(double),
-		       "dump:thresh_value");
-
-    // customize by adding to if statement
-
-    if (strcmp(arg[1],"tag") == 0) thresh_array[nthresh] = TAG;
-    else if (strcmp(arg[1],"mol") == 0) thresh_array[nthresh] = MOL;
-    else if (strcmp(arg[1],"type") == 0) thresh_array[nthresh] = TYPE;
-    else if (strcmp(arg[1],"x") == 0) thresh_array[nthresh] = X;
-    else if (strcmp(arg[1],"y") == 0) thresh_array[nthresh] = Y;
-    else if (strcmp(arg[1],"z") == 0) thresh_array[nthresh] = Z;
-    else if (strcmp(arg[1],"xs") == 0) thresh_array[nthresh] = XS;
-    else if (strcmp(arg[1],"ys") == 0) thresh_array[nthresh] = YS;
-    else if (strcmp(arg[1],"zs") == 0) thresh_array[nthresh] = ZS;
-    else if (strcmp(arg[1],"xu") == 0) thresh_array[nthresh] = XU;
-    else if (strcmp(arg[1],"yu") == 0) thresh_array[nthresh] = YU;
-    else if (strcmp(arg[1],"zu") == 0) thresh_array[nthresh] = ZU;
-    else if (strcmp(arg[1],"ix") == 0) thresh_array[nthresh] = IX;
-    else if (strcmp(arg[1],"iy") == 0) thresh_array[nthresh] = IY;
-    else if (strcmp(arg[1],"iz") == 0) thresh_array[nthresh] = IZ;
-    else if (strcmp(arg[1],"vx") == 0) thresh_array[nthresh] = VX;
-    else if (strcmp(arg[1],"vy") == 0) thresh_array[nthresh] = VY;
-    else if (strcmp(arg[1],"vz") == 0) thresh_array[nthresh] = VZ;
-    else if (strcmp(arg[1],"fx") == 0) thresh_array[nthresh] = FX;
-    else if (strcmp(arg[1],"fy") == 0) thresh_array[nthresh] = FY;
-    else if (strcmp(arg[1],"fz") == 0) thresh_array[nthresh] = FZ;
-    else if (strcmp(arg[1],"q") == 0) thresh_array[nthresh] = Q;
-    else if (strcmp(arg[1],"mux") == 0) thresh_array[nthresh] = MUX;
-    else if (strcmp(arg[1],"muy") == 0) thresh_array[nthresh] = MUY;
-    else if (strcmp(arg[1],"muz") == 0) thresh_array[nthresh] = MUZ;
-    else if (strcmp(arg[1],"tqx") == 0) thresh_array[nthresh] = TQX;
-    else if (strcmp(arg[1],"tqy") == 0) thresh_array[nthresh] = TQY;
-    else if (strcmp(arg[1],"tqz") == 0) thresh_array[nthresh] = TQZ;
-    else if (strcmp(arg[1],"etotal") == 0) thresh_array[nthresh] = ETOTAL;
-    else if (strcmp(arg[1],"ke") == 0) thresh_array[nthresh] = KE;
-    else if (strcmp(arg[1],"epair") == 0) thresh_array[nthresh] = EPAIR;
-    else if (strcmp(arg[1],"centro") == 0) thresh_array[nthresh] = CENTRO;
-    else if (strcmp(arg[1],"sxx") == 0) thresh_array[nthresh] = SXX;
-    else if (strcmp(arg[1],"syy") == 0) thresh_array[nthresh] = SYY;
-    else if (strcmp(arg[1],"szz") == 0) thresh_array[nthresh] = SZZ;
-    else if (strcmp(arg[1],"sxy") == 0) thresh_array[nthresh] = SXY;
-    else if (strcmp(arg[1],"sxz") == 0) thresh_array[nthresh] = SXZ;
-    else if (strcmp(arg[1],"syz") == 0) thresh_array[nthresh] = SYZ;
-    else error->all("Invalid dump_modify threshhold operator");
-
-    if (strcmp(arg[2],">=") == 0) thresh_op[nthresh] = LT;
-    else if (strcmp(arg[2],">") == 0) thresh_op[nthresh] = LE;
-    else if (strcmp(arg[2],"<=") == 0) thresh_op[nthresh] = GT;
-    else if (strcmp(arg[2],"<") == 0) thresh_op[nthresh] = GE;
-    else if (strcmp(arg[2],"=") == 0) thresh_op[nthresh] = NEQ;
-    else if (strcmp(arg[2],"<>") == 0) thresh_op[nthresh] = EQ;
-    else error->all("Invalid dump_modify threshhold operator");
-
-    thresh_value[nthresh] = atof(arg[3]);
-
-    // add new fix if necessary
-
-    if (thresh_array[nthresh] == EPAIR && fixflag_epair == 0) {
-      fix_create("ENERGY");
-      fixflag_epair = 1;
-    }
-    if (thresh_array[nthresh] == CENTRO && fixflag_centro == 0) {
-      fix_create("CENTRO");
-      fixflag_centro = 1;
-    }
-    if ((thresh_array[nthresh] == SXX || thresh_array[nthresh] == SYY ||
-	thresh_array[nthresh] == SZZ || thresh_array[nthresh] == SXY ||
-	thresh_array[nthresh] == SXZ || thresh_array[nthresh] == SYZ) &&
-	fixflag_stress == 0) {
-      fix_create("STRESS");
-      fixflag_stress = 1;
-    }
-
-    nthresh++;
-    return 4;
-  }
-  return 0;
+  fwrite(&update->ntimestep,sizeof(int),1,fp);
+  fwrite(&ndump,sizeof(int),1,fp);
+  fwrite(&domain->boxxlo,sizeof(double),1,fp);
+  fwrite(&domain->boxxhi,sizeof(double),1,fp);
+  fwrite(&domain->boxylo,sizeof(double),1,fp);
+  fwrite(&domain->boxyhi,sizeof(double),1,fp);
+  fwrite(&domain->boxzlo,sizeof(double),1,fp);
+  fwrite(&domain->boxzhi,sizeof(double),1,fp);
+  fwrite(&size_one,sizeof(int),1,fp);
+  if (multiproc) {
+    int one = 1;
+    fwrite(&one,sizeof(int),1,fp);
+  } else fwrite(&nprocs,sizeof(int),1,fp);
 }
 
 /* ---------------------------------------------------------------------- */
 
-void DumpCustom::write_header(int ndump)
+void DumpCustom::header_item(int ndump)
 {
-  (this->*header_choice)(ndump);
+  fprintf(fp,"ITEM: TIMESTEP\n");
+  fprintf(fp,"%d\n",update->ntimestep);
+  fprintf(fp,"ITEM: NUMBER OF ATOMS\n");
+  fprintf(fp,"%d\n",ndump);
+  fprintf(fp,"ITEM: BOX BOUNDS\n");
+  fprintf(fp,"%g %g\n",domain->boxxlo,domain->boxxhi);
+  fprintf(fp,"%g %g\n",domain->boxylo,domain->boxyhi);
+  fprintf(fp,"%g %g\n",domain->boxzlo,domain->boxzhi);
+  fprintf(fp,"ITEM: ATOMS\n");
 }
 
 /* ---------------------------------------------------------------------- */
@@ -469,36 +229,21 @@ int DumpCustom::count()
 {
   int i;
 
-  // grow choose and local-computation arrays if needed
+  // grow choose arrays if needed
 
   int nlocal = atom->nlocal;
   if (nlocal > maxlocal) {
     delete [] choose;
     delete [] dchoose;
-    if (computeflag_etotal) delete [] etotal;
-    if (computeflag_ke) delete [] ke;
     maxlocal = atom->nmax;
     choose = new int[maxlocal];
     dchoose = new double[maxlocal];
-    if (computeflag_etotal) etotal = new double[maxlocal];
-    if (computeflag_ke) ke = new double[maxlocal];
-  }
-
-  // invoke any fixes that compute dump quantities
-
-  if (fixflag) {
-    if (fixflag_epair) modify->fix[ifix_epair]->dump();
-    if (fixflag_centro) modify->fix[ifix_centro]->dump();
-    if (fixflag_stress) modify->fix[ifix_stress]->dump();
   }
 
-  // invoke any local computation of dump quantities
-  // etotal must come after ke and fix_epair since uses their results
+  // invoke Computes for per-atom dump quantities
 
-  if (computeflag) {
-    if (computeflag_ke) compute_ke();
-    if (computeflag_etotal) compute_etotal();
-  }
+  if (ncompute)
+    for (i = 0; i < ncompute; i++) compute[i]->compute_peratom();
 
   // choose all local atoms for output
 
@@ -669,36 +414,45 @@ int DumpCustom::count()
       } else if (thresh_array[ithresh] == TQZ) {
 	ptr = &atom->torque[0][2];
 	nstride = 3;
-      } else if (thresh_array[ithresh] == ETOTAL) {
-	ptr = etotal;
+      } else if (thresh_array[ithresh] == EPAIR) {
+	ptr = compute[index_epair]->scalar_atom;
 	nstride = 1;
       } else if (thresh_array[ithresh] == KE) {
-	ptr = ke;
+	ptr = compute[index_ke]->scalar_atom;
 	nstride = 1;
-      } else if (thresh_array[ithresh] == EPAIR) {
-	ptr = ((FixEnergy *) modify->fix[ifix_epair])->energy;
+      } else if (thresh_array[ithresh] == ETOTAL) {
+	ptr = compute[index_etotal]->scalar_atom;
 	nstride = 1;
       } else if (thresh_array[ithresh] == CENTRO) {
-	ptr = ((FixCentro *) modify->fix[ifix_centro])->centro;
+	ptr = compute[index_centro]->scalar_atom;
 	nstride = 1;
       } else if (thresh_array[ithresh] == SXX) {
-	ptr = &((FixStress *) modify->fix[ifix_stress])->stress[0][0];
+	ptr = &compute[index_stress]->vector_atom[0][0];
 	nstride = 6;
       } else if (thresh_array[ithresh] == SYY) {
-	ptr = &((FixStress *) modify->fix[ifix_stress])->stress[0][1];
+	ptr = &compute[index_stress]->vector_atom[0][1];
 	nstride = 6;
       } else if (thresh_array[ithresh] == SZZ) {
-	ptr = &((FixStress *) modify->fix[ifix_stress])->stress[0][2];
+	ptr = &compute[index_stress]->vector_atom[0][2];
 	nstride = 6;
       } else if (thresh_array[ithresh] == SXY) {
-	ptr = &((FixStress *) modify->fix[ifix_stress])->stress[0][3];
+	ptr = &compute[index_stress]->vector_atom[0][3];
 	nstride = 6;
       } else if (thresh_array[ithresh] == SXZ) {
-	ptr = &((FixStress *) modify->fix[ifix_stress])->stress[0][4];
+	ptr = &compute[index_stress]->vector_atom[0][4];
 	nstride = 6;
       } else if (thresh_array[ithresh] == SYZ) {
-	ptr = &((FixStress *) modify->fix[ifix_stress])->stress[0][5];
+	ptr = &compute[index_stress]->vector_atom[0][5];
 	nstride = 6;
+      } else if (thresh_array[ithresh] == COMPUTE) {
+	i = nfield + ithresh;
+	if (arg_compute[i] == 0) {
+	  ptr = compute[field2compute[i]]->scalar_atom;
+	  nstride = 1;
+	} else {
+	  ptr = &compute[field2compute[i]]->vector_atom[0][arg_compute[i]-1];
+	  nstride = compute[field2compute[i]]->size_peratom;
+	}
       }
 
       value = thresh_value[ithresh];
@@ -746,150 +500,553 @@ int DumpCustom::count()
   return nmine;
 }
 
-/* ---------------------------------------------------------------------- */
+/* ---------------------------------------------------------------------- */
+
+int DumpCustom::pack()
+{
+  for (int n = 0; n < size_one; n++) (this->*pack_choice[n])(n);
+  return nmine*size_one;
+}
+
+/* ---------------------------------------------------------------------- */
+
+void DumpCustom::write_data(int n, double *buf)
+{
+  (this->*write_choice)(n,buf);
+}
+
+/* ---------------------------------------------------------------------- */
+
+void DumpCustom::write_binary(int n, double *buf)
+{
+  n *= size_one;
+  fwrite(&n,sizeof(int),1,fp);
+  fwrite(buf,sizeof(double),n,fp);
+}
+
+/* ---------------------------------------------------------------------- */
+
+void DumpCustom::write_text(int n, double *buf)
+{
+  int i,j;
+
+  int m = 0;
+  for (i = 0; i < n; i++) {
+    for (j = 0; j < size_one; j++) {
+      if (vtype[j] == INT) fprintf(fp,vformat[j],static_cast<int> (buf[m]));
+      else fprintf(fp,vformat[j],buf[m]);
+      m++;
+    }
+    fprintf(fp,"\n");
+  }
+}
+
+/* ---------------------------------------------------------------------- */
+
+void DumpCustom::parse_fields(int narg, char **arg)
+{
+  // customize by adding to if statement
+
+  int i;
+  for (int iarg = 5; iarg < narg; iarg++) {
+    i = iarg-5;
+    if (strcmp(arg[iarg],"tag") == 0) {
+      pack_choice[i] = &DumpCustom::pack_tag;
+      vtype[i] = INT;
+    } else if (strcmp(arg[iarg],"mol") == 0) {
+      if (atom->molecule == NULL)
+	error->all("Dumping an atom quantity that isn't allocated");
+      pack_choice[i] = &DumpCustom::pack_molecule;
+      vtype[i] = INT;
+    } else if (strcmp(arg[iarg],"type") == 0) {
+      pack_choice[i] = &DumpCustom::pack_type;
+      vtype[i] = INT;
+    } else if (strcmp(arg[iarg],"x") == 0) {
+      pack_choice[i] = &DumpCustom::pack_x;
+      vtype[i] = DOUBLE;
+    } else if (strcmp(arg[iarg],"y") == 0) {
+      pack_choice[i] = &DumpCustom::pack_y;
+      vtype[i] = DOUBLE;
+    } else if (strcmp(arg[iarg],"z") == 0) {
+      pack_choice[i] = &DumpCustom::pack_z;
+      vtype[i] = DOUBLE;
+    } else if (strcmp(arg[iarg],"xs") == 0) {
+      pack_choice[i] = &DumpCustom::pack_xs;
+      vtype[i] = DOUBLE;
+    } else if (strcmp(arg[iarg],"ys") == 0) {
+      pack_choice[i] = &DumpCustom::pack_ys;
+      vtype[i] = DOUBLE;
+    } else if (strcmp(arg[iarg],"zs") == 0) {
+      pack_choice[i] = &DumpCustom::pack_zs;
+      vtype[i] = DOUBLE;
+    } else if (strcmp(arg[iarg],"xu") == 0) {
+      pack_choice[i] = &DumpCustom::pack_xu;
+      vtype[i] = DOUBLE;
+    } else if (strcmp(arg[iarg],"yu") == 0) {
+      pack_choice[i] = &DumpCustom::pack_yu;
+      vtype[i] = DOUBLE;
+    } else if (strcmp(arg[iarg],"zu") == 0) {
+      pack_choice[i] = &DumpCustom::pack_zu;
+      vtype[i] = DOUBLE;
+    } else if (strcmp(arg[iarg],"ix") == 0) {
+      pack_choice[i] = &DumpCustom::pack_ix;
+      vtype[i] = INT;
+    } else if (strcmp(arg[iarg],"iy") == 0) {
+      pack_choice[i] = &DumpCustom::pack_iy;
+      vtype[i] = INT;
+    } else if (strcmp(arg[iarg],"iz") == 0) {
+      pack_choice[i] = &DumpCustom::pack_iz;
+      vtype[i] = INT;
+    } else if (strcmp(arg[iarg],"vx") == 0) {
+      pack_choice[i] = &DumpCustom::pack_vx;
+      vtype[i] = DOUBLE;
+    } else if (strcmp(arg[iarg],"vy") == 0) {
+      pack_choice[i] = &DumpCustom::pack_vy;
+      vtype[i] = DOUBLE;
+    } else if (strcmp(arg[iarg],"vz") == 0) {
+      pack_choice[i] = &DumpCustom::pack_vz;
+      vtype[i] = DOUBLE;
+    } else if (strcmp(arg[iarg],"fx") == 0) {
+      pack_choice[i] = &DumpCustom::pack_fx;
+      vtype[i] = DOUBLE;
+    } else if (strcmp(arg[iarg],"fy") == 0) {
+      pack_choice[i] = &DumpCustom::pack_fy;
+      vtype[i] = DOUBLE;
+    } else if (strcmp(arg[iarg],"fz") == 0) {
+      pack_choice[i] = &DumpCustom::pack_fz;
+      vtype[i] = DOUBLE;
+    } else if (strcmp(arg[iarg],"q") == 0) {
+      if (atom->q == NULL)
+	error->all("Dumping an atom quantity that isn't allocated");
+      pack_choice[i] = &DumpCustom::pack_q;
+      vtype[i] = DOUBLE;
+    } else if (strcmp(arg[iarg],"mux") == 0) {
+      if (atom->mu == NULL)
+	error->all("Dumping an atom quantity that isn't allocated");
+      pack_choice[i] = &DumpCustom::pack_mux;
+      vtype[i] = DOUBLE;
+    } else if (strcmp(arg[iarg],"muy") == 0) {
+      if (atom->mu == NULL)
+	error->all("Dumping an atom quantity that isn't allocated");
+      pack_choice[i] = &DumpCustom::pack_muy;
+      vtype[i] = DOUBLE;
+    } else if (strcmp(arg[iarg],"muz") == 0) {
+      if (atom->mu == NULL)
+	error->all("Dumping an atom quantity that isn't allocated");
+      pack_choice[i] = &DumpCustom::pack_muz;
+      vtype[i] = DOUBLE;
+    } else if (strcmp(arg[iarg],"tqx") == 0) {
+      if (atom->torque == NULL)
+	error->all("Dumping an atom quantity that isn't allocated");
+      pack_choice[i] = &DumpCustom::pack_tqx;
+      vtype[i] = DOUBLE;
+    } else if (strcmp(arg[iarg],"tqy") == 0) {
+      if (atom->torque == NULL)
+	error->all("Dumping an atom quantity that isn't allocated");
+      pack_choice[i] = &DumpCustom::pack_tqy;
+      vtype[i] = DOUBLE;
+    } else if (strcmp(arg[iarg],"tqz") == 0) {
+      if (atom->torque == NULL)
+	error->all("Dumping an atom quantity that isn't allocated");
+      pack_choice[i] = &DumpCustom::pack_tqz;
+      vtype[i] = DOUBLE;
+    } else if (strcmp(arg[iarg],"epair") == 0) {
+      pack_choice[i] = &DumpCustom::pack_epair;
+      vtype[i] = DOUBLE;
+      index_epair = add_compute(style_epair,1);
+    } else if (strcmp(arg[iarg],"ke") == 0) {
+      pack_choice[i] = &DumpCustom::pack_ke;
+      vtype[i] = DOUBLE;
+      index_ke = add_compute(style_ke,1);
+    } else if (strcmp(arg[iarg],"etotal") == 0) {
+      pack_choice[i] = &DumpCustom::pack_etotal;
+      vtype[i] = DOUBLE;
+      index_epair = add_compute(style_epair,1);
+      index_etotal = add_compute(style_etotal,1);
+    } else if (strcmp(arg[iarg],"centro") == 0) {
+      pack_choice[i] = &DumpCustom::pack_centro;
+      vtype[i] = DOUBLE;
+      index_centro = add_compute(style_centro,1);
+    } else if (strcmp(arg[iarg],"sxx") == 0) {
+      pack_choice[i] = &DumpCustom::pack_sxx;
+      vtype[i] = DOUBLE;
+      index_stress = add_compute(style_stress,1);
+    } else if (strcmp(arg[iarg],"syy") == 0) {
+      pack_choice[i] = &DumpCustom::pack_syy;
+      vtype[i] = DOUBLE;
+      index_stress = add_compute(style_stress,1);
+    } else if (strcmp(arg[iarg],"szz") == 0) {
+      pack_choice[i] = &DumpCustom::pack_szz;
+      vtype[i] = DOUBLE;
+      index_stress = add_compute(style_stress,1);
+    } else if (strcmp(arg[iarg],"sxy") == 0) {
+      pack_choice[i] = &DumpCustom::pack_sxy;
+      vtype[i] = DOUBLE;
+      index_stress = add_compute(style_stress,1);
+    } else if (strcmp(arg[iarg],"sxz") == 0) {
+      pack_choice[i] = &DumpCustom::pack_sxz;
+      vtype[i] = DOUBLE;
+      index_stress = add_compute(style_stress,1);
+    } else if (strcmp(arg[iarg],"syz") == 0) {
+      pack_choice[i] = &DumpCustom::pack_syz;
+      vtype[i] = DOUBLE;
+      index_stress = add_compute(style_stress,1);
+
+    // compute value = c_ID
+    // if no trailing [], then arg is set to 0, else arg is between []
+    // if Compute has pre-compute, first add it to list
 
-int DumpCustom::pack()
-{
-  for (int n = 0; n < size_one; n++) (this->*pack_choice[n])(n);
-  return nmine*size_one;
-}
+    } else if (strncmp(arg[iarg],"c_",2) == 0) {
+      pack_choice[i] = &DumpCustom::pack_compute;
+      vtype[i] = DOUBLE;
 
-/* ---------------------------------------------------------------------- */
+      int n = strlen(arg[iarg]);
+      char *suffix = new char[n];
+      strcpy(suffix,&arg[iarg][2]);
+
+      char *ptr = strchr(suffix,'[');
+      if (ptr) {
+	if (suffix[strlen(suffix)-1] != ']')
+	  error->all("Invalid keyword in dump custom command");
+	arg_compute[i] = atoi(ptr+1);
+	*ptr = '\0';
+      } else arg_compute[i] = 0;
+
+      n = modify->find_compute(suffix);
+      if (n < 0) error->all("Could not find dump custom compute ID");
+      if (modify->compute[n]->peratom_flag == 0)
+	error->all("Dump custom compute ID does not compute peratom info");
+      if (arg_compute[i] == 0 && modify->compute[n]->size_peratom > 0)
+	error->all("Dump custom compute ID does not compute scalar per atom");
+      if (arg_compute[i] > 0 && modify->compute[n]->size_peratom == 0)
+	error->all("Dump custom compute ID does not compute vector per atom");
+      if (arg_compute[i] > 0 && 
+	  arg_compute[i] > modify->compute[n]->size_peratom)
+	error->all("Dump custom compute ID vector is not large enough");
+      if (modify->compute[n]->id_pre)
+	int tmp = add_compute(modify->compute[n]->id_pre,0);
+      field2compute[i] = add_compute(suffix,0);
+      delete [] suffix;
 
-void DumpCustom::write_data(int n, double *buf)
-{
-  (this->*write_choice)(n,buf);
+    } else error->all("Invalid keyword in dump custom command");
+  }
 }
 
-/* ---------------------------------------------------------------------- */
+/* ----------------------------------------------------------------------
+   add Compute to list of Compute objects to call
+   return index of where this Compute is in call list
+   compute ID = dump-ID + "_" + keyword if appendflag is set, else just keyword
+   if already in call list, do not add, just return index, else add to list
+------------------------------------------------------------------------- */
 
-void DumpCustom::header_binary(int ndump)
+int DumpCustom::add_compute(char *keyword, int appendflag)
 {
-  fwrite(&update->ntimestep,sizeof(int),1,fp);
-  fwrite(&ndump,sizeof(int),1,fp);
-  fwrite(&domain->boxxlo,sizeof(double),1,fp);
-  fwrite(&domain->boxxhi,sizeof(double),1,fp);
-  fwrite(&domain->boxylo,sizeof(double),1,fp);
-  fwrite(&domain->boxyhi,sizeof(double),1,fp);
-  fwrite(&domain->boxzlo,sizeof(double),1,fp);
-  fwrite(&domain->boxzhi,sizeof(double),1,fp);
-  fwrite(&size_one,sizeof(int),1,fp);
-  if (multiproc) {
-    int one = 1;
-    fwrite(&one,sizeof(int),1,fp);
-  } else fwrite(&nprocs,sizeof(int),1,fp);
+  int n = strlen(id) + strlen(keyword) + 2;
+  char *name = new char[n];
+  if (appendflag) {
+    strcpy(name,id);
+    strcat(name,"_");
+    strcat(name,keyword);
+  } else strcpy(name,keyword);
+
+  int icompute;
+  for (icompute = 0; icompute < ncompute; icompute++)
+    if (strcmp(name,id_compute[icompute]) == 0) break;
+  if (icompute < ncompute) {
+    delete [] name;
+    return icompute;
+  }
+  
+  id_compute = (char **)
+    memory->srealloc(id_compute,(ncompute+1)*sizeof(char *),"dump:id_compute");
+  compute = (Compute **) 
+    memory->srealloc(compute,(ncompute+1)*sizeof(Compute *),"dump:compute");
+
+  n = strlen(name) + 1;
+  id_compute[ncompute] = new char[n];
+  strcpy(id_compute[ncompute],name);
+  delete [] name;
+  ncompute++;
+  return ncompute-1;
 }
 
-/* ---------------------------------------------------------------------- */
+/* ----------------------------------------------------------------------
+   create a compute
+   compute ID = dump-ID + "_" + keyword, compute style = keyword
+   pass additional extra args to Modify::add_compute() if defined
+------------------------------------------------------------------------- */
 
-void DumpCustom::header_item(int ndump)
+void DumpCustom::create_compute(char *keyword, char *extra)
 {
-  fprintf(fp,"ITEM: TIMESTEP\n");
-  fprintf(fp,"%d\n",update->ntimestep);
-  fprintf(fp,"ITEM: NUMBER OF ATOMS\n");
-  fprintf(fp,"%d\n",ndump);
-  fprintf(fp,"ITEM: BOX BOUNDS\n");
-  fprintf(fp,"%g %g\n",domain->boxxlo,domain->boxxhi);
-  fprintf(fp,"%g %g\n",domain->boxylo,domain->boxyhi);
-  fprintf(fp,"%g %g\n",domain->boxzlo,domain->boxzhi);
-  fprintf(fp,"ITEM: ATOMS\n");
-}
-
-/* ---------------------------------------------------------------------- */
+  int n = strlen(id) + strlen(keyword) + 2;
+  char *name = new char[n];
+  strcpy(name,id);
+  strcat(name,"_");
+  strcat(name,keyword);
 
-void DumpCustom::write_binary(int n, double *buf)
-{
-  n *= size_one;
-  fwrite(&n,sizeof(int),1,fp);
-  fwrite(buf,sizeof(double),n,fp);
+  char **newarg = new char*[4];
+  newarg[0] = name;
+  newarg[1] = group->names[igroup];
+  newarg[2] = keyword;
+  if (extra) newarg[3] = extra;
+  if (extra) modify->add_compute(4,newarg);
+  else modify->add_compute(3,newarg);
+  delete [] name;
+  delete [] newarg;
 }
 
 /* ---------------------------------------------------------------------- */
 
-void DumpCustom::write_text(int n, double *buf)
+int DumpCustom::modify_param(int narg, char **arg)
 {
-  int i,j;
-
-  int m = 0;
-  for (i = 0; i < n; i++) {
-    for (j = 0; j < size_one; j++) {
-      if (vtype[j] == INT) fprintf(fp,vformat[j],static_cast<int> (buf[m]));
-      else fprintf(fp,vformat[j],buf[m]);
-      m++;
+  if (strcmp(arg[0],"region") == 0) {
+    if (narg < 2) error->all("Illegal dump_modify command");
+    if (strcmp(arg[1],"none") == 0) iregion = -1;
+    else {
+      for (iregion = 0; iregion < domain->nregion; iregion++)
+	if (strcmp(arg[1],domain->regions[iregion]->id) == 0) break;
+      if (iregion == domain->nregion)
+	error->all("Dump_modify region ID does not exist");
     }
-    fprintf(fp,"\n");
-  }
-}
-
-/* ----------------------------------------------------------------------
-   create a fix of style keyword for computing a per-atom custom quantity
-   fix-ID = dump-ID + keyword
-------------------------------------------------------------------------- */
-
-void DumpCustom::fix_create(char *keyword)
-{
-  char **fixarg = new char*[3];
-
-  int n = strlen(id) + strlen(keyword) + 1;
-  fixarg[0] = new char[n];
-  strcpy(fixarg[0],id);
-  strcat(fixarg[0],keyword);
+    return 2;
+    
+  } else if (strcmp(arg[0],"thresh") == 0) {
+    if (narg < 2) error->all("Illegal dump_modify command");
+    if (strcmp(arg[1],"none") == 0) {
+      if (nthresh) {
+	memory->sfree(thresh_array);
+	memory->sfree(thresh_op);
+	memory->sfree(thresh_value);
+	thresh_array = NULL;
+	thresh_op = NULL;
+	thresh_value = NULL;
+      }
+      nthresh = 0;
+      return 2;
+    }
+    
+    if (narg < 4) error->all("Illegal dump_modify command");
+    
+    // grow threshhold arrays
+    
+    thresh_array = (int *)
+      memory->srealloc(thresh_array,(nthresh+1)*sizeof(int),
+		       "dump:thresh_array");
+    thresh_op = (int *)
+      memory->srealloc(thresh_op,(nthresh+1)*sizeof(int),
+		       "dump:thresh_op");
+    thresh_value = (double *)
+      memory->srealloc(thresh_value,(nthresh+1)*sizeof(double),
+		       "dump:thresh_value");
 
-  n = strlen(group->names[igroup]) + 1;
-  fixarg[1] = new char[n];
-  strcpy(fixarg[1],group->names[igroup]);
+    // set keyword type of threshhold
+    // customize by adding to if statement
+    
+    if (strcmp(arg[1],"tag") == 0) thresh_array[nthresh] = TAG;
+    else if (strcmp(arg[1],"mol") == 0) thresh_array[nthresh] = MOL;
+    else if (strcmp(arg[1],"type") == 0) thresh_array[nthresh] = TYPE;
+    else if (strcmp(arg[1],"x") == 0) thresh_array[nthresh] = X;
+    else if (strcmp(arg[1],"y") == 0) thresh_array[nthresh] = Y;
+    else if (strcmp(arg[1],"z") == 0) thresh_array[nthresh] = Z;
+    else if (strcmp(arg[1],"xs") == 0) thresh_array[nthresh] = XS;
+    else if (strcmp(arg[1],"ys") == 0) thresh_array[nthresh] = YS;
+    else if (strcmp(arg[1],"zs") == 0) thresh_array[nthresh] = ZS;
+    else if (strcmp(arg[1],"xu") == 0) thresh_array[nthresh] = XU;
+    else if (strcmp(arg[1],"yu") == 0) thresh_array[nthresh] = YU;
+    else if (strcmp(arg[1],"zu") == 0) thresh_array[nthresh] = ZU;
+    else if (strcmp(arg[1],"ix") == 0) thresh_array[nthresh] = IX;
+    else if (strcmp(arg[1],"iy") == 0) thresh_array[nthresh] = IY;
+    else if (strcmp(arg[1],"iz") == 0) thresh_array[nthresh] = IZ;
+    else if (strcmp(arg[1],"vx") == 0) thresh_array[nthresh] = VX;
+    else if (strcmp(arg[1],"vy") == 0) thresh_array[nthresh] = VY;
+    else if (strcmp(arg[1],"vz") == 0) thresh_array[nthresh] = VZ;
+    else if (strcmp(arg[1],"fx") == 0) thresh_array[nthresh] = FX;
+    else if (strcmp(arg[1],"fy") == 0) thresh_array[nthresh] = FY;
+    else if (strcmp(arg[1],"fz") == 0) thresh_array[nthresh] = FZ;
+    else if (strcmp(arg[1],"q") == 0) thresh_array[nthresh] = Q;
+    else if (strcmp(arg[1],"mux") == 0) thresh_array[nthresh] = MUX;
+    else if (strcmp(arg[1],"muy") == 0) thresh_array[nthresh] = MUY;
+    else if (strcmp(arg[1],"muz") == 0) thresh_array[nthresh] = MUZ;
+    else if (strcmp(arg[1],"tqx") == 0) thresh_array[nthresh] = TQX;
+    else if (strcmp(arg[1],"tqy") == 0) thresh_array[nthresh] = TQY;
+    else if (strcmp(arg[1],"tqz") == 0) thresh_array[nthresh] = TQZ;
+    else if (strcmp(arg[1],"epair") == 0) {
+      thresh_array[nthresh] = EPAIR;
+      if (index_epair < 0) {
+	index_epair = add_compute(style_epair,1);
+	create_compute(style_epair,NULL);
+      }
+    } else if (strcmp(arg[1],"ke") == 0) {
+      thresh_array[nthresh] = KE;
+      if (index_ke < 0) {
+	index_ke = add_compute(style_ke,1);
+	create_compute(style_ke,NULL);
+      }
+    } else if (strcmp(arg[1],"etotal") == 0) {
+      thresh_array[nthresh] = ETOTAL;
+      if (index_etotal < 0) {
+	if (index_epair < 0) {
+	  index_epair = add_compute(style_epair,1);
+	  create_compute(style_epair,NULL);
+	}
+	index_etotal = add_compute(style_etotal,1);
+	create_compute(style_etotal,style_epair);
+      }
+    } else if (strcmp(arg[1],"centro") == 0) {
+      thresh_array[nthresh] = CENTRO;
+      if (index_centro < 0) {
+	index_centro = add_compute(style_centro,1);
+	create_compute(style_stress,NULL);
+      }
+    } else if (strcmp(arg[1],"sxx") == 0) {
+      thresh_array[nthresh] = SXX;
+      if (index_stress < 0) {
+	index_stress = add_compute(style_stress,1);
+	create_compute(style_stress,NULL);
+      }
+    } else if (strcmp(arg[1],"syy") == 0) {
+      thresh_array[nthresh] = SYY;
+      if (index_stress < 0) {
+	index_stress = add_compute(style_stress,1);
+	create_compute(style_stress,NULL);
+      }
+    } else if (strcmp(arg[1],"szz") == 0) {
+      thresh_array[nthresh] = SZZ;
+      if (index_stress < 0) {
+	index_stress = add_compute(style_stress,1);
+	create_compute(style_stress,NULL);
+      }
+    } else if (strcmp(arg[1],"sxy") == 0) {
+      thresh_array[nthresh] = SXY;
+      if (index_stress < 0) {
+	index_stress = add_compute(style_stress,1);
+	create_compute(style_stress,NULL);
+      }
+    } else if (strcmp(arg[1],"sxz") == 0) {
+      thresh_array[nthresh] = SXZ;
+      if (index_stress < 0) {
+	index_stress = add_compute(style_stress,1);
+	create_compute(style_stress,NULL);
+      }
+    } else if (strcmp(arg[1],"syz") == 0) {
+      thresh_array[nthresh] = SYZ;
+      if (index_stress < 0) {
+	index_stress = add_compute(style_stress,1);
+	create_compute(style_stress,NULL);
+      }
+    
+    // compute value = c_ID
+    // if no trailing [], then arg is set to 0, else arg is between []
+    // must grow field2compute and arg_compute arrays,
+    //   since access is beyond nfield
+    // if Compute has pre-compute, first add it to list
+
+    } else if (strncmp(arg[1],"c_",2) == 0) {
+      thresh_array[nthresh] = COMPUTE;
+      field2compute = (int *) memory->srealloc(field2compute,
+					       (nfield+nthresh+1)*sizeof(int),
+					       "dump:field2compute");
+      arg_compute = (int *) memory->srealloc(arg_compute,
+					     (nfield+nthresh+1)*sizeof(int),
+					     "dump:arg_compute");
+      int n = strlen(arg[1]);
+      char *suffix = new char[n];
+      strcpy(suffix,&arg[1][2]);
+    
+      char *ptr = strchr(suffix,'[');
+      if (ptr) {
+	if (suffix[strlen(suffix)-1] != ']')
+	  error->all("Invalid keyword in dump custom command");
+	arg_compute[nfield+nthresh] = atoi(ptr+1);
+	*ptr = '\0';
+      } else arg_compute[nfield+nthresh] = 0;
+      
+      n = modify->find_compute(suffix);
+      if (n < 0) error->all("Could not find dump custom compute ID");
+
+      if (modify->compute[n]->peratom_flag == 0)
+	error->all("Dump custom compute ID does not compute peratom info");
+      if (arg_compute[nfield+nthresh] == 0 && 
+	  modify->compute[n]->size_peratom > 0)
+	error->all("Dump custom compute ID does not compute scalar per atom");
+      if (arg_compute[nfield+nthresh] > 0 && 
+	  modify->compute[n]->size_peratom == 0)
+	error->all("Dump custom compute ID does not compute vector per atom");
+      if (arg_compute[nfield+nthresh] > 0 && 
+	  arg_compute[nfield+nthresh] > modify->compute[n]->size_peratom)
+	error->all("Dump custom compute ID vector is not large enough");
+      if (modify->compute[n]->id_pre)
+	int tmp = add_compute(modify->compute[n]->id_pre,0);
+      field2compute[nfield+nthresh] = add_compute(suffix,0);
+      delete [] suffix;
+
+    } else error->all("Invalid dump_modify threshhold operator");
+
+    // set operation type of threshhold
 
-  n = strlen(keyword) + 1;
-  fixarg[2] = new char[n];
-  strcpy(fixarg[2],keyword);
+    if (strcmp(arg[2],">=") == 0) thresh_op[nthresh] = LT;
+    else if (strcmp(arg[2],">") == 0) thresh_op[nthresh] = LE;
+    else if (strcmp(arg[2],"<=") == 0) thresh_op[nthresh] = GT;
+    else if (strcmp(arg[2],"<") == 0) thresh_op[nthresh] = GE;
+    else if (strcmp(arg[2],"=") == 0) thresh_op[nthresh] = NEQ;
+    else if (strcmp(arg[2],"<>") == 0) thresh_op[nthresh] = EQ;
+    else error->all("Invalid dump_modify threshhold operator");
 
-  modify->add_fix(3,fixarg);
-  for (int i = 0; i < 3; i++) delete [] fixarg[i];
-  delete [] fixarg;
-}
+    // set threshhold value
 
-/* ----------------------------------------------------------------------
-   delete a fix of style keyword for computing a per-atom custom quantity 
-------------------------------------------------------------------------- */
+    thresh_value[nthresh] = atof(arg[3]);
 
-void DumpCustom::fix_delete(char *keyword)
-{
-  int n = strlen(id) + strlen(keyword) + 1;
-  char *name = new char[n];
-  strcpy(name,id);
-  strcat(name,keyword);
-  modify->delete_fix(name);
-  delete [] name;
+    nthresh++;
+    return 4;
+  }
+  return 0;
 }
 
 /* ----------------------------------------------------------------------
-   find which fix matches keyword
-   fix was created by dump custom, so must exist
+   return # of bytes of allocated memory in buf and choose and local arrays
 ------------------------------------------------------------------------- */
 
-int DumpCustom::fix_match(char *keyword)
+int DumpCustom::memory_usage()
 {
-  int n = strlen(id) + strlen(keyword) + 1;
-  char *name = new char[n];
-  strcpy(name,id);
-  strcat(name,keyword);
-
-  int i;
-  for (i = 0; i < modify->nfix; i++)
-    if (strcmp(name,modify->fix[i]->id) == 0) break;
-
-  delete [] name;
-  return i;
+  int bytes = maxbuf * sizeof(double);
+  bytes += maxlocal * sizeof(int);
+  bytes += maxlocal * sizeof(double);
+  return bytes;
 }
 
 // ----------------------------------------------------------------------
-// one method for every kind of quantity dump custom can output
+// one method for every keyword dump custom can output
 // the atom quantity is packed into buf starting at n with stride size_one
 // customize by adding a method
 // ----------------------------------------------------------------------
 
 /* ---------------------------------------------------------------------- */
 
+void DumpCustom::pack_compute(int n)
+{
+  double *vector = compute[field2compute[n]]->scalar_atom;
+  double **array = compute[field2compute[n]]->vector_atom;
+  int index = arg_compute[n];
+  int nlocal = atom->nlocal;
+
+  if (index == 0) {
+    for (int i = 0; i < nlocal; i++)
+      if (choose[i]) {
+	buf[n] = vector[i];
+	n += size_one;
+      }
+  } else {
+    index--;
+    for (int i = 0; i < nlocal; i++)
+      if (choose[i]) {
+	buf[n] = array[i][index];
+	n += size_one;
+      }
+  }
+}
+
+/* ---------------------------------------------------------------------- */
+
 void DumpCustom::pack_tag(int n)
 {
   int *tag = atom->tag;
@@ -1297,14 +1454,14 @@ void DumpCustom::pack_tqz(int n)
 
 /* ---------------------------------------------------------------------- */
 
-void DumpCustom::pack_etotal(int n)
+void DumpCustom::pack_epair(int n)
 {
-  double *epair = ((FixEnergy *) modify->fix[ifix_epair])->energy;
+  double *epair = compute[index_epair]->scalar_atom;
   int nlocal = atom->nlocal;
 
   for (int i = 0; i < nlocal; i++)
     if (choose[i]) {
-      buf[n] = ke[i] + epair[i];
+      buf[n] = epair[i];
       n += size_one;
     }
 }
@@ -1313,6 +1470,7 @@ void DumpCustom::pack_etotal(int n)
 
 void DumpCustom::pack_ke(int n)
 {
+  double *ke = compute[index_ke]->scalar_atom;
   int nlocal = atom->nlocal;
 
   for (int i = 0; i < nlocal; i++)
@@ -1324,14 +1482,14 @@ void DumpCustom::pack_ke(int n)
 
 /* ---------------------------------------------------------------------- */
 
-void DumpCustom::pack_epair(int n)
+void DumpCustom::pack_etotal(int n)
 {
-  double *epair = ((FixEnergy *) modify->fix[ifix_epair])->energy;
+  double *etotal = compute[index_etotal]->scalar_atom;
   int nlocal = atom->nlocal;
 
   for (int i = 0; i < nlocal; i++)
     if (choose[i]) {
-      buf[n] = epair[i];
+      buf[n] = etotal[i];
       n += size_one;
     }
 }
@@ -1340,7 +1498,7 @@ void DumpCustom::pack_epair(int n)
 
 void DumpCustom::pack_centro(int n)
 {
-  double *centro = ((FixCentro *) modify->fix[ifix_centro])->centro;
+  double *centro = compute[index_centro]->scalar_atom;
   int nlocal = atom->nlocal;
 
   for (int i = 0; i < nlocal; i++)
@@ -1354,7 +1512,7 @@ void DumpCustom::pack_centro(int n)
 
 void DumpCustom::pack_sxx(int n)
 {
-  double **stress = ((FixStress *) modify->fix[ifix_stress])->stress;
+  double **stress = compute[index_stress]->vector_atom;
   int nlocal = atom->nlocal;
 
   for (int i = 0; i < nlocal; i++)
@@ -1368,7 +1526,7 @@ void DumpCustom::pack_sxx(int n)
 
 void DumpCustom::pack_syy(int n)
 {
-  double **stress = ((FixStress *) modify->fix[ifix_stress])->stress;
+  double **stress = compute[index_stress]->vector_atom;
   int nlocal = atom->nlocal;
 
   for (int i = 0; i < nlocal; i++)
@@ -1382,7 +1540,7 @@ void DumpCustom::pack_syy(int n)
 
 void DumpCustom::pack_szz(int n)
 {
-  double **stress = ((FixStress *) modify->fix[ifix_stress])->stress;
+  double **stress = compute[index_stress]->vector_atom;
   int nlocal = atom->nlocal;
 
   for (int i = 0; i < nlocal; i++)
@@ -1396,7 +1554,7 @@ void DumpCustom::pack_szz(int n)
 
 void DumpCustom::pack_sxy(int n)
 {
-  double **stress = ((FixStress *) modify->fix[ifix_stress])->stress;
+  double **stress = compute[index_stress]->vector_atom;
   int nlocal = atom->nlocal;
 
   for (int i = 0; i < nlocal; i++)
@@ -1410,7 +1568,7 @@ void DumpCustom::pack_sxy(int n)
 
 void DumpCustom::pack_sxz(int n)
 {
-  double **stress = ((FixStress *) modify->fix[ifix_stress])->stress;
+  double **stress = compute[index_stress]->vector_atom;
   int nlocal = atom->nlocal;
 
   for (int i = 0; i < nlocal; i++)
@@ -1424,7 +1582,7 @@ void DumpCustom::pack_sxz(int n)
 
 void DumpCustom::pack_syz(int n)
 {
-  double **stress = ((FixStress *) modify->fix[ifix_stress])->stress;
+  double **stress = compute[index_stress]->vector_atom;
   int nlocal = atom->nlocal;
 
   for (int i = 0; i < nlocal; i++)
@@ -1433,39 +1591,3 @@ void DumpCustom::pack_syz(int n)
       n += size_one;
     }
 }
-
-// ----------------------------------------------------------------------
-// one method for each locally-computed dump quantity
-// ----------------------------------------------------------------------
-
-/* ---------------------------------------------------------------------- */
-
-void DumpCustom::compute_etotal()
-{
-  double *epair = ((FixEnergy *) modify->fix[ifix_epair])->energy;
-  int nlocal = atom->nlocal;
-
-  for (int i = 0; i < nlocal; i++)
-    etotal[i] = ke[i] + epair[i];
-}
-
-/* ---------------------------------------------------------------------- */
-
-void DumpCustom::compute_ke()
-{
-  double mvv2e = force->mvv2e;
-  double **v = atom->v;
-  double *mass = atom->mass;
-  double *rmass = atom->rmass;
-  int *type = atom->type;
-  int nlocal = atom->nlocal;
-
-  if (atom->mass_require)
-    for (int i = 0; i < nlocal; i++)
-      ke[i] = 0.5 * mvv2e * mass[type[i]] *
-	(v[i][0]*v[i][0] + v[i][1]*v[i][1] + v[i][2]*v[i][2]);
-  else
-    for (int i = 0; i < nlocal; i++)
-      ke[i] = 0.5 * mvv2e * rmass[i] *
-	(v[i][0]*v[i][0] + v[i][1]*v[i][1] + v[i][2]*v[i][2]);
-}
diff --git a/src/dump_custom.h b/src/dump_custom.h
index fe836d5c698c33c905c8c6e0a16c361213b0c15a..1340c12af8e4b9a35a5bccfbd4d66a8cb7f75886 100644
--- a/src/dump_custom.h
+++ b/src/dump_custom.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,9 +16,11 @@
 
 #include "dump.h"
 
+namespace LAMMPS_NS {
+
 class DumpCustom : public Dump {
  public:
-  DumpCustom(int, char **);
+  DumpCustom(class LAMMPS *, int, char **);
   ~DumpCustom();
   void init();
   int memory_usage();
@@ -38,36 +40,30 @@ class DumpCustom : public Dump {
   int *choose;               // 1 if output this atom, 0 if no
   double *dchoose;           // value for each atom to threshhold against
 
-  int nevery;
-
-  int fixflag;               // 1 if this dump invokes any fixes, 0 if not
-  int fixflag_epair;         // 1 if this fix is invoked, 0 if not
-  int fixflag_centro;
-  int fixflag_stress;
-  int ifix_epair;            // which fix it is (0 to nfixes-1)
-  int ifix_centro;
-  int ifix_stress;
-
-  int computeflag;           // 1 if this dump invokes any local comp, 0 if not
-  int computeflag_etotal;    // 1 if this local comp is invoked, 0 if not
-  int computeflag_ke;
+  int nfield;                // # of keywords listed by user
+  int ncompute;              // # of Compute objects called by dump
+  char **id_compute;         // their IDs
+  class Compute **compute;   // list of ptrs to the Compute objects
+  int *field2compute;        // which Compute computes this field
+  int *arg_compute;          // index into Compute scalar_atom,vector_atom
+                             // 0 for scalar_atom, 1-N for vector_atom values
 
-  // local computation arrays
-
-  double *etotal;
-  double *ke;
+                             // index = where keyword's Compute is in list
+                             // style = style of Compute object
+  int index_epair,index_ke,index_etotal,index_centro,index_stress;
+  char *style_epair,*style_ke,*style_etotal,*style_centro,*style_stress;
 
   // private methods
 
-  int modify_param(int, char **);
   void write_header(int);
   int count();
   int pack();
   void write_data(int, double *);
 
-  void fix_create(char *);
-  void fix_delete(char *);
-  int fix_match(char *);
+  void parse_fields(int, char **);
+  int add_compute(char *, int);
+  void create_compute(char *, char *);
+  int modify_param(int, char **);
 
   typedef void (DumpCustom::*FnPtrHeader)(int);
   FnPtrHeader header_choice;           // ptr to write header functions
@@ -83,6 +79,9 @@ class DumpCustom : public Dump {
 
   typedef void (DumpCustom::*FnPtrPack)(int);
   FnPtrPack *pack_choice;              // ptrs to pack functions
+
+  void pack_compute(int);
+
   void pack_tag(int);
   void pack_molecule(int);
   void pack_type(int);
@@ -121,11 +120,8 @@ class DumpCustom : public Dump {
   void pack_sxy(int);
   void pack_sxz(int);
   void pack_syz(int);
-
-  // local computation methods
-
-  void compute_etotal();
-  void compute_ke();
 };
 
+}
+
 #endif
diff --git a/src/dump_dcd.cpp b/src/dump_dcd.cpp
index 2a520b44d16a86ce449e8deef8ba136dad39f998..ef9b73ff40b51b90308babfe77ba60f1e41abbca 100644
--- a/src/dump_dcd.cpp
+++ b/src/dump_dcd.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -28,6 +28,8 @@
 #include "memory.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define NFILE_POS 8L
 #define NSTEP_POS 20L
 
@@ -41,7 +43,8 @@
 
 /* ---------------------------------------------------------------------- */
 
-DumpDCD::DumpDCD(int narg, char **arg) : Dump(narg, arg)
+DumpDCD::DumpDCD(LAMMPS *lmp, int narg, char **arg) :
+  Dump(lmp, narg, arg)
 {
   if (narg != 5) error->all("Illegal dump dcd command");
   if (igroup != group->find("all")) error->all("Dump dcd must use group all");
diff --git a/src/dump_dcd.h b/src/dump_dcd.h
index fa205ef5647d04a08ca81704ed8464dc0f3536e4..f190eb1432b70f7136ea8ddbbb681217803e9b74 100644
--- a/src/dump_dcd.h
+++ b/src/dump_dcd.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -18,9 +18,11 @@
 #include "dump.h"
 #include "inttypes.h"
 
+namespace LAMMPS_NS {
+
 class DumpDCD : public Dump {
  public:
-  DumpDCD(int, char**);
+  DumpDCD(LAMMPS *, int, char**);
   ~DumpDCD();
   void init();
   int memory_usage();
@@ -40,4 +42,6 @@ class DumpDCD : public Dump {
   void fwrite_int32(FILE *, uint32_t);
 };
 
+}
+
 #endif
diff --git a/src/dump_xyz.cpp b/src/dump_xyz.cpp
index 3df2cd984cec32ed422496f55aec14abd2bac687..5a5ba59974b3df3222ed373d2e5fdf21af7bcc66 100644
--- a/src/dump_xyz.cpp
+++ b/src/dump_xyz.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -18,9 +18,11 @@
 #include "error.h"
 #include "memory.h"
 
+using namespace LAMMPS_NS;
+
 /* ---------------------------------------------------------------------- */
 
-DumpXYZ::DumpXYZ(int narg, char **arg) : Dump(narg, arg)
+DumpXYZ::DumpXYZ(LAMMPS *lmp, int narg, char **arg) : Dump(lmp, narg, arg)
 {
   if (narg != 5) error->all("Illegal dump xyz command");
   if (binary || multiproc) error->all("Invalid dump xyz filename");
diff --git a/src/dump_xyz.h b/src/dump_xyz.h
index dd0d90ec2904db37d140751359cf283e37bb1553..56ddf119873572641dd24333366b16fa34b134c6 100644
--- a/src/dump_xyz.h
+++ b/src/dump_xyz.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,9 +16,11 @@
 
 #include "dump.h"
 
+namespace LAMMPS_NS {
+
 class DumpXYZ : public Dump {
  public:
-  DumpXYZ(int, char**);
+  DumpXYZ(class LAMMPS *, int, char**);
   ~DumpXYZ();
   void init();
   int memory_usage();
@@ -35,4 +37,6 @@ class DumpXYZ : public Dump {
   void write_frame();
 };
 
+}
+
 #endif
diff --git a/src/error.cpp b/src/error.cpp
index 5221ef16fe4c6890cf53746836e9dce5d1072c1d..8307760aefc3b3bc0870c7cbb8d83297fe4ed9e2 100644
--- a/src/error.cpp
+++ b/src/error.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -18,6 +18,12 @@
 #include "memory.h"
 #include "output.h"
 
+using namespace LAMMPS_NS;
+
+/* ---------------------------------------------------------------------- */
+
+Error::Error(LAMMPS *lmp) : Pointers(lmp) {}
+
 /* ----------------------------------------------------------------------
    called by all procs in universe
    close all output, screen, and log files in world and universe
diff --git a/src/error.h b/src/error.h
index 40c28f7dd545f6d3e0c68d60432eba4e1b640856..248ecdd6049de04196c8978316496de88f5ad7cc 100644
--- a/src/error.h
+++ b/src/error.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -14,13 +14,13 @@
 #ifndef ERROR_H
 #define ERROR_H
 
-#include "stdio.h"
-#include "lammps.h"
+#include "pointers.h"
 
-class Error : public LAMMPS {
+namespace LAMMPS_NS {
+
+class Error : protected Pointers {
  public:
-  Error() {}
-  ~Error() {}
+  Error(class LAMMPS *);
 
   void universe_all(char *);
   void universe_one(char *);
@@ -30,4 +30,6 @@ class Error : public LAMMPS {
   void warning(char *);
 };
 
+}
+
 #endif
diff --git a/src/finish.cpp b/src/finish.cpp
index 65e6212dc28752734cbdeb1d1645f4a51b8b987e..8af0f57743fcd2b503476f8dad268d74a175c415 100644
--- a/src/finish.cpp
+++ b/src/finish.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -26,6 +26,12 @@
 #include "output.h"
 #include "memory.h"
 
+using namespace LAMMPS_NS;
+
+/* ---------------------------------------------------------------------- */
+
+Finish::Finish(LAMMPS *lmp) : Pointers(lmp) {}
+
 /* ---------------------------------------------------------------------- */
 
 void Finish::end(int flag)
diff --git a/src/finish.h b/src/finish.h
index f22b427616f0e1777b8b4e0cb88b869e1c40d80f..b0e815f4124ff1d5d51e1d7f3bab4ca89b442083 100644
--- a/src/finish.h
+++ b/src/finish.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -14,16 +14,19 @@
 #ifndef FINISH_H
 #define FINISH_H
 
-#include "lammps.h"
+#include "pointers.h"
 
-class Finish : public LAMMPS {
+namespace LAMMPS_NS {
+
+class Finish : protected Pointers {
  public:
-  Finish() {}
-  ~Finish() {}
+  Finish(class LAMMPS *);
   void end(int);
 
  private:
   void stats(int, double *, double *, double *, double *, int, int *);
 };
 
+}
+
 #endif
diff --git a/src/fix.cpp b/src/fix.cpp
index ebc926900c091caef447971ac3319bfb5a1d3171..2fb690f1ceb0e2fd557a61c69a7cc14a472c976f 100644
--- a/src/fix.cpp
+++ b/src/fix.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,9 +16,11 @@
 #include "group.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 /* ---------------------------------------------------------------------- */
 
-Fix::Fix(int narg, char **arg)
+Fix::Fix(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp)
 {
   int n = strlen(arg[0]) + 1;
   id = new char[n];
@@ -34,14 +36,13 @@ Fix::Fix(int narg, char **arg)
   restart_global = 0;
   restart_peratom = 0;
   force_reneighbor = 0;
-  thermo_print = 0;
   thermo_energy = 0;
-  nevery = 1;
 
+  comm_forward = comm_reverse = 0;
   neigh_half_once = neigh_half_every = 0;
   neigh_full_once = neigh_full_every = 0;
 
-  // mask settings - same as define settings in modify.cpp
+  // mask settings - same as in modify.cpp
 
   INITIAL_INTEGRATE = 1;
   PRE_EXCHANGE = 2;
@@ -49,7 +50,7 @@ Fix::Fix(int narg, char **arg)
   POST_FORCE = 8;
   FINAL_INTEGRATE = 16;
   END_OF_STEP = 32;
-  THERMO = 64;
+  THERMO_ENERGY = 64;
   INITIAL_INTEGRATE_RESPA = 128;
   POST_FORCE_RESPA = 256;
   FINAL_INTEGRATE_RESPA = 512;
@@ -75,13 +76,7 @@ void Fix::modify_params(int narg, char **arg)
 
   int iarg = 0;
   while (iarg < narg) {
-    if (strcmp(arg[iarg],"thermo") == 0) {
-      if (iarg+2 > narg) error->all("Illegal fix_modify command");
-      if (strcmp(arg[iarg+1],"no") == 0) thermo_print = 0;
-      else if (strcmp(arg[iarg+1],"yes") == 0) thermo_print = 1;
-      else error->all("Illegal fix_modify command");
-      iarg += 2;
-    } else if (strcmp(arg[iarg],"energy") == 0) {
+    if (strcmp(arg[iarg],"energy") == 0) {
       if (iarg+2 > narg) error->all("Illegal fix_modify command");
       if (strcmp(arg[iarg+1],"no") == 0) thermo_energy = 0;
       else if (strcmp(arg[iarg+1],"yes") == 0) thermo_energy = 1;
diff --git a/src/fix.h b/src/fix.h
index 6311a8ef6e1b4b9a3c65cde0a4a892e9716720ea..564eefcc9d553a7b9e5698ee32edd6de6afe6c05 100644
--- a/src/fix.h
+++ b/src/fix.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -14,31 +14,37 @@
 #ifndef FIX_H
 #define FIX_H
 
-#include "lammps.h"
+#include "pointers.h"
 
-class Fix : public LAMMPS {
+namespace LAMMPS_NS {
+
+class Fix : protected Pointers {
  public:
   char *id,*style;
   int igroup,groupbit;
+
   int restart_global;            // 1 if Fix saves global state, 0 if not
   int restart_peratom;           // 1 if Fix saves peratom state, 0 if not
   int force_reneighbor;          // 1 if Fix forces reneighboring, 0 if not
   int next_reneighbor;           // next timestep to force a reneighboring
-  int thermo_print;              // 1 if Fix prints info during thermo, 0 no
-  int thermo_energy;             // 1 if Fix adds to thermo energy, 0 if not
+  int thermo_energy;             // 1 if ThEng enabled via fix_modify, 0 if not
   int nevery;                    // how often to call an end_of_step fix
+
+  int comm_forward;              // size of forward communication (0 if none)
+  int comm_reverse;              // size of reverse communication (0 if none)
   int neigh_half_once;           // 0/1 if needs half neigh list occasionally
   int neigh_half_every;          // 0/1 if needs half neigh list every step
   int neigh_full_once;           // 0/1 if needs full neigh list occasionally
   int neigh_full_every;          // 0/1 if needs full neigh list every step
+
   double virial[6];              // fix contribution to pressure virial
 
   int INITIAL_INTEGRATE,PRE_EXCHANGE,PRE_NEIGHBOR;    // mask settings
-  int POST_FORCE,FINAL_INTEGRATE,END_OF_STEP,THERMO;
+  int POST_FORCE,FINAL_INTEGRATE,END_OF_STEP,THERMO_ENERGY;
   int INITIAL_INTEGRATE_RESPA,POST_FORCE_RESPA,FINAL_INTEGRATE_RESPA;
   int MIN_POST_FORCE;
 
-  Fix(int, char **);
+  Fix(class LAMMPS *, int, char **);
   virtual ~Fix();
   void modify_params(int, char **);
 
@@ -56,7 +62,6 @@ class Fix : public LAMMPS {
   virtual void write_restart(FILE *) {}
   virtual void restart(char *) {}
 
-  virtual int memory_usage() {return 0;}
   virtual void grow_arrays(int) {}
   virtual void copy_arrays(int, int) {}
   virtual int pack_exchange(int, double *) {return 0;}
@@ -77,14 +82,16 @@ class Fix : public LAMMPS {
   virtual int pack_reverse_comm(int, int, double *) {return 0;}
   virtual void unpack_reverse_comm(int, int *, double *) {}
 
-  virtual int thermo_fields(int, int *, char **) {return 0;}
-  virtual int thermo_compute(double *) {return 0;}
-  virtual void dump() {}
+  virtual double thermo(int) {return 0.0;}
 
   virtual int dof(int) {return 0;}
   virtual void dilate(int, double, double, double, double) {}
 
   virtual int modify_param(int, char **) {return 0;}
+
+  virtual int memory_usage() {return 0;}
 };
 
+}
+
 #endif
diff --git a/src/fix_add_force.cpp b/src/fix_add_force.cpp
index fa40420a3f94c8c822cfe85dfe8d21515e60b47a..a865b9a63a233146a787ab12127dac21d73ae740 100644
--- a/src/fix_add_force.cpp
+++ b/src/fix_add_force.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -19,9 +19,12 @@
 #include "respa.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 /* ---------------------------------------------------------------------- */
 
-FixAddForce::FixAddForce(int narg, char **arg) : Fix(narg, arg)
+FixAddForce::FixAddForce(LAMMPS *lmp, int narg, char **arg) :
+  Fix(lmp, narg, arg)
 {
   if (narg != 6) error->all("Illegal fix addforce command");
   xvalue = atof(arg[3]);
diff --git a/src/fix_add_force.h b/src/fix_add_force.h
index 85075c5c74d00d030c649a5d5f51a0c5aabfadf9..44d68de3433060b2401e7d2c5ce30ab713058f98 100644
--- a/src/fix_add_force.h
+++ b/src/fix_add_force.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,10 +16,11 @@
 
 #include "fix.h"
 
+namespace LAMMPS_NS {
+
 class FixAddForce : public Fix {
  public:
-  FixAddForce(int, char **);
-  ~FixAddForce() {}
+  FixAddForce(class LAMMPS *, int, char **);
   int setmask();
   void init();
   void setup();
@@ -33,4 +34,6 @@ class FixAddForce : public Fix {
   int nlevels_respa;
 };
 
+}
+
 #endif
diff --git a/src/fix_ave_force.cpp b/src/fix_ave_force.cpp
index af44ee70ce79c6d15f6979d4b30233d19d21ca66..e05393918efa442b30a12a1e9c825fcc4f5b3d93 100644
--- a/src/fix_ave_force.cpp
+++ b/src/fix_ave_force.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -20,9 +20,12 @@
 #include "respa.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 /* ---------------------------------------------------------------------- */
 
-FixAveForce::FixAveForce(int narg, char **arg) : Fix(narg, arg)
+FixAveForce::FixAveForce(LAMMPS *lmp, int narg, char **arg) :
+  Fix(lmp, narg, arg)
 {
   if (narg != 6) error->all("Illegal fix aveforce command");
 
diff --git a/src/fix_ave_force.h b/src/fix_ave_force.h
index bcd44c4c49b43be006aa8f5120481d156f2abdd8..542b49befa1082f5277018422dc1d9e7013b6471 100644
--- a/src/fix_ave_force.h
+++ b/src/fix_ave_force.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,10 +16,11 @@
 
 #include "fix.h"
 
+namespace LAMMPS_NS {
+
 class FixAveForce : public Fix {
  public:
-  FixAveForce(int, char **);
-  ~FixAveForce() {}
+  FixAveForce(class LAMMPS *, int, char **);
   int setmask();
   void init();
   void setup();
@@ -35,4 +36,6 @@ class FixAveForce : public Fix {
   int nlevels_respa;
 };
 
+}
+
 #endif
diff --git a/src/fix_centro.cpp b/src/fix_centro.cpp
deleted file mode 100644
index 410b0f55a7b4cbd42c0cc003767087c193e85028..0000000000000000000000000000000000000000
--- a/src/fix_centro.cpp
+++ /dev/null
@@ -1,292 +0,0 @@
-/* ----------------------------------------------------------------------
-   LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
-
-   Copyright (2003) Sandia Corporation.  Under the terms of Contract
-   DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
-   certain rights in this software.  This software is distributed under 
-   the GNU General Public License.
-
-   See the README file in the top-level LAMMPS directory.
-------------------------------------------------------------------------- */
-
-#include "string.h"
-#include "fix_centro.h"
-#include "atom.h"
-#include "modify.h"
-#include "update.h"
-#include "neighbor.h"
-#include "force.h"
-#include "pair.h"
-#include "comm.h"
-#include "memory.h"
-#include "error.h"
-
-/* ---------------------------------------------------------------------- */
-
-FixCentro::FixCentro(int narg, char **arg) : Fix(narg, arg)
-{
-  if (narg != 3) error->all("Illegal fix centro command");
-
-  neigh_full_once = 1;
-  nmax = 0;
-  centro = NULL;
-  maxneigh = 0;
-  distsq = NULL;
-  nearest = NULL;
-}
-
-/* ---------------------------------------------------------------------- */
-
-FixCentro::~FixCentro()
-{
-  memory->sfree(centro);
-  memory->sfree(distsq);
-  memory->sfree(nearest);
-}
-
-/* ---------------------------------------------------------------------- */
-
-int FixCentro::setmask()
-{
-  int mask = 0;
-  return mask;
-}
-
-/* ---------------------------------------------------------------------- */
-
-void FixCentro::init()
-{
-  // warn if more than one centro fix
-  
-  int count = 0;
-  for (int i = 0; i < modify->nfix; i++)
-    if (strcmp(modify->fix[i]->style,"CENTRO") == 0) count++;
-  if (count > 1 && comm->me == 0)
-    error->warning("More than one dump custom with a centro attribute");
-}
-
-/* ---------------------------------------------------------------------- */
-
-void FixCentro::dump()
-{
-  int j,k,jj,kk,n,numneigh;
-  double xtmp,ytmp,ztmp,delx,dely,delz,rsq,value;
-  int *neighs;
-  double pairs[66];
-
-  // grow centro array if necessary
-
-  if (atom->nlocal > nmax) {
-    memory->sfree(centro);
-    nmax = atom->nmax;
-    centro = (double *) memory->smalloc(nmax*sizeof(double),"centro:centro");
-  }
-
-  // if needed, build a full neighbor list
-
-  if (!neighbor->full_every) neighbor->build_full();
-
-  // compute centro-symmetry parameter for each atom in group
-  // use full neighbor list
-
-  double **x = atom->x;
-  int *mask = atom->mask;
-  int nlocal = atom->nlocal;
-  int nall = atom->nlocal + atom->nghost;
-  double cutsq = force->pair->cutforce * force->pair->cutforce;
-
-  for (int i = 0; i < nlocal; i++)
-    if (mask[i] & groupbit) {
-      xtmp = x[i][0];
-      ytmp = x[i][1];
-      ztmp = x[i][2];
-      neighs = neighbor->firstneigh_full[i];
-      numneigh = neighbor->numneigh_full[i];
-
-      // insure distsq and nearest arrays are long enough
-
-      if (numneigh > maxneigh) {
-	memory->sfree(distsq);
-	memory->sfree(nearest);
-	maxneigh = numneigh;
-	distsq = (double *) memory->smalloc(maxneigh*sizeof(double),
-					    "centro:distsq");
-	nearest = (int *) memory->smalloc(maxneigh*sizeof(int),
-					  "centro:nearest");
-      }
-
-      // loop over list of all neighbors within force cutoff
-      // distsq[] = distance sq to each
-      // nearest[] = atom indices of neighbors
-
-      n = 0;
-      for (k = 0; k < numneigh; k++) {
-	j = neighs[k];
-	if (j >= nall) j %= nall;
-
-	delx = xtmp - x[j][0];
-	dely = ytmp - x[j][1];
-	delz = ztmp - x[j][2];
-	rsq = delx*delx + dely*dely + delz*delz;
-	if (rsq < cutsq) {
-	  distsq[n] = rsq;
-	  nearest[n++] = j;
-	}
-      }
-
-      // if not 12 neighbors, centro = 0.0
-
-      if (n < 12) {
-	centro[i] = 0.0;
-	continue;
-      }
-
-      // store 12 nearest neighs in 1st 12 locations of distsq and nearest
-
-      select2(12,n,distsq,nearest);
-
-      // R = Ri + Rj for each of 66 i,j pairs among 12 neighbors
-      // pairs = squared length of each R
-
-      n = 0;
-      for (j = 0; j < 12; j++) {
-	jj = nearest[j];
-	for (k = j+1; k < 12; k++) {
-	  kk = nearest[k];
-	  delx = x[jj][0] + x[kk][0] - 2.0*xtmp;
-	  dely = x[jj][1] + x[kk][1] - 2.0*ytmp;
-	  delz = x[jj][2] + x[kk][2] - 2.0*ztmp;
-	  pairs[n++] = delx*delx + dely*dely + delz*delz;
-	}
-      }
-
-      // store 6 smallest pair distances in 1st 6 locations of pairs
-
-      select(6,66,pairs);
-
-      // centrosymmetry = sum of 6 smallest squared values
-
-      value = 0.0;
-      for (j = 0; j < 6; j++) value += pairs[j];
-      centro[i] = value;
-    }
-}
-
-/* ----------------------------------------------------------------------
-   2 select routines from Numerical Recipes (slightly modified)
-   find k smallest values in array of length n
-   2nd routine sorts auxiliary array at same time
-------------------------------------------------------------------------- */
-
-#define SWAP(a,b)   tmp = a; a = b; b = tmp;
-#define ISWAP(a,b) itmp = a; a = b; b = itmp;
-
-void FixCentro::select(int k, int n, double *arr)
-{
-  int i,ir,j,l,mid;
-  double a,tmp;
-
-  arr--;
-  l = 1;
-  ir = n;
-  for (;;) {
-    if (ir <= l+1) {
-      if (ir == l+1 && arr[ir] < arr[l]) {
-	SWAP(arr[l],arr[ir])
-      }
-      return;
-    } else {
-      mid=(l+ir) >> 1;
-      SWAP(arr[mid],arr[l+1])
-      if (arr[l] > arr[ir]) {
-	SWAP(arr[l],arr[ir])
-      }
-      if (arr[l+1] > arr[ir]) {
-	SWAP(arr[l+1],arr[ir])
-      }
-      if (arr[l] > arr[l+1]) {
-	SWAP(arr[l],arr[l+1])
-      }
-      i = l+1;
-      j = ir;
-      a = arr[l+1];
-      for (;;) {
-	do i++; while (arr[i] < a);
-	do j--; while (arr[j] > a);
-	if (j < i) break;
-	SWAP(arr[i],arr[j])
-      }
-      arr[l+1] = arr[j];
-      arr[j] = a;
-      if (j >= k) ir = j-1;
-      if (j <= k) l = i;
-    }
-  }
-}
-
-/* ---------------------------------------------------------------------- */
-
-void FixCentro::select2(int k, int n, double *arr, int *iarr)
-{
-  int i,ir,j,l,mid,ia,itmp;
-  double a,tmp;
-
-  arr--;
-  iarr--;
-  l = 1;
-  ir = n;
-  for (;;) {
-    if (ir <= l+1) {
-      if (ir == l+1 && arr[ir] < arr[l]) {
-	SWAP(arr[l],arr[ir])
-	ISWAP(iarr[l],iarr[ir])
-      }
-      return;
-    } else {
-      mid=(l+ir) >> 1;
-      SWAP(arr[mid],arr[l+1])
-      ISWAP(iarr[mid],iarr[l+1])
-      if (arr[l] > arr[ir]) {
-	SWAP(arr[l],arr[ir])
-	ISWAP(iarr[l],iarr[ir])
-      }
-      if (arr[l+1] > arr[ir]) {
-	SWAP(arr[l+1],arr[ir])
-	ISWAP(iarr[l+1],iarr[ir])
-      }
-      if (arr[l] > arr[l+1]) {
-	SWAP(arr[l],arr[l+1])
-	ISWAP(iarr[l],iarr[l+1])
-      }
-      i = l+1;
-      j = ir;
-      a = arr[l+1];
-      ia = iarr[l+1];
-      for (;;) {
-	do i++; while (arr[i] < a);
-	do j--; while (arr[j] > a);
-	if (j < i) break;
-	SWAP(arr[i],arr[j])
-	ISWAP(iarr[i],iarr[j])
-      }
-      arr[l+1] = arr[j];
-      arr[j] = a;
-      iarr[l+1] = iarr[j];
-      iarr[j] = ia;
-      if (j >= k) ir = j-1;
-      if (j <= k) l = i;
-    }
-  }
-}
-
-/* ----------------------------------------------------------------------
-   memory usage of local atom-based array
-------------------------------------------------------------------------- */
-
-int FixCentro::memory_usage()
-{
-  int bytes = nmax * sizeof(double);
-  return bytes;
-}
diff --git a/src/fix_centro.h b/src/fix_centro.h
deleted file mode 100644
index b7031955e33e1bd9273b4cecb40bdad58ffa7c12..0000000000000000000000000000000000000000
--- a/src/fix_centro.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/* ----------------------------------------------------------------------
-   LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
-
-   Copyright (2003) Sandia Corporation.  Under the terms of Contract
-   DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
-   certain rights in this software.  This software is distributed under 
-   the GNU General Public License.
-
-   See the README file in the top-level LAMMPS directory.
-------------------------------------------------------------------------- */
-
-#ifndef FIX_CENTRO_H
-#define FIX_CENTRO_H
-
-#include "fix.h"
-
-class FixCentro : public Fix {
-  friend class DumpCustom;
-
- public:
-  FixCentro(int, char **);
-  ~FixCentro();
-  int setmask();
-  void init();
-  void dump();
-  int memory_usage();
-
- private:
-  int nmax,maxneigh;
-  double *centro;
-  double *distsq;
-  int *nearest;
-
-  void select(int, int, double *);
-  void select2(int, int, double *, int *);
-};
-
-#endif
diff --git a/src/fix_com.cpp b/src/fix_com.cpp
index 568e8a3eea232649d4876b9a35c947f810efec49..c52f78db5aaaa9f8364e568193dc3567fea8061c 100644
--- a/src/fix_com.cpp
+++ b/src/fix_com.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -19,9 +19,12 @@
 #include "group.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 /* ---------------------------------------------------------------------- */
 
-FixCOM::FixCOM(int narg, char **arg) : Fix(narg, arg)
+FixCOM::FixCOM(LAMMPS *lmp, int narg, char **arg) :
+  Fix(lmp, narg, arg)
 {
   if (narg != 5) error->all("Illegal fix com command");
   nevery = atoi(arg[3]);
diff --git a/src/fix_com.h b/src/fix_com.h
index ab5205b7d1bc6bd2b814e22cb509df049d0f561b..4623e0471a20456c8217409c09b565398e359ad1 100644
--- a/src/fix_com.h
+++ b/src/fix_com.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -17,9 +17,11 @@
 #include "stdio.h"
 #include "fix.h"
 
+namespace LAMMPS_NS {
+
 class FixCOM : public Fix {
  public:
-  FixCOM(int, char **);
+  FixCOM(class LAMMPS *, int, char **);
   ~FixCOM();
   int setmask();
   void init();
@@ -32,4 +34,6 @@ class FixCOM : public Fix {
   double masstotal;
 };
 
+}
+
 #endif
diff --git a/src/fix_deposit.cpp b/src/fix_deposit.cpp
index 2b96796d7fc9a8a08375c5a3f81872272e8041e9..f24ee98da1044bda8bb4ee08e5e1eb2254b093b2 100644
--- a/src/fix_deposit.cpp
+++ b/src/fix_deposit.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,6 +16,7 @@
 #include "string.h"
 #include "fix_deposit.h"
 #include "atom.h"
+#include "atom_vec.h"
 #include "force.h"
 #include "update.h"
 #include "comm.h"
@@ -26,9 +27,12 @@
 #include "memory.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 /* ---------------------------------------------------------------------- */
 
-FixDeposit::FixDeposit(int narg, char **arg) : Fix(narg, arg)
+FixDeposit::FixDeposit(LAMMPS *lmp, int narg, char **arg) :
+  Fix(lmp, narg, arg)
 {
   if (narg < 7) error->all("Illegal fix deposit command");
 
@@ -113,7 +117,7 @@ FixDeposit::FixDeposit(int narg, char **arg) : Fix(narg, arg)
 
   // random number generator, same for all procs
 
-  random = new RanPark(seed);
+  random = new RanPark(lmp,seed);
 
   // set up reneighboring
 
@@ -244,7 +248,7 @@ void FixDeposit::pre_exchange()
     double vztmp = vzlo + random->uniform() * (vzhi-vzlo);
 
     // check if new atom is in my sub-box or above it if I'm highest proc
-    // if so, add to my list via create_one()
+    // if so, add to my list via create_atom()
     // initialize info about the atoms
     // set group mask to "all" plus fix group
 
@@ -261,7 +265,7 @@ void FixDeposit::pre_exchange()
 	     xtmp >= domain->subxlo && xtmp < domain->subxhi) flag = 1;
 
     if (flag) {
-      atom->create_one(ntype,xtmp,ytmp,ztmp);
+      atom->avec->create_atom(ntype,xtmp,ytmp,ztmp,0);
       int m = atom->nlocal - 1;
       atom->type[m] = ntype;
       atom->mask[m] = 1 | groupbit;
diff --git a/src/fix_deposit.h b/src/fix_deposit.h
index a0fee52ff556f9de9aeaf2405b71e59e25c57f49..cb0b685474d0f069d258b36c8f4fc747f925a992 100644
--- a/src/fix_deposit.h
+++ b/src/fix_deposit.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,11 +16,11 @@
 
 #include "fix.h"
 
-class RanPark;
+namespace LAMMPS_NS {
 
 class FixDeposit : public Fix {
  public:
-  FixDeposit(int, char **);
+  FixDeposit(class LAMMPS *, int, char **);
   ~FixDeposit();
   int setmask();
   void pre_exchange();
@@ -32,9 +32,11 @@ class FixDeposit : public Fix {
   double vxlo,vxhi,vylo,vyhi,vzlo,vzhi;
   double xlo,xhi,ylo,yhi,zlo,zhi;
   int nfirst,ninserted;
-  RanPark *random;
+  class RanPark *random;
 
   void options(int, char **);
 };
 
+}
+
 #endif
diff --git a/src/fix_drag.cpp b/src/fix_drag.cpp
index 4063ce70ba6ba0e8cd81cb532f03276997163100..d3220bae8dfdec2878780fa308df00e3c8224348 100644
--- a/src/fix_drag.cpp
+++ b/src/fix_drag.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -21,9 +21,12 @@
 #include "domain.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 /* ---------------------------------------------------------------------- */
 
-FixDrag::FixDrag(int narg, char **arg) : Fix(narg, arg)
+FixDrag::FixDrag(LAMMPS *lmp, int narg, char **arg) :
+  Fix(lmp, narg, arg)
 {
   if (narg != 8) error->all("Illegal fix drag command");
 
diff --git a/src/fix_drag.h b/src/fix_drag.h
index 3a46b695db84173f3aef57dacb659e2b7f56308e..c2a0615cda50eb34936322f56803c4276700ab7c 100644
--- a/src/fix_drag.h
+++ b/src/fix_drag.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,10 +16,11 @@
 
 #include "fix.h"
 
+namespace LAMMPS_NS {
+
 class FixDrag : public Fix {
  public:
-  FixDrag(int, char **);
-  ~FixDrag() {}
+  FixDrag(class LAMMPS *, int, char **);
   int setmask();
   void init();
   void setup();
@@ -34,4 +35,6 @@ class FixDrag : public Fix {
   int nlevels_respa;
 };
 
+}
+
 #endif
diff --git a/src/fix_efield.cpp b/src/fix_efield.cpp
index 6fadf4054948d959bfaea79a9211968aed89cb6b..96d3029d9756d13ffd28340d88d9aaf8ee4efd09 100644
--- a/src/fix_efield.cpp
+++ b/src/fix_efield.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -25,9 +25,12 @@
 #include "error.h"
 #include "math.h"
 
+using namespace LAMMPS_NS;
+
 /* ---------------------------------------------------------------------- */
 
-FixEfield::FixEfield(int narg, char **arg) : Fix(narg, arg)
+FixEfield::FixEfield(LAMMPS *lmp, int narg, char **arg) :
+  Fix(lmp, narg, arg)
 {
   if (narg != 6) error->all("Illegal fix efield command");
 
@@ -53,7 +56,7 @@ void FixEfield::init()
 {
   // require an atom style with charge defined
 
-  if (atom->charge_allow == 0)
+  if (atom->q == NULL)
     error->all("Must use charged atom style with fix efield");
 
   if (strcmp(update->integrate_style,"respa") == 0)
diff --git a/src/fix_efield.h b/src/fix_efield.h
index 4add204245e84fa19a8257bada6e93253c3466b0..ce973abab618aecef80fa2a46cc4bfd9c7844361 100644
--- a/src/fix_efield.h
+++ b/src/fix_efield.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,10 +16,11 @@
 
 #include "fix.h"
 
+namespace LAMMPS_NS {
+
 class FixEfield : public Fix {
  public:
-  FixEfield(int, char **);
-  ~FixEfield() {}
+  FixEfield(class LAMMPS *, int, char **);
   int setmask();
   void init();
   void setup();
@@ -31,4 +32,6 @@ class FixEfield : public Fix {
   int nlevels_respa;
 };
 
+}
+
 #endif
diff --git a/src/fix_energy.cpp b/src/fix_energy.cpp
deleted file mode 100644
index 899c198ee5fb0278433cc9914106fa50f2f59c6b..0000000000000000000000000000000000000000
--- a/src/fix_energy.cpp
+++ /dev/null
@@ -1,210 +0,0 @@
-/* ----------------------------------------------------------------------
-   LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
-
-   Copyright (2003) Sandia Corporation.  Under the terms of Contract
-   DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
-   certain rights in this software.  This software is distributed under 
-   the GNU General Public License.
-
-   See the README file in the top-level LAMMPS directory.
-------------------------------------------------------------------------- */
-
-#include "string.h"
-#include "fix_energy.h"
-#include "atom.h"
-#include "neighbor.h"
-#include "modify.h"
-#include "comm.h"
-#include "update.h"
-#include "force.h"
-#include "pair.h"
-#include "memory.h"
-#include "error.h"
-
-#define MIN(a,b) ((a) < (b) ? (a) : (b))
-#define MAX(a,b) ((a) > (b) ? (a) : (b))
-
-/* ---------------------------------------------------------------------- */
-
-FixEnergy::FixEnergy(int narg, char **arg) : Fix(narg, arg)
-{
-  if (narg != 3) error->all("Illegal fix energy command");
-
-  neigh_half_once = 1;
-  nmax = 0;
-  energy = NULL;
-}
-
-/* ---------------------------------------------------------------------- */
-
-FixEnergy::~FixEnergy()
-{
-  memory->sfree(energy);
-}
-
-/* ---------------------------------------------------------------------- */
-
-int FixEnergy::setmask()
-{
-  int mask = 0;
-  return mask;
-}
-
-/* ---------------------------------------------------------------------- */
-
-void FixEnergy::init()
-{
-  if (force->pair == NULL || force->pair->single_enable == 0)
-    error->all("Pair style does not support dumping per-atom energy");
-
-  eamstyle = 0;
-  if (force->pair_match("eam")) eamstyle = 1;
-  else if (force->pair_match("eam/alloy")) eamstyle = 1;
-  else if (force->pair_match("eam/fs")) eamstyle = 1;
-
-  // set communication size in comm class
-
-  comm->maxreverse_fix = MAX(comm->maxreverse_fix,1);
-
-  // warn if more than one energy fix
-  
-  int count = 0;
-  for (int i = 0; i < modify->nfix; i++)
-    if (strcmp(modify->fix[i]->style,"ENERGY") == 0) count++;
-  if (count > 1 && comm->me == 0)
-    error->warning("More than one dump custom with an energy attribute");
-}
-
-/* ---------------------------------------------------------------------- */
-
-void FixEnergy::dump()
-{
-  int i,j,k,n,itype,jtype,numneigh;
-  double xtmp,ytmp,ztmp,delx,dely,delz,rsq;
-  double factor_coul,factor_lj,e;
-  int *neighs;
-
-  // grow energy array if necessary
-
-  if (atom->nmax > nmax) {
-    memory->sfree(energy);
-    nmax = atom->nmax;
-    energy = (double *) memory->smalloc(nmax*sizeof(double),"energy:energy");
-  }
-
-  // clear energy array
-  // n includes ghosts only if newton_pair flag is set
-
-  if (force->newton_pair) n = atom->nlocal + atom->nghost;
-  else n = atom->nlocal;
-
-  for (i = 0; i < n; i++) energy[i] = 0.0;
-
-  // if needed, build a half neighbor list
-
-  if (!neighbor->half_every) neighbor->build_half();
-
-  // compute pairwise energy for all atoms via pair->single()
-  // use half neighbor list
-
-  double *special_coul = force->special_coul;
-  double *special_lj = force->special_lj;
-  double **cutsq = force->pair->cutsq;
-
-  double **x = atom->x;
-  int *type = atom->type;
-  int nlocal = atom->nlocal;
-  int nall = atom->nlocal + atom->nghost;
-
-  Pair::One one;
-
-  for (i = 0; i < nlocal; i++) {
-    xtmp = x[i][0];
-    ytmp = x[i][1];
-    ztmp = x[i][2];
-    itype = type[i];
-    neighs = neighbor->firstneigh[i];
-    numneigh = neighbor->numneigh[i];
-    
-    for (k = 0; k < numneigh; k++) {
-      j = neighs[k];
-
-      if (j < nall) factor_coul = factor_lj = 1.0;
-      else {
-	factor_coul = special_coul[j/nall];
-	factor_lj = special_lj[j/nall];
-	j %= nall;
-      }
-
-      delx = xtmp - x[j][0];
-      dely = ytmp - x[j][1];
-      delz = ztmp - x[j][2];
-      rsq = delx*delx + dely*dely + delz*delz;
-      jtype = type[j];
-
-      if (rsq < cutsq[itype][jtype]) {
-	force->pair->single(i,j,itype,jtype,rsq,factor_coul,factor_lj,1,one);
-	e = one.eng_coul + one.eng_vdwl;
-	energy[i] += e;
-	energy[j] += e;
-      }
-    }
-  }
-
-  // communicate energy between neighbor procs
-
-  if (force->newton_pair) comm->reverse_comm_fix(this);
-
-  // remove double counting of per-atom energy
-
-  for (i = 0; i < nlocal; i++) energy[i] *= 0.5;
-
-  // for EAM, include embedding function contribution to energy
-
-  if (eamstyle) {
-    int *type = atom->type;
-    double fptmp,etmp;
-
-    for (i = 0; i < nlocal; i++) {
-      force->pair->single_embed(i,type[i],fptmp,1,etmp);
-      energy[i] += etmp;
-    }
-  }
-}
-
-/* ---------------------------------------------------------------------- */
-
-int FixEnergy::pack_reverse_comm(int n, int first, double *buf)
-{
-  int i,m,last;
-
-  m = 0;
-  last = first + n;
-  for (i = first; i < last; i++) buf[m++] = energy[i];
-  return 1;
-}
-
-/* ---------------------------------------------------------------------- */
-
-void FixEnergy::unpack_reverse_comm(int n, int *list, double *buf)
-{
-  int i,j,m;
-
-  m = 0;
-  for (i = 0; i < n; i++) {
-    j = list[i];
-    energy[j] += buf[m++];
-  }
-}
-
-/* ----------------------------------------------------------------------
-   memory usage of local atom-based array
-------------------------------------------------------------------------- */
-
-int FixEnergy::memory_usage()
-{
-  int bytes = nmax * sizeof(double);
-  return bytes;
-}
diff --git a/src/fix_energy.h b/src/fix_energy.h
deleted file mode 100644
index 4882f1af211e96df0b16fb92748d5cde04779a1c..0000000000000000000000000000000000000000
--- a/src/fix_energy.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/* ----------------------------------------------------------------------
-   LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
-
-   Copyright (2003) Sandia Corporation.  Under the terms of Contract
-   DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
-   certain rights in this software.  This software is distributed under 
-   the GNU General Public License.
-
-   See the README file in the top-level LAMMPS directory.
-------------------------------------------------------------------------- */
-
-#ifndef FIX_ENERGY_H
-#define FIX_ENERGY_H
-
-#include "fix.h"
-
-class FixEnergy : public Fix {
-  friend class DumpCustom;
-
- public:
-  FixEnergy(int, char **);
-  ~FixEnergy();
-  int setmask();
-  void init();
-  void dump();
-  int pack_reverse_comm(int, int, double *);
-  void unpack_reverse_comm(int, int *, double *);
-  int memory_usage();
-
- private:
-  int nmax,eamstyle;
-  double *energy;
-};
-
-#endif
diff --git a/src/fix_enforce2d.cpp b/src/fix_enforce2d.cpp
index e86787a6105f8ebe41b488d788fe197c10eeb26d..30d99020504bab5ec30a779f4c89e34e4b1561a4 100644
--- a/src/fix_enforce2d.cpp
+++ b/src/fix_enforce2d.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -18,9 +18,12 @@
 #include "respa.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 /* ---------------------------------------------------------------------- */
 
-FixEnforce2D::FixEnforce2D(int narg, char **arg) : Fix(narg, arg)
+FixEnforce2D::FixEnforce2D(LAMMPS *lmp, int narg, char **arg) :
+  Fix(lmp, narg, arg)
 {
   if (narg != 3) error->all("Illegal fix enforce2d command");
 }
diff --git a/src/fix_enforce2d.h b/src/fix_enforce2d.h
index 1379a540d75a8b0f3b5941a146aa417237a42a4d..5e45481e4b919acf733566fd5db1182376b952ce 100644
--- a/src/fix_enforce2d.h
+++ b/src/fix_enforce2d.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,10 +16,11 @@
 
 #include "fix.h"
 
+namespace LAMMPS_NS {
+
 class FixEnforce2D : public Fix {
  public:
-  FixEnforce2D(int, char **);
-  ~FixEnforce2D() {}
+  FixEnforce2D(class LAMMPS *, int, char **);
   int setmask();
   void init();
   void setup();
@@ -32,4 +33,6 @@ class FixEnforce2D : public Fix {
   int granular;
 };
 
+}
+
 #endif
diff --git a/src/fix_gravity.cpp b/src/fix_gravity.cpp
index b0b4c0f8a5a899858bb80bdca38fa60ff60f9ddc..211b89870133650285fdfa2066f83f8a5bd4fbf7 100644
--- a/src/fix_gravity.cpp
+++ b/src/fix_gravity.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -20,9 +20,12 @@
 #include "update.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 /* ---------------------------------------------------------------------- */
 
-FixGravity::FixGravity(int narg, char **arg) : Fix(narg, arg)
+FixGravity::FixGravity(LAMMPS *lmp, int narg, char **arg) :
+  Fix(lmp, narg, arg)
 {
   if (narg < 4) error->all("Illegal fix gravity command");
 
diff --git a/src/fix_gravity.h b/src/fix_gravity.h
index 5f5301e703bc3b36ddc6ba8ace797c3f030b57fe..505ebf5acda38d19db344c1f95b7e07baa8c6696 100644
--- a/src/fix_gravity.h
+++ b/src/fix_gravity.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,12 +16,13 @@
 
 #include "fix.h"
 
+namespace LAMMPS_NS {
+
 class FixGravity : public Fix {
   friend class FixPour;
 
  public:
-  FixGravity(int, char **);
-  ~FixGravity() {}
+FixGravity(class LAMMPS *, int, char **);
   int setmask();
   void init();
   void setup();
@@ -37,4 +38,6 @@ class FixGravity : public Fix {
   double degree2rad;
 };
 
+}
+
 #endif
diff --git a/src/fix_gyration.cpp b/src/fix_gyration.cpp
index 7d50a7ba018b5b39102d30718f45a6e2f3082421..d21a91fd8e60c9379e66814b3b10ffbd414ee086 100644
--- a/src/fix_gyration.cpp
+++ b/src/fix_gyration.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -19,9 +19,12 @@
 #include "group.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 /* ---------------------------------------------------------------------- */
 
-FixGyration::FixGyration(int narg, char **arg) : Fix(narg, arg)
+FixGyration::FixGyration(LAMMPS *lmp, int narg, char **arg) :
+  Fix(lmp, narg, arg)
 {
   if (narg != 5) error->all("Illegal fix gyration command");
   nevery = atoi(arg[3]);
diff --git a/src/fix_gyration.h b/src/fix_gyration.h
index 77d54cf2cd3fc7fbdb3ea14a0a5d963c372c76f1..448a80cd0645dc2b47bc9dfd82a0095e4035a9fa 100644
--- a/src/fix_gyration.h
+++ b/src/fix_gyration.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -17,9 +17,11 @@
 #include "stdio.h"
 #include "fix.h"
 
+namespace LAMMPS_NS {
+
 class FixGyration : public Fix {
  public:
-  FixGyration(int, char **);
+  FixGyration(class LAMMPS *, int, char **);
   ~FixGyration();
   int setmask();
   void init();
@@ -32,4 +34,6 @@ class FixGyration : public Fix {
   double masstotal;
 };
 
+}
+
 #endif
diff --git a/src/fix_indent.cpp b/src/fix_indent.cpp
index ff491f2ef506050b5bb02e276c36340169296422..9f65eeb4584b274bd15a78d9cc8251fcc73b281c 100644
--- a/src/fix_indent.cpp
+++ b/src/fix_indent.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -27,13 +27,16 @@
 #include "respa.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define NONE     0
 #define SPHERE   1
 #define CYLINDER 2
 
 /* ---------------------------------------------------------------------- */
 
-FixIndent::FixIndent(int narg, char **arg) : Fix(narg, arg)
+FixIndent::FixIndent(LAMMPS *lmp, int narg, char **arg) :
+  Fix(lmp, narg, arg)
 {
   if (narg < 4) error->all("Illegal fix indent command");
   k = atof(arg[3]);
@@ -107,7 +110,7 @@ int FixIndent::setmask()
 {
   int mask = 0;
   mask |= POST_FORCE;
-  mask |= THERMO;
+  mask |= THERMO_ENERGY;
   mask |= POST_FORCE_RESPA;
   mask |= MIN_POST_FORCE;
   return mask;
@@ -119,16 +122,13 @@ void FixIndent::init()
 {
   if (strcmp(update->integrate_style,"respa") == 0)
     nlevels_respa = ((Respa *) update->integrate)->nlevels;
-
-  if (thermo_print || thermo_energy) thermo_flag = 1;
-  else thermo_flag = 0;
 }
 
 /* ---------------------------------------------------------------------- */
 
 void FixIndent::setup()
 {
-  eflag_on = 1;
+  eflag_enable = 1;
   if (strcmp(update->integrate_style,"verlet") == 0)
     post_force(1);
   else {
@@ -136,14 +136,14 @@ void FixIndent::setup()
     post_force_respa(1,nlevels_respa-1,0);
     ((Respa *) update->integrate)->copy_f_flevel(nlevels_respa-1);
   }
-  eflag_on = 0;
+  eflag_enable = 0;
 }
 
 /* ---------------------------------------------------------------------- */
 
 void FixIndent::min_setup()
 {
-  eflag_on = 1;
+  eflag_enable = 1;
   post_force(1);
 }
 
@@ -152,11 +152,8 @@ void FixIndent::min_setup()
 void FixIndent::post_force(int vflag)
 {
   bool eflag = false;
-  if (thermo_flag) {
-    if (eflag_on) eflag = true;
-    else if (output->next_thermo == update->ntimestep) eflag = true;
-  }
-  if (eflag) eng = 0.0;
+  if (eflag_enable) eflag = true;
+  else if (output->next_thermo == update->ntimestep) eflag = true;
 
   // set current r0
   // for minimization, always set to r0_stop
@@ -169,6 +166,9 @@ void FixIndent::post_force(int vflag)
     r0 = r0_start + delta * (r0_stop-r0_start);
   }
 
+  double eng;
+  if (eflag) eng = 0.0;
+
   // spherical indenter
 
   if (istyle == SPHERE) {
@@ -273,20 +273,10 @@ void FixIndent::min_post_force(int vflag)
 
 /* ---------------------------------------------------------------------- */
 
-int FixIndent::thermo_fields(int n, int *flags, char **keywords)
-{
-  if (n == 0) return 1;
-  flags[0] = 3;
-  strcpy(keywords[0],"Indent");
-  return 1;
-}
-
-/* ---------------------------------------------------------------------- */
-
-int FixIndent::thermo_compute(double *values)
+double FixIndent::thermo(int n)
 {
-  values[0] = etotal;
-  return 1;
+  if (n == 0) return etotal;
+  else return 0.0;
 }
 
 /* ----------------------------------------------------------------------
diff --git a/src/fix_indent.h b/src/fix_indent.h
index 73f5f1ca1aa89d32877e7cb571bce6a9bcaafa74..3b7d28bd2cdf48f53f48e32759c27c38a3af617f 100644
--- a/src/fix_indent.h
+++ b/src/fix_indent.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,10 +16,11 @@
 
 #include "fix.h"
 
+namespace LAMMPS_NS {
+
 class FixIndent : public Fix {
  public:
-  FixIndent(int, char **);
-  ~FixIndent() {}
+  FixIndent(class LAMMPS *, int, char **);
   int setmask();
   void init();
   void setup();
@@ -27,11 +28,10 @@ class FixIndent : public Fix {
   void post_force(int);
   void post_force_respa(int, int, int);
   void min_post_force(int);
-  int thermo_fields(int, int *, char **);
-  int thermo_compute(double *);
+  double thermo(int);
 
  private:
-  int ntimestep_initial,istyle,scaleflag,radflag,thermo_flag,eflag_on;
+  int ntimestep_initial,istyle,scaleflag,radflag,thermo_flag,eflag_enable;
   double k,k3,eng,etotal;
   double x0,y0,z0,r0_stop,r0_start;
   int cdim;
@@ -42,4 +42,6 @@ class FixIndent : public Fix {
   void options(int, char **);
 };
 
+}
+
 #endif
diff --git a/src/fix_langevin.cpp b/src/fix_langevin.cpp
index f5cdb96e0ddcab67fbbd6d8bca9b866fd4c01a2f..2d2fc0a210c50679d42a117311e694da3fda2f74 100644
--- a/src/fix_langevin.cpp
+++ b/src/fix_langevin.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -26,9 +26,12 @@
 #include "random_mars.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 /* ---------------------------------------------------------------------- */
 
-FixLangevin::FixLangevin(int narg, char **arg) : Fix(narg, arg)
+FixLangevin::FixLangevin(LAMMPS *lmp, int narg, char **arg) :
+  Fix(lmp, narg, arg)
 {
   if (narg < 7) error->all("Illegal fix langevin command");
 
@@ -43,7 +46,7 @@ FixLangevin::FixLangevin(int narg, char **arg) : Fix(narg, arg)
 
   // initialize Marsaglia RNG with processor-unique seed
 
-  random = new RanMars(seed + comm->me);
+  random = new RanMars(lmp,seed + comm->me);
 
   // allocate per-type arrays for force prefactors
 
diff --git a/src/fix_langevin.h b/src/fix_langevin.h
index 44eee526a1d8c55d2d5c3992066b7ebf08ed5730..9b614e882332029d425259bf99e327b2f6155efb 100644
--- a/src/fix_langevin.h
+++ b/src/fix_langevin.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,11 +16,11 @@
 
 #include "fix.h"
 
-class RanMars;
+namespace LAMMPS_NS {
 
 class FixLangevin : public Fix {
  public:
-  FixLangevin(int, char **);
+  FixLangevin(class LAMMPS *, int, char **);
   ~FixLangevin();
   int setmask();
   void init();
@@ -35,7 +35,9 @@ class FixLangevin : public Fix {
   double *gfactor1,*gfactor2,*ratio;
 
   int nlevels_respa;
-  RanMars *random;
+  class RanMars *random;
 };
 
+}
+
 #endif
diff --git a/src/fix_line_force.cpp b/src/fix_line_force.cpp
index e20d16a99f3997c6adb2fd4961e071222e16cb6a..bde78c504002c542b3eff75728c629d96d1b9ce0 100644
--- a/src/fix_line_force.cpp
+++ b/src/fix_line_force.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -19,9 +19,12 @@
 #include "respa.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 /* ---------------------------------------------------------------------- */
 
-FixLineForce::FixLineForce(int narg, char **arg) : Fix(narg, arg)
+FixLineForce::FixLineForce(LAMMPS *lmp, int narg, char **arg) :
+  Fix(lmp, narg, arg)
 {
   if (narg != 6) error->all("Illegal fix lineforce command");
   xdir = atof(arg[3]);
diff --git a/src/fix_line_force.h b/src/fix_line_force.h
index 47aa393695232994c38030654f12a4ad6612ffb0..e7fbc20b24122f01948302edc8ea611e9c848f32 100644
--- a/src/fix_line_force.h
+++ b/src/fix_line_force.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,10 +16,11 @@
 
 #include "fix.h"
 
+namespace LAMMPS_NS {
+
 class FixLineForce : public Fix {
  public:
-  FixLineForce(int, char **);
-  ~FixLineForce() {}
+  FixLineForce(class LAMMPS *, int, char **);
   int setmask();
   void setup();
   void min_setup();
@@ -31,4 +32,6 @@ class FixLineForce : public Fix {
   double xdir,ydir,zdir;
 };
 
+}
+
 #endif
diff --git a/src/fix_minimize.cpp b/src/fix_minimize.cpp
index a2531b84c32067eacfff1e2c35498e113504a41e..27f2ae084aa98d0316288a274cce158059e26f9f 100644
--- a/src/fix_minimize.cpp
+++ b/src/fix_minimize.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,12 +16,15 @@
 #include "memory.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 /* ---------------------------------------------------------------------- */
 
-FixMinimize::FixMinimize(int narg, char **arg) : Fix(narg, arg)
+FixMinimize::FixMinimize(LAMMPS *lmp, int narg, char **arg) :
+  Fix(lmp, narg, arg)
 {
   // perform initial allocation of atom-based arrays
-  // register with atom class
+  // register with Atom class
 
   gradient = NULL;
   searchdir = NULL;
@@ -33,10 +36,9 @@ FixMinimize::FixMinimize(int narg, char **arg) : Fix(narg, arg)
 
 FixMinimize::~FixMinimize()
 {
-  // if atom class still exists:
-  //   unregister this fix so atom class doesn't invoke it any more
+  // unregister callbacks to this fix from Atom class
 
-  if (atom) atom->delete_callback(id,0);
+  atom->delete_callback(id,0);
 
   // delete locally stored arrays
 
diff --git a/src/fix_minimize.h b/src/fix_minimize.h
index c6adf3bd57e8c695fd56eb56648b2e3d5321e3ac..4d5a5c20182c19dc661432fd09d1a56e0f8ee13c 100644
--- a/src/fix_minimize.h
+++ b/src/fix_minimize.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,11 +16,13 @@
 
 #include "fix.h"
 
+namespace LAMMPS_NS {
+
 class FixMinimize : public Fix {
  public:
   double **gradient,**searchdir;      // gradient vectors
 
-  FixMinimize(int, char **);
+  FixMinimize(class LAMMPS *, int, char **);
   ~FixMinimize();
   int setmask();
   void init() {}
@@ -32,4 +34,6 @@ class FixMinimize : public Fix {
   int unpack_exchange(int, double *);
 };
 
+}
+
 #endif
diff --git a/src/fix_momentum.cpp b/src/fix_momentum.cpp
index 87fa9b1821943b9e3fbeaf315d1cac6ca57eb6c9..b01f752ec5b50135acf4aec68ea57af09d1e731c 100644
--- a/src/fix_momentum.cpp
+++ b/src/fix_momentum.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -19,13 +19,16 @@
 #include "group.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 /* ----------------------------------------------------------------------
    Contributing author: Naveen Michaud-Agrawal (Johns Hopkins U)
 ------------------------------------------------------------------------- */
 
 /* ---------------------------------------------------------------------- */
 
-FixMomentum::FixMomentum(int narg, char **arg) : Fix(narg, arg)
+FixMomentum::FixMomentum(LAMMPS *lmp, int narg, char **arg) :
+  Fix(lmp, narg, arg)
 {
   if (narg < 4) error->all("Illegal fix momentum command");
   nevery = atoi(arg[3]);
@@ -105,7 +108,7 @@ void FixMomentum::end_of_step()
     group->xcm(igroup,masstotal,xcm);
     group->angmom(igroup,xcm,angmom);
     group->inertia(igroup,xcm,inertia);
-    group->omega(igroup,angmom,inertia,omega);
+    group->omega(angmom,inertia,omega);
     
     // adjust velocities to zero omega
     // vnew_i = v_i - w x r_i
diff --git a/src/fix_momentum.h b/src/fix_momentum.h
index 9664052965cf6b6b16c52c9ac18e4c289fcfc417..e3b038733757dc53d4c6bdd1144c595be437e49c 100644
--- a/src/fix_momentum.h
+++ b/src/fix_momentum.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,10 +16,11 @@
 
 #include "fix.h"
 
+namespace LAMMPS_NS {
+
 class FixMomentum : public Fix {
  public:
-  FixMomentum(int, char **);
-  ~FixMomentum() {}
+  FixMomentum(class LAMMPS *, int, char **);
   int setmask();
   void init();
   void end_of_step();
@@ -30,4 +31,6 @@ class FixMomentum : public Fix {
   double masstotal;
 };
 
+}
+
 #endif
diff --git a/src/fix_msd.cpp b/src/fix_msd.cpp
index 986729d5de2191daa1b69b512a9d2b2b25daef4d..097a8eaed3380edf27639622b59b983b01bbba9b 100644
--- a/src/fix_msd.cpp
+++ b/src/fix_msd.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -22,9 +22,12 @@
 #include "memory.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 /* ---------------------------------------------------------------------- */
 
-FixMSD::FixMSD(int narg, char **arg) : Fix(narg, arg)
+FixMSD::FixMSD(LAMMPS *lmp, int narg, char **arg) :
+  Fix(lmp, narg, arg)
 {
   if (narg != 5) error->all("Illegal fix msd command");
   nevery = atoi(arg[3]);
@@ -49,7 +52,7 @@ FixMSD::FixMSD(int narg, char **arg) : Fix(narg, arg)
   }
 
   // perform initial allocation of atom-based array
-  // register with atom class
+  // register with Atom class
 
   xoriginal = NULL;
   grow_arrays(atom->nmax);
@@ -98,11 +101,10 @@ FixMSD::~FixMSD()
 {
   if (me == 0) fclose(fp);
 
-  // if atom class still exists:
-  //   unregister this fix so atom class doesn't invoke it any more
+  // unregister callbacks to this fix from Atom class
  
-  if (atom) atom->delete_callback(id,0);
-  if (atom) atom->delete_callback(id,1);
+  atom->delete_callback(id,0);
+  atom->delete_callback(id,1);
 
   // delete locally stored array
 
diff --git a/src/fix_msd.h b/src/fix_msd.h
index 88b4345395192cbf61a32a3db4a0551ae70d572d..8c364f86dd9cd61a98ebe780bc7e66ae582c0ee8 100644
--- a/src/fix_msd.h
+++ b/src/fix_msd.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -17,9 +17,11 @@
 #include "stdio.h"
 #include "fix.h"
 
+namespace LAMMPS_NS {
+
 class FixMSD : public Fix {
  public:
-  FixMSD(int, char **);
+  FixMSD(class LAMMPS *, int, char **);
   ~FixMSD();
   int setmask();
   void init();
@@ -43,4 +45,6 @@ class FixMSD : public Fix {
   double **xoriginal;         // original coords of atoms
 };
 
+}
+
 #endif
diff --git a/src/fix_nph.cpp b/src/fix_nph.cpp
index 2f68702dcf0a3c5ff93d4819c738944b03be9566..ce149ec859c1f8270e55fa7656dd703d829acc2f 100644
--- a/src/fix_nph.cpp
+++ b/src/fix_nph.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -24,20 +24,22 @@
 #include "comm.h"
 #include "output.h"
 #include "modify.h"
+#include "compute.h"
 #include "kspace.h"
 #include "update.h"
 #include "respa.h"
-#include "temperature.h"
-#include "pressure.h"
 #include "domain.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define MIN(A,B) ((A) < (B)) ? (A) : (B)
 #define MAX(A,B) ((A) > (B)) ? (A) : (B)
 
 /* ---------------------------------------------------------------------- */
 
-FixNPH::FixNPH(int narg, char **arg) : Fix(narg, arg)
+FixNPH::FixNPH(LAMMPS *lmp, int narg, char **arg) :
+  Fix(lmp, narg, arg)
 {
   if (narg < 4) error->all("Illegal fix nph command");
 
@@ -125,19 +127,6 @@ FixNPH::FixNPH(int narg, char **arg) : Fix(narg, arg)
   if (p_flag[2] && domain->zperiodic == 0)
     error->all("Cannot fix nph on a non-periodic dimension");
 
-  // create a new temperature full style with fix ID and group all
-  // pressure is always global (group all) and thus its
-  //   KE/temperature contribution should use group all
-
-  char **newarg = new char*[3];
-  newarg[0] = id;
-  newarg[1] = "all";
-  newarg[2] = "full";
-  force->add_temp(3,newarg,1);
-  delete [] newarg;
-
-  temperature = force->find_temp(id);
-
   // convert input periods to frequencies
 
   if ((p_flag[0] && p_period[0] <= 0.0) || 
@@ -149,9 +138,44 @@ FixNPH::FixNPH(int narg, char **arg) : Fix(narg, arg)
   if (p_flag[1]) p_freq[1] = 1.0 / p_period[1];
   if (p_flag[2]) p_freq[2] = 1.0 / p_period[2];
 
-  // pressure init
+  // create a new compute temp style
+  // id = fix-ID + temp
+  // compute group = all since pressure is always global (group all)
+  //   and thus its KE/temperature contribution should use group all
+
+  int n = strlen(id) + 6;
+  id_temp = new char[n];
+  strcpy(id_temp,id);
+  strcat(id_temp,"_temp");
+
+  char **newarg = new char*[3];
+  newarg[0] = id_temp;
+  newarg[1] = "all";
+  newarg[2] = "temp";
+  modify->add_compute(3,newarg);
+  delete [] newarg;
+  tflag = 1;
+
+  // create a new compute pressure style
+  // id = fix-ID + press, compute group = all
+  // pass id_temp as 4th arg to pressure constructor
+
+  n = strlen(id) + 7;
+  id_press = new char[n];
+  strcpy(id_press,id);
+  strcat(id_press,"_press");
+
+  newarg = new char*[4];
+  newarg[0] = id_press;
+  newarg[1] = "all";
+  newarg[2] = "pressure";
+  newarg[3] = id_temp;
+  modify->add_compute(4,newarg);
+  delete [] newarg;
+  pflag = 1;
+
+  // Nose/Hoover pressure init
 
-  pressure = force->pressure;
   omega[0] = omega[1] = omega[2] = 0.0;
   omega_dot[0] = omega_dot[1] = omega_dot[2] = 0.0;
 
@@ -164,6 +188,13 @@ FixNPH::FixNPH(int narg, char **arg) : Fix(narg, arg)
 FixNPH::~FixNPH()
 {
   delete [] rfix;
+
+  // delete temperature and pressure if fix created them
+
+  if (tflag) modify->delete_compute(id_temp);
+  if (pflag) modify->delete_compute(id_press);
+  delete [] id_temp;
+  delete [] id_press;
 }
 
 /* ---------------------------------------------------------------------- */
@@ -173,7 +204,7 @@ int FixNPH::setmask()
   int mask = 0;
   mask |= INITIAL_INTEGRATE;
   mask |= FINAL_INTEGRATE;
-  mask |= THERMO;
+  mask |= THERMO_ENERGY;
   mask |= INITIAL_INTEGRATE_RESPA;
   mask |= FINAL_INTEGRATE_RESPA;
   return mask;
@@ -183,8 +214,27 @@ int FixNPH::setmask()
 
 void FixNPH::init()
 {
-  if (atom->mass_require == 0)
-    error->all("Cannot use fix nph with no per-type mass defined");
+  if (atom->mass == NULL)
+    error->all("Cannot use fix nph without per-type mass defined");
+
+  // set temperature and pressure ptrs
+  // set ptemperature only if pressure's id_pre is not id_temp
+
+  int icompute = modify->find_compute(id_temp);
+  if (icompute < 0) error->all("Temp ID for fix nph does not exist");
+  temperature = modify->compute[icompute];
+
+  icompute = modify->find_compute(id_press);
+  if (icompute < 0) error->all("Press ID for fix nph does not exist");
+  pressure = modify->compute[icompute];
+
+  if (strcmp(id_temp,pressure->id_pre) == 0) ptemperature = NULL;
+  else {
+    icompute = modify->find_compute(pressure->id_pre);
+    if (icompute < 0)
+      error->all("Temp ID of press ID for fix nph does not exist");
+    ptemperature = modify->compute[icompute];
+  }
 
   // set timesteps and frequencies
   // Nkt = initial value for piston mass and energy conservation
@@ -202,7 +252,8 @@ void FixNPH::init()
   nktv2p = force->nktv2p;
   vol0 = domain->xprd * domain->yprd * domain->zprd;
 
-  double t_initial = temperature->compute();
+  temperature->init();           // not yet called by Modify::init()
+  double t_initial = temperature->compute_scalar();
   if (t_initial == 0.0) {
     if (strcmp(update->unit_style,"lj") == 0) t_initial = 1.0;
     else t_initial = 300.0;
@@ -246,12 +297,19 @@ void FixNPH::init()
 
 void FixNPH::setup()
 {
-  p_target[0] = p_start[0];                 // used by thermo_compute()
+  p_target[0] = p_start[0];                 // used by thermo()
   p_target[1] = p_start[1];
   p_target[2] = p_start[2];
 
-  double t_current = temperature->compute();
-  pressure->compute(temperature);
+  double tmp = temperature->compute_scalar();
+  if (press_couple == 0) {
+    if (ptemperature) tmp = ptemperature->compute_scalar();
+    tmp = pressure->compute_scalar();
+  } else {
+    temperature->compute_vector();
+    if (ptemperature) ptemperature->compute_vector();
+    pressure->compute_vector();
+  }
   couple();
 }
 
@@ -352,8 +410,15 @@ void FixNPH::final_integrate()
 
   // compute new pressure
 
-  double t_current = temperature->compute();
-  pressure->compute(temperature);
+  double tmp = temperature->compute_scalar();
+  if (press_couple == 0) {
+    if (ptemperature) tmp = ptemperature->compute_scalar();
+    tmp = pressure->compute_scalar();
+  } else {
+    temperature->compute_vector();
+    if (ptemperature) ptemperature->compute_vector();
+    pressure->compute_vector();
+  }
   couple();
 
   // update omega_dot
@@ -509,26 +574,26 @@ void FixNPH::final_integrate_respa(int ilevel)
 
 void FixNPH::couple()
 {
-  double *p_tensor = pressure->p_tensor;
+  double *tensor = pressure->vector;
 
   if (press_couple == 0)
-    p_current[0] = p_current[1] = p_current[2] = pressure->p_total;
+    p_current[0] = p_current[1] = p_current[2] = pressure->scalar;
   else if (press_couple == 1) {
-    double ave = 0.5 * (p_tensor[0] + p_tensor[1]);
+    double ave = 0.5 * (tensor[0] + tensor[1]);
     p_current[0] = p_current[1] = ave;
-    p_current[2] = p_tensor[2];
+    p_current[2] = tensor[2];
   } else if (press_couple == 2) {
-    double ave = 0.5 * (p_tensor[1] + p_tensor[2]);
+    double ave = 0.5 * (tensor[1] + tensor[2]);
     p_current[1] = p_current[2] = ave;
-    p_current[0] = p_tensor[0];
+    p_current[0] = tensor[0];
   } else if (press_couple == 3) {
-    double ave = 0.5 * (p_tensor[0] + p_tensor[2]);
+    double ave = 0.5 * (tensor[0] + tensor[2]);
     p_current[0] = p_current[2] = ave;
-    p_current[1] = p_tensor[1];
+    p_current[1] = tensor[1];
   } if (press_couple == 4) {
-    p_current[0] = p_tensor[0];
-    p_current[1] = p_tensor[1];
-    p_current[2] = p_tensor[2];
+    p_current[0] = tensor[0];
+    p_current[1] = tensor[1];
+    p_current[2] = tensor[2];
   }
 }
 
@@ -662,39 +727,69 @@ int FixNPH::modify_param(int narg, char **arg)
 {
   if (strcmp(arg[0],"temp") == 0) {
     if (narg < 2) error->all("Illegal fix_modify command");
-    temperature = force->find_temp(arg[1]);
-    if (temperature == NULL)
-      error->all("Could not find fix_modify temperature ID");
+    if (tflag) {
+      modify->delete_compute(id_temp);
+      tflag = 0;
+    }
+    delete [] id_temp;
+    int n = strlen(arg[1]) + 1;
+    id_temp = new char[n];
+    strcpy(id_temp,arg[1]);
+
+    int icompute = modify->find_compute(id_temp);
+    if (icompute < 0) error->all("Could not find fix_modify temp ID");
+    temperature = modify->compute[icompute];
+
+    if (temperature->tempflag == 0)
+      error->all("Fix_modify temp ID does not compute temperature");
     if (temperature->igroup != 0 && comm->me == 0)
       error->warning("Temperature for NPH is not for group all");
-    if (strcmp(temperature->style,"region") == 0 && comm->me == 0)
-      error->warning("Temperature for NPH is style region");
+
+    // reset id_pre of pressure to new temp ID
+    
+    icompute = modify->find_compute(id_press);
+    if (icompute < 0) error->all("Press ID for fix npt does not exist");
+    delete [] modify->compute[icompute]->id_pre;
+    modify->compute[icompute]->id_pre = new char[n];
+    strcpy(modify->compute[icompute]->id_pre,id_temp);
+
     return 2;
-  }
-  return 0;
-}
 
-/* ---------------------------------------------------------------------- */
+  } else if (strcmp(arg[0],"press") == 0) {
+    if (narg < 2) error->all("Illegal fix_modify command");
+    if (pflag) {
+      modify->delete_compute(id_press);
+      pflag = 0;
+    }
+    delete [] id_press;
+    int n = strlen(arg[1]) + 1;
+    id_press = new char[n];
+    strcpy(id_press,arg[1]);
 
-int FixNPH::thermo_fields(int n, int *flags, char **keywords)
-{
-  if (n == 0) return 1;
-  flags[0] = 3;
-  strcpy(keywords[0],"EngNPH");
-  return 1;
+    int icompute = modify->find_compute(id_press);
+    if (icompute < 0) error->all("Could not find fix_modify press ID");
+    pressure = modify->compute[icompute];
+
+    if (pressure->pressflag == 0)
+      error->all("Fix_modify press ID does not compute pressure");
+    return 2;
+  }
+  return 0;
 }
 
 /* ---------------------------------------------------------------------- */
 
-int FixNPH::thermo_compute(double *values)
+double FixNPH::thermo(int n)
 {
   double volume = domain->xprd * domain->yprd * domain->zprd;
   int pdim = p_flag[0] + p_flag[1] + p_flag[2];
 
-  values[0] = 0.0;
+  double energy = 0.0;
   for (int i = 0; i < 3; i++)
     if (p_freq[i] > 0.0)
-      values[0] += 0.5*nkt*omega_dot[i]*omega_dot[i] / 
+      energy += 0.5*nkt*omega_dot[i]*omega_dot[i] / 
 	(p_freq[i]*p_freq[i]) + p_target[i]*(volume-vol0) / (pdim*nktv2p);
-  return 1;
+
+  if (n == 0) return energy;
+  else return 0.0;
 }
diff --git a/src/fix_nph.h b/src/fix_nph.h
index 5df3a17a7897ea709fe2cd93e7b9bebfac223f11..351e81f0c85a02d0fcfea817fde2e57f0f266d37 100644
--- a/src/fix_nph.h
+++ b/src/fix_nph.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -15,14 +15,12 @@
 #define FIX_NPH_H
 
 #include "fix.h"
-class Temperature;
-class Pressure;
 
-class FixNPH : public Fix {
-  friend class Pressure;              // accesses press_couple
+namespace LAMMPS_NS {
 
+class FixNPH : public Fix {
  public:
-  FixNPH(int, char **);
+  FixNPH(class LAMMPS *, int, char **);
   ~FixNPH();
   int setmask();
   void init();
@@ -31,16 +29,12 @@ class FixNPH : public Fix {
   void final_integrate();
   void initial_integrate_respa(int,int);
   void final_integrate_respa(int);
+  double thermo(int);
   void write_restart(FILE *);
   void restart(char *);
   int modify_param(int, char **);
-  int thermo_fields(int, int *, char **);
-  int thermo_compute(double *);
 
  private:
-  Temperature *temperature;
-  Pressure *pressure;
-
   double dtv,dtf,dthalf;
   double boltz,nktv2p;
   double total_mass,vol0,nkt;
@@ -60,8 +54,14 @@ class FixNPH : public Fix {
   int nlevels_respa;
   double *step_respa;
 
+  char *id_temp,*id_press;
+  class Compute *temperature,*pressure,*ptemperature;
+  int tflag,pflag;
+
   void couple();
   void box_dilate(int);
 };
 
+}
+
 #endif
diff --git a/src/fix_npt.cpp b/src/fix_npt.cpp
index 49605405c7fbf17aacb7cafc318b8a0e0ccbbbc5..68e3e213aea271b50c86cb894b1bb4fb9e3e3bbd 100644
--- a/src/fix_npt.cpp
+++ b/src/fix_npt.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -24,20 +24,22 @@
 #include "comm.h"
 #include "output.h"
 #include "modify.h"
+#include "compute.h"
 #include "kspace.h"
 #include "update.h"
 #include "respa.h"
-#include "temperature.h"
-#include "pressure.h"
 #include "domain.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define MIN(A,B) ((A) < (B)) ? (A) : (B)
 #define MAX(A,B) ((A) > (B)) ? (A) : (B)
 
 /* ---------------------------------------------------------------------- */
 
-FixNPT::FixNPT(int narg, char **arg) : Fix(narg, arg)
+FixNPT::FixNPT(LAMMPS *lmp, int narg, char **arg) :
+  Fix(lmp, narg, arg)
 {
   if (narg < 7) error->all("Illegal fix npt command");
 
@@ -132,21 +134,6 @@ FixNPT::FixNPT(int narg, char **arg) : Fix(narg, arg)
   if (p_flag[2] && domain->zperiodic == 0)
     error->all("Cannot fix npt on a non-periodic dimension");
 
-  // create a new temperature full style with fix ID and group all
-  // pressure is always global (group all) and thus its
-  //   KE/temperature contribution should use group all
-
-  eta = eta_dot = 0.0;
-
-  char **newarg = new char*[3];
-  newarg[0] = id;
-  newarg[1] = "all";
-  newarg[2] = "full";
-  force->add_temp(3,newarg,1);
-  delete [] newarg;
-
-  temperature = force->find_temp(id);
-
   // convert input periods to frequencies
 
   if (t_period <= 0.0 || (p_flag[0] && p_period[0] <= 0.0) || 
@@ -159,9 +146,45 @@ FixNPT::FixNPT(int narg, char **arg) : Fix(narg, arg)
   if (p_flag[1]) p_freq[1] = 1.0 / p_period[1];
   if (p_flag[2]) p_freq[2] = 1.0 / p_period[2];
 
-  // pressure init
+  // create a new compute temp style
+  // id = fix-ID + temp
+  // compute group = all since pressure is always global (group all)
+  //   and thus its KE/temperature contribution should use group all
+
+  int n = strlen(id) + 6;
+  id_temp = new char[n];
+  strcpy(id_temp,id);
+  strcat(id_temp,"_temp");
 
-  pressure = force->pressure;
+  char **newarg = new char*[3];
+  newarg[0] = id_temp;
+  newarg[1] = "all";
+  newarg[2] = "temp";
+  modify->add_compute(3,newarg);
+  delete [] newarg;
+  tflag = 1;
+
+  // create a new compute pressure style
+  // id = fix-ID + press, compute group = all
+  // pass id_temp as 4th arg to pressure constructor
+
+  n = strlen(id) + 7;
+  id_press = new char[n];
+  strcpy(id_press,id);
+  strcat(id_press,"_press");
+
+  newarg = new char*[4];
+  newarg[0] = id_press;
+  newarg[1] = "all";
+  newarg[2] = "pressure";
+  newarg[3] = id_temp;
+  modify->add_compute(4,newarg);
+  delete [] newarg;
+  pflag = 1;
+
+  // Nose/Hoover temp and pressure init
+
+  eta = eta_dot = 0.0;
   omega[0] = omega[1] = omega[2] = 0.0;
   omega_dot[0] = omega_dot[1] = omega_dot[2] = 0.0;
 
@@ -174,6 +197,13 @@ FixNPT::FixNPT(int narg, char **arg) : Fix(narg, arg)
 FixNPT::~FixNPT()
 {
   delete [] rfix;
+
+  // delete temperature and pressure if fix created them
+
+  if (tflag) modify->delete_compute(id_temp);
+  if (pflag) modify->delete_compute(id_press);
+  delete [] id_temp;
+  delete [] id_press;
 }
 
 /* ---------------------------------------------------------------------- */
@@ -183,7 +213,7 @@ int FixNPT::setmask()
   int mask = 0;
   mask |= INITIAL_INTEGRATE;
   mask |= FINAL_INTEGRATE;
-  mask |= THERMO;
+  mask |= THERMO_ENERGY;
   mask |= INITIAL_INTEGRATE_RESPA;
   mask |= FINAL_INTEGRATE_RESPA;
   return mask;
@@ -193,8 +223,27 @@ int FixNPT::setmask()
 
 void FixNPT::init()
 {
-  if (atom->mass_require == 0)
-    error->all("Cannot use fix npt with no per-type mass defined");
+  if (atom->mass == NULL)
+    error->all("Cannot use fix npt without per-type mass defined");
+
+  // set temperature and pressure ptrs
+  // set ptemperature only if pressure's id_pre is not id_temp
+
+  int icompute = modify->find_compute(id_temp);
+  if (icompute < 0) error->all("Temp ID for fix npt does not exist");
+  temperature = modify->compute[icompute];
+
+  icompute = modify->find_compute(id_press);
+  if (icompute < 0) error->all("Press ID for fix npt does not exist");
+  pressure = modify->compute[icompute];
+
+  if (strcmp(id_temp,pressure->id_pre) == 0) ptemperature = NULL;
+  else {
+    icompute = modify->find_compute(pressure->id_pre);
+    if (icompute < 0)
+      error->all("Temp ID of press ID for fix npt does not exist");
+    ptemperature = modify->compute[icompute];
+  }
 
   // set timesteps and frequencies
 
@@ -247,13 +296,20 @@ void FixNPT::init()
 
 void FixNPT::setup()
 {
-  t_target = t_start;                      // used by thermo_compute()
+  t_target = t_start;                      // used by thermo()
   p_target[0] = p_start[0];
   p_target[1] = p_start[1];
   p_target[2] = p_start[2];
 
-  t_current = temperature->compute();
-  pressure->compute(temperature);
+  t_current = temperature->compute_scalar();
+  if (press_couple == 0) {
+    if (ptemperature) double ptmp = ptemperature->compute_scalar();
+    double tmp = pressure->compute_scalar();
+  } else {
+    temperature->compute_vector();
+    if (ptemperature) ptemperature->compute_vector();
+    pressure->compute_vector();
+  }
   couple();
 }
 
@@ -363,8 +419,15 @@ void FixNPT::final_integrate()
 
   // compute new T,P
 
-  t_current = temperature->compute();
-  pressure->compute(temperature);
+  t_current = temperature->compute_scalar();
+  if (press_couple == 0) {
+    if (ptemperature) double ptmp = ptemperature->compute_scalar();
+    double tmp = pressure->compute_scalar();
+  } else {
+    temperature->compute_vector();
+    if (ptemperature) ptemperature->compute_vector();
+    pressure->compute_vector();
+  }
   couple();
 
   // update eta_dot
@@ -537,26 +600,26 @@ void FixNPT::final_integrate_respa(int ilevel)
 
 void FixNPT::couple()
 {
-  double *p_tensor = pressure->p_tensor;
+  double *tensor = pressure->vector;
 
   if (press_couple == 0)
-    p_current[0] = p_current[1] = p_current[2] = pressure->p_total;
+    p_current[0] = p_current[1] = p_current[2] = pressure->scalar;
   else if (press_couple == 1) {
-    double ave = 0.5 * (p_tensor[0] + p_tensor[1]);
+    double ave = 0.5 * (tensor[0] + tensor[1]);
     p_current[0] = p_current[1] = ave;
-    p_current[2] = p_tensor[2];
+    p_current[2] = tensor[2];
   } else if (press_couple == 2) {
-    double ave = 0.5 * (p_tensor[1] + p_tensor[2]);
+    double ave = 0.5 * (tensor[1] + tensor[2]);
     p_current[1] = p_current[2] = ave;
-    p_current[0] = p_tensor[0];
+    p_current[0] = tensor[0];
   } else if (press_couple == 3) {
-    double ave = 0.5 * (p_tensor[0] + p_tensor[2]);
+    double ave = 0.5 * (tensor[0] + tensor[2]);
     p_current[0] = p_current[2] = ave;
-    p_current[1] = p_tensor[1];
+    p_current[1] = tensor[1];
   } if (press_couple == 4) {
-    p_current[0] = p_tensor[0];
-    p_current[1] = p_tensor[1];
-    p_current[2] = p_tensor[2];
+    p_current[0] = tensor[0];
+    p_current[1] = tensor[1];
+    p_current[2] = tensor[2];
   }
 }
 
@@ -694,41 +757,71 @@ int FixNPT::modify_param(int narg, char **arg)
 {
   if (strcmp(arg[0],"temp") == 0) {
     if (narg < 2) error->all("Illegal fix_modify command");
-    temperature = force->find_temp(arg[1]);
-    if (temperature == NULL)
-      error->all("Could not find fix_modify temperature ID");
+    if (tflag) {
+      modify->delete_compute(id_temp);
+      tflag = 0;
+    }
+    delete [] id_temp;
+    int n = strlen(arg[1]) + 1;
+    id_temp = new char[n];
+    strcpy(id_temp,arg[1]);
+
+    int icompute = modify->find_compute(id_temp);
+    if (icompute < 0) error->all("Could not find fix_modify temp ID");
+    temperature = modify->compute[icompute];
+
+    if (temperature->tempflag == 0)
+      error->all("Fix_modify temp ID does not compute temperature");
     if (temperature->igroup != 0 && comm->me == 0)
       error->warning("Temperature for NPT is not for group all");
-    if (strcmp(temperature->style,"region") == 0 && comm->me == 0)
-      error->warning("Temperature for NPT is style region");
+
+    // reset id_pre of pressure to new temp ID
+    
+    icompute = modify->find_compute(id_press);
+    if (icompute < 0) error->all("Press ID for fix npt does not exist");
+    delete [] modify->compute[icompute]->id_pre;
+    modify->compute[icompute]->id_pre = new char[n];
+    strcpy(modify->compute[icompute]->id_pre,id_temp);
+
     return 2;
-  }
-  return 0;
-}
 
-/* ---------------------------------------------------------------------- */
+  } else if (strcmp(arg[0],"press") == 0) {
+    if (narg < 2) error->all("Illegal fix_modify command");
+    if (pflag) {
+      modify->delete_compute(id_press);
+      pflag = 0;
+    }
+    delete [] id_press;
+    int n = strlen(arg[1]) + 1;
+    id_press = new char[n];
+    strcpy(id_press,arg[1]);
 
-int FixNPT::thermo_fields(int n, int *flags, char **keywords)
-{
-  if (n == 0) return 1;
-  flags[0] = 3;
-  strcpy(keywords[0],"EngNPT");
-  return 1;
+    int icompute = modify->find_compute(id_press);
+    if (icompute < 0) error->all("Could not find fix_modify press ID");
+    pressure = modify->compute[icompute];
+
+    if (pressure->pressflag == 0)
+      error->all("Fix_modify press ID does not compute pressure");
+    return 2;
+  }
+  return 0;
 }
 
 /* ---------------------------------------------------------------------- */
 
-int FixNPT::thermo_compute(double *values)
+double FixNPT::thermo(int n)
 {
   double ke = temperature->dof * boltz * t_target;
   double keplus = atom->natoms * boltz * t_target;
   double volume = domain->xprd * domain->yprd * domain->zprd;
   int pdim = p_flag[0] + p_flag[1] + p_flag[2];
 
-  values[0] = ke * (eta + 0.5*eta_dot*eta_dot/(t_freq*t_freq));
+  double energy = ke * (eta + 0.5*eta_dot*eta_dot/(t_freq*t_freq));
   for (int i = 0; i < 3; i++)
     if (p_freq[i] > 0.0)
-      values[0] += 0.5*keplus*omega_dot[i]*omega_dot[i] / 
+      energy += 0.5*keplus*omega_dot[i]*omega_dot[i] / 
 	(p_freq[i]*p_freq[i]) + p_target[i]*(volume-vol0) / (pdim*nktv2p);
-  return 1;
+
+  if (n == 0) return energy;
+  else return 0.0;
 }
diff --git a/src/fix_npt.h b/src/fix_npt.h
index d9ce157f570d175be55469e494136ea8f5f67340..dd066bc28e6f797ea2c6c3e05679278a3677266e 100644
--- a/src/fix_npt.h
+++ b/src/fix_npt.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -15,14 +15,12 @@
 #define FIX_NPT_H
 
 #include "fix.h"
-class Temperature;
-class Pressure;
 
-class FixNPT : public Fix {
-  friend class Pressure;              // accesses press_couple
+namespace LAMMPS_NS {
 
+class FixNPT : public Fix {
  public:
-  FixNPT(int, char **);
+  FixNPT(class LAMMPS *, int, char **);
   ~FixNPT();
   int setmask();
   void init();
@@ -31,16 +29,12 @@ class FixNPT : public Fix {
   void final_integrate();
   void initial_integrate_respa(int, int);
   void final_integrate_respa(int);
+  double thermo(int);
   void write_restart(FILE *);
   void restart(char *);
   int modify_param(int, char **);
-  int thermo_fields(int, int *, char **);
-  int thermo_compute(double *);
 
  private:
-  Temperature *temperature;
-  Pressure *pressure;
-
   double dtv,dtf,dthalf;
   double boltz,nktv2p;
   double total_mass,vol0;
@@ -65,8 +59,14 @@ class FixNPT : public Fix {
   int nlevels_respa;
   double *step_respa;
 
+  char *id_temp,*id_press;
+  class Compute *temperature,*pressure,*ptemperature;
+  int tflag,pflag;
+
   void couple();
   void box_dilate(int);
 };
 
+}
+
 #endif
diff --git a/src/fix_nve.cpp b/src/fix_nve.cpp
index 9013e2ab8ca1c0cd78f181120f38693490e9cf52..883c1ab7fe4bc15019d50c1dee8a4cfe0ea0dc2c 100644
--- a/src/fix_nve.cpp
+++ b/src/fix_nve.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -20,9 +20,12 @@
 #include "respa.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 /* ---------------------------------------------------------------------- */
 
-FixNVE::FixNVE(int narg, char **arg) : Fix(narg, arg)
+FixNVE::FixNVE(LAMMPS *lmp, int narg, char **arg) :
+  Fix(lmp, narg, arg)
 {
   if (narg != 3) error->all("Illegal fix nve command");
 }
@@ -46,7 +49,6 @@ void FixNVE::init()
   dtv = update->dt;
   dtf = 0.5 * update->dt * force->ftm2v;
 
-  mass_require = atom->mass_require;
   if (strcmp(update->integrate_style,"respa") == 0)
     step_respa = ((Respa *) update->integrate)->step;
 }
@@ -62,12 +64,13 @@ void FixNVE::initial_integrate()
   double **x = atom->x;
   double **v = atom->v;
   double **f = atom->f;
+  double *mass = atom->mass;
+  double *rmass = atom->rmass;
   int *type = atom->type;
   int *mask = atom->mask;
   int nlocal = atom->nlocal;
 
-  if (mass_require) {
-    double *mass = atom->mass;
+  if (mass) {
     for (int i = 0; i < nlocal; i++) {
       if (mask[i] & groupbit) {
 	dtfm = dtf / mass[type[i]];
@@ -81,7 +84,6 @@ void FixNVE::initial_integrate()
     }
 
   } else {
-    double *rmass = atom->rmass;
     for (int i = 0; i < nlocal; i++) {
       if (mask[i] & groupbit) {
 	dtfm = dtf / rmass[i];
@@ -104,12 +106,13 @@ void FixNVE::final_integrate()
 
   double **v = atom->v;
   double **f = atom->f;
+  double *mass = atom->mass;
+  double *rmass = atom->rmass;
   int *type = atom->type;
   int *mask = atom->mask;
   int nlocal = atom->nlocal;
 
-  if (mass_require) {
-    double *mass = atom->mass;
+  if (mass) {
     for (int i = 0; i < nlocal; i++) {
       if (mask[i] & groupbit) {
 	dtfm = dtf / mass[type[i]];
@@ -120,7 +123,6 @@ void FixNVE::final_integrate()
     }
 
   } else {
-    double *rmass = atom->rmass;
     for (int i = 0; i < nlocal; i++) {
       if (mask[i] & groupbit) {
 	dtfm = dtf / rmass[i];
diff --git a/src/fix_nve.h b/src/fix_nve.h
index cdde4c65b466cd15216912f1053fad24387496d7..5032b9bae55274b47f403897e599bde24663b0d4 100644
--- a/src/fix_nve.h
+++ b/src/fix_nve.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,10 +16,11 @@
 
 #include "fix.h"
 
+namespace LAMMPS_NS {
+
 class FixNVE : public Fix {
  public:
-  FixNVE(int, char **);
-  ~FixNVE() {}
+  FixNVE(class LAMMPS *, int, char **);
   int setmask();
   void init();
   void initial_integrate();
@@ -33,4 +34,6 @@ class FixNVE : public Fix {
   int mass_require;
 };
 
+}
+
 #endif
diff --git a/src/fix_nvt.cpp b/src/fix_nvt.cpp
index 0db44d123a26b7029881cdde39ba4ff540900965..1eee6e9bdb9c98756ce1c05ece5c8a0dd34dc459 100644
--- a/src/fix_nvt.cpp
+++ b/src/fix_nvt.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -25,12 +25,16 @@
 #include "group.h"
 #include "update.h"
 #include "respa.h"
-#include "temperature.h"
+#include "modify.h"
+#include "compute.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 /* ---------------------------------------------------------------------- */
 
-FixNVT::FixNVT(int narg, char **arg) : Fix(narg, arg)
+FixNVT::FixNVT(LAMMPS *lmp, int narg, char **arg) :
+  Fix(lmp, narg, arg)
 {
   if (narg < 6) error->all("Illegal fix nvt command");
 
@@ -52,18 +56,33 @@ FixNVT::FixNVT(int narg, char **arg) : Fix(narg, arg)
   if (t_period <= 0.0) error->all("Fix nvt period must be > 0.0");
   t_freq = 1.0 / t_period;
 
-  // create a new temperature full style with fix ID and fix group
-
   eta = eta_dot = 0.0;
 
+  // create a new compute temp style
+  // id = fix-ID + temp, compute group = fix group
+
+  int n = strlen(id) + 6;
+  id_temp = new char[n];
+  strcpy(id_temp,id);
+  strcat(id_temp,"_temp");
+
   char **newarg = new char*[3];
-  newarg[0] = id;
+  newarg[0] = id_temp;
   newarg[1] = group->names[igroup];
-  newarg[2] = "full";
-  force->add_temp(3,newarg,1);
+  newarg[2] = "temp";
+  modify->add_compute(3,newarg);
   delete [] newarg;
+  tflag = 1;
+}
 
-  temperature = force->find_temp(id);
+/* ---------------------------------------------------------------------- */
+
+FixNVT::~FixNVT()
+{
+  // delete temperature if fix created it
+
+  if (tflag) modify->delete_compute(id_temp);
+  delete [] id_temp;
 }
 
 /* ---------------------------------------------------------------------- */
@@ -73,7 +92,7 @@ int FixNVT::setmask()
   int mask = 0;
   mask |= INITIAL_INTEGRATE;
   mask |= FINAL_INTEGRATE;
-  mask |= THERMO;
+  mask |= THERMO_ENERGY;
   mask |= INITIAL_INTEGRATE_RESPA;
   mask |= FINAL_INTEGRATE_RESPA;
   return mask;
@@ -83,8 +102,14 @@ int FixNVT::setmask()
 
 void FixNVT::init()
 {
-  if (atom->mass_require == 0)
-    error->all("Cannot use fix nvt with no per-type mass defined");
+  if (atom->mass == NULL)
+    error->all("Cannot use fix nvt without per-type mass defined");
+
+  int icompute = modify->find_compute(id_temp);
+  if (icompute < 0) error->all("Temp ID for fix nvt does not exist");
+  temperature = modify->compute[icompute];
+
+  // set timesteps and frequencies
 
   dtv = update->dt;
   dtf = 0.5 * update->dt * force->ftm2v;
@@ -102,8 +127,8 @@ void FixNVT::init()
 
 void FixNVT::setup()
 {
-  t_target = t_start;                      // used by thermo_compute()
-  t_current = temperature->compute();
+  t_target = t_start;                         // used by thermo()
+  t_current = temperature->compute_scalar();
 }
 
 /* ---------------------------------------------------------------------- */
@@ -173,7 +198,7 @@ void FixNVT::final_integrate()
 
   // compute current T
 
-  t_current = temperature->compute();
+  t_current = temperature->compute_scalar();
 
   // update eta_dot
 
@@ -332,13 +357,23 @@ int FixNVT::modify_param(int narg, char **arg)
 {
   if (strcmp(arg[0],"temp") == 0) {
     if (narg < 2) error->all("Illegal fix_modify command");
-    temperature = force->find_temp(arg[1]);
-    if (temperature == NULL)
-      error->all("Could not find fix_modify temperature ID");
+    if (tflag) {
+      modify->delete_compute(id_temp);
+      tflag = 0;
+    }
+    delete [] id_temp;
+    int n = strlen(arg[1]) + 1;
+    id_temp = new char[n];
+    strcpy(id_temp,arg[1]);
+
+    int icompute = modify->find_compute(id_temp);
+    if (icompute < 0) error->all("Could not find fix_modify temp ID");
+    temperature = modify->compute[icompute];
+
+    if (temperature->tempflag == 0)
+      error->all("Fix_modify temp ID does not compute temperature");
     if (temperature->igroup != igroup && comm->me == 0)
       error->warning("Group for fix_modify temp != fix group");
-    if (strcmp(temperature->style,"region") == 0 && comm->me == 0)
-      error->warning("Temperature for NVT is style region");
     return 2;
   }
   return 0;
@@ -353,19 +388,11 @@ void FixNVT::reset_target(double t_new)
 
 /* ---------------------------------------------------------------------- */
 
-int FixNVT::thermo_fields(int n, int *flags, char **keywords)
-{
-  if (n == 0) return 1;
-  flags[0] = 3;
-  strcpy(keywords[0],"EngNVT");
-  return 1;
-}
-
-/* ---------------------------------------------------------------------- */
-
-int FixNVT::thermo_compute(double *values)
+double FixNVT::thermo(int n)
 {
   double ke = temperature->dof * force->boltz * t_target;
-  values[0] = ke * (eta + 0.5*eta_dot*eta_dot/(t_freq*t_freq));
-  return 1;
+  double energy = ke * (eta + 0.5*eta_dot*eta_dot/(t_freq*t_freq));
+
+  if (n == 0) return energy;
+  else return 0.0;
 }
diff --git a/src/fix_nvt.h b/src/fix_nvt.h
index 7cb14a3684e02eac8c0a17a184a7bdd9fbb8efda..64f4e82492466b5048222c291d0fcd67814d1e6b 100644
--- a/src/fix_nvt.h
+++ b/src/fix_nvt.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -15,12 +15,13 @@
 #define FIX_NVT_H
 
 #include "fix.h"
-class Temperature;
+
+namespace LAMMPS_NS {
 
 class FixNVT : public Fix {
  public:
-  FixNVT(int, char **);
-  ~FixNVT() {}
+  FixNVT(class LAMMPS *, int, char **);
+  ~FixNVT();
   int setmask();
   void init();
   void setup();
@@ -28,12 +29,11 @@ class FixNVT : public Fix {
   void final_integrate();
   void initial_integrate_respa(int,int);
   void final_integrate_respa(int);
+  double thermo(int);
   void write_restart(FILE *);
   void restart(char *);
   int modify_param(int, char **);
   void reset_target(double);
-  int thermo_fields(int, int *, char **);
-  int thermo_compute(double *);
 
  private:
   double t_start,t_stop;
@@ -41,10 +41,15 @@ class FixNVT : public Fix {
   double t_freq,drag,drag_factor;
   double f_eta,eta_dot,eta,factor;
   double dtv,dtf,dthalf;
-  Temperature *temperature;
 
   int nlevels_respa;
   double *step_respa;
+
+  char *id_temp;
+  class Compute *temperature;
+  int tflag;
 };
 
+}
+
 #endif
diff --git a/src/fix_orient_fcc.cpp b/src/fix_orient_fcc.cpp
index bb039e1f4efa90f42412c780ac34597e21a6be80..804e35dacba9f5ad458de551e74b1a2f683788b6 100644
--- a/src/fix_orient_fcc.cpp
+++ b/src/fix_orient_fcc.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -28,6 +28,8 @@
 #include "output.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define BIG 1000000000
 
 #define MIN(A,B) ((A) < (B)) ? (A) : (B)
@@ -35,7 +37,8 @@
 
 /* ---------------------------------------------------------------------- */
 
-FixOrientFCC::FixOrientFCC(int narg, char **arg) : Fix(narg, arg)
+FixOrientFCC::FixOrientFCC(LAMMPS *lmp, int narg, char **arg) :
+  Fix(lmp, narg, arg)
 {
   MPI_Comm_rank(world,&me);
 
@@ -136,6 +139,12 @@ FixOrientFCC::FixOrientFCC(int narg, char **arg) : Fix(narg, arg)
   xiid /= 12.0;
   xi0 = uxif_low * xiid;
   xi1 = uxif_high * xiid;
+
+  // set comm size needed by this Fix
+  // NOTE: doesn't seem that use_xismooth is ever true
+
+  if (use_xismooth) comm_forward = 62;
+  else comm_forward = 50;
 }
 
 /* ---------------------------------------------------------------------- */
@@ -153,8 +162,8 @@ int FixOrientFCC::setmask()
 {
   int mask = 0;
   mask |= POST_FORCE;
+  mask |= THERMO_ENERGY;
   mask |= POST_FORCE_RESPA;
-  mask |= THERMO;
   return mask;
 }
 
@@ -162,21 +171,15 @@ int FixOrientFCC::setmask()
 
 void FixOrientFCC::init()
 {
-  if (use_xismooth) comm->maxforward_fix = MAX(comm->maxforward_fix,62);
-  else comm->maxforward_fix = MAX(comm->maxforward_fix,50);
-
   if (strcmp(update->integrate_style,"respa") == 0)
     nlevels_respa = ((Respa *) update->integrate)->nlevels;
-
-  if (thermo_print || thermo_energy) thermo_flag = 1;
-  else thermo_flag = 0;
 }
 
 /* ---------------------------------------------------------------------- */
 
 void FixOrientFCC::setup()
 {
-  eflag_on = 1;
+  eflag_enable = 1;
   if (strcmp(update->integrate_style,"verlet") == 0)
     post_force(1);
   else {
@@ -184,7 +187,7 @@ void FixOrientFCC::setup()
     post_force_respa(1,nlevels_respa-1,0);
     ((Respa *) update->integrate)->copy_f_flevel(nlevels_respa-1);
   }
-  eflag_on = 0;
+  eflag_enable = 0;
 }
 
 /* ---------------------------------------------------------------------- */
@@ -199,11 +202,9 @@ void FixOrientFCC::post_force(int vflag)
   double *dxiptr;
   bool found_myself;
 
-  int eflag = false;
-  if (thermo_flag) {
-    if (eflag_on) eflag = true;
-    else if (output->next_thermo == update->ntimestep) eflag = true;
-  }
+  bool eflag = false;
+  if (eflag_enable) eflag = true;
+  else if (output->next_thermo == update->ntimestep) eflag = true;
 
   // set local ptrs
 
@@ -410,20 +411,10 @@ void FixOrientFCC::post_force_respa(int vflag, int ilevel, int iloop)
 
 /* ---------------------------------------------------------------------- */
 
-int FixOrientFCC::thermo_fields(int n, int *flags, char **keywords)
-{
-  if (n == 0) return 1;
-  flags[0] = 3;
-  strcpy(keywords[0],"Orient");
-  return 1;
-}
-
-/* ---------------------------------------------------------------------- */
-
-int FixOrientFCC::thermo_compute(double *values)
+double FixOrientFCC::thermo(int n)
 {
-  values[0] = total_added_e;
-  return 1;
+  if (n == 0) return total_added_e;
+  else return 0.0;
 }
 
 /* ---------------------------------------------------------------------- */
diff --git a/src/fix_orient_fcc.h b/src/fix_orient_fcc.h
index decfeb67641c1373018b349813eba316030ac16a..1ec09a68339a323f2eecc2df8bfefc897e0e69b0 100644
--- a/src/fix_orient_fcc.h
+++ b/src/fix_orient_fcc.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,6 +16,8 @@
 
 #include "fix.h"
 
+namespace LAMMPS_NS {
+
 class FixOrientFCC : public Fix {
  public:
   struct Nbr {              // neighbor info for each owned and ghost atom
@@ -35,17 +37,16 @@ class FixOrientFCC : public Fix {
     double xismooth;        // distance weighting factor
   };
 
-  FixOrientFCC(int, char **);
+  FixOrientFCC(class LAMMPS *, int, char **);
   ~FixOrientFCC();
   int setmask();
   void init();
   void setup();
   void post_force(int);
   void post_force_respa(int, int, int);
+  double thermo(int);
   int pack_comm(int, int *, double *, int *);
   void unpack_comm(int, int, double *);
-  int thermo_fields(int, int *, char **);
-  int thermo_compute(double *);
   int memory_usage();
 
  private:
@@ -62,7 +63,7 @@ class FixOrientFCC : public Fix {
   char *xifilename, *chifilename;  // file names for 2 crystal orientations
 
   bool use_xismooth;
-  int thermo_flag,eflag_on;
+  int eflag_enable;
   double Rxi[12][3],Rchi[12][3],half_xi_chi_vec[2][6][3];
   double xiid,xi0,xi1,xicutoffsq,cutsq,total_added_e;
   int half_fcc_nn,nmax;
@@ -74,4 +75,6 @@ class FixOrientFCC : public Fix {
   static int compare(const void *, const void *);
 };
 
+}
+
 #endif
diff --git a/src/fix_plane_force.cpp b/src/fix_plane_force.cpp
index 1dea08c3b1ffff70c299007a2cce584c08531606..104ff1162f19f080a39efc49ca847ee14f4ca876 100644
--- a/src/fix_plane_force.cpp
+++ b/src/fix_plane_force.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -19,9 +19,12 @@
 #include "respa.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 /* ---------------------------------------------------------------------- */
 
-FixPlaneForce::FixPlaneForce(int narg, char **arg) : Fix(narg, arg)
+FixPlaneForce::FixPlaneForce(LAMMPS *lmp, int narg, char **arg) :
+  Fix(lmp, narg, arg)
 {
   if (narg != 6) error->all("Illegal fix planeforce command");
   xdir = atof(arg[3]);
diff --git a/src/fix_plane_force.h b/src/fix_plane_force.h
index 5485ce612d4bcf827e2739e224bc8d968b3523f0..76c429d8b2b31ed228341948a8ca23ccacdb0573 100644
--- a/src/fix_plane_force.h
+++ b/src/fix_plane_force.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,10 +16,11 @@
 
 #include "fix.h"
 
+namespace LAMMPS_NS {
+
 class FixPlaneForce : public Fix {
  public:
-  FixPlaneForce(int, char **);
-  ~FixPlaneForce() {}
+  FixPlaneForce(class LAMMPS *, int, char **);
   int setmask();
   void setup();
   void min_setup();
@@ -31,4 +32,6 @@ class FixPlaneForce : public Fix {
   double xdir,ydir,zdir;
 };
 
+}
+
 #endif
diff --git a/src/fix_print.cpp b/src/fix_print.cpp
index f1263a823407801da854a6b9ddf8c5818381138f..0684dc3e0498ca54e59278120be3253a26c9b665 100644
--- a/src/fix_print.cpp
+++ b/src/fix_print.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -19,11 +19,14 @@
 #include "variable.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define MAXLINE 1024
 
 /* ---------------------------------------------------------------------- */
 
-FixPrint::FixPrint(int narg, char **arg) : Fix(narg, arg)
+FixPrint::FixPrint(LAMMPS *lmp, int narg, char **arg) :
+  Fix(lmp, narg, arg)
 {
   if (narg != 5) error->all("Illegal fix print command");
   nevery = atoi(arg[3]);
diff --git a/src/fix_print.h b/src/fix_print.h
index 07099ebea0963527360233a4a989d9b0817c76fe..a68a68ad5a1a423199e886a575c26b902260c8bf 100644
--- a/src/fix_print.h
+++ b/src/fix_print.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,9 +16,11 @@
 
 #include "fix.h"
 
+namespace LAMMPS_NS {
+
 class FixPrint : public Fix {
  public:
-  FixPrint(int, char **);
+  FixPrint(class LAMMPS *, int, char **);
   ~FixPrint();
   int setmask();
   void end_of_step();
@@ -28,4 +30,6 @@ class FixPrint : public Fix {
   char *line,*copy,*work;
 };
 
+}
+
 #endif
diff --git a/src/fix_rdf.cpp b/src/fix_rdf.cpp
index d68ffe6938caefca617f91b3bc8dac96fc12bcea..f671687baef9dbb50c031f4d514575fadd96decc 100644
--- a/src/fix_rdf.cpp
+++ b/src/fix_rdf.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -32,9 +32,12 @@
 #include "memory.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 /* ---------------------------------------------------------------------- */
 
-FixRDF::FixRDF(int narg, char **arg) : Fix(narg, arg)
+FixRDF::FixRDF(LAMMPS *lmp, int narg, char **arg) :
+  Fix(lmp, narg, arg)
 {
   if (narg < 8 || (narg-6) % 2) error->all("Illegal fix rdf command");
 
diff --git a/src/fix_rdf.h b/src/fix_rdf.h
index eae2d8add87cf986aa43419ffa632e7de70e5314..47a3f97fc4ac4e46c8a1df0476faf2fbdff91e0b 100644
--- a/src/fix_rdf.h
+++ b/src/fix_rdf.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -17,9 +17,11 @@
 #include "stdio.h"
 #include "fix.h"
 
+namespace LAMMPS_NS {
+
 class FixRDF : public Fix {
  public:
-  FixRDF(int, char **);
+  FixRDF(class LAMMPS *, int, char **);
   ~FixRDF();
   int setmask();
   void init();
@@ -39,4 +41,6 @@ class FixRDF : public Fix {
   double **gr_ave,**ncoord_ave;  // accumulators for average rdf statistics
 };
 
+}
+
 #endif
diff --git a/src/fix_recenter.cpp b/src/fix_recenter.cpp
index f40324b915277053e384cabbba178ac48ff24f2f..5f224352437f084489d4cee874dad2e867bc06f4 100644
--- a/src/fix_recenter.cpp
+++ b/src/fix_recenter.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -26,9 +26,12 @@
 #include "comm.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 /* ---------------------------------------------------------------------- */
 
-FixRecenter::FixRecenter(int narg, char **arg) : Fix(narg, arg)
+FixRecenter::FixRecenter(LAMMPS *lmp, int narg, char **arg) :
+  Fix(lmp, narg, arg)
 {
   if (narg < 6) error->all("Illegal fix recenter command");
 
diff --git a/src/fix_recenter.h b/src/fix_recenter.h
index da33a6884461834bc1ec199b00a201ebaf85af85..b2a4e82656ffedcaf6c8d4c1948592b7d9b5264a 100644
--- a/src/fix_recenter.h
+++ b/src/fix_recenter.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,10 +16,11 @@
 
 #include "fix.h"
 
+namespace LAMMPS_NS {
+
 class FixRecenter : public Fix {
  public:
-  FixRecenter(int, char **);
-  ~FixRecenter() {}
+  FixRecenter(class LAMMPS *, int, char **);
   int setmask();
   void init();
   void initial_integrate();
@@ -31,4 +32,6 @@ class FixRecenter : public Fix {
   double xcom,ycom,zcom,xinit,yinit,zinit,masstotal;
 };
 
+}
+
 #endif
diff --git a/src/fix_respa.cpp b/src/fix_respa.cpp
index 6215c114bf05c8d972a09f8e81cb0e647d4de6a6..312c9ea5579b2a0058eeac36e7e701dc5c7b5d5a 100644
--- a/src/fix_respa.cpp
+++ b/src/fix_respa.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -17,16 +17,19 @@
 #include "memory.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 /* ---------------------------------------------------------------------- */
 
-FixRespa::FixRespa(int narg, char **arg) : Fix(narg, arg)
+FixRespa::FixRespa(LAMMPS *lmp, int narg, char **arg) :
+  Fix(lmp, narg, arg)
 {
   // nlevels = # of rRESPA levels
 
   nlevels = atoi(arg[3]);
 
   // perform initial allocation of atom-based arrays
-  // register with atom class
+  // register with Atom class
 
   f_level = NULL;
   grow_arrays(atom->nmax);
@@ -37,10 +40,9 @@ FixRespa::FixRespa(int narg, char **arg) : Fix(narg, arg)
 
 FixRespa::~FixRespa()
 {
-  // if atom class still exists:
-  // unregister this fix so atom class doesn't invoke it any more
+  // unregister callbacks to this fix from Atom class
 
-  if (atom) atom->delete_callback(id,0);
+  atom->delete_callback(id,0);
 
   // delete locally stored arrays
 
diff --git a/src/fix_respa.h b/src/fix_respa.h
index acc2fb81c2a201ef22ab76a93d8474f909a8eb59..8771b637757acadbef597a432b148b1aeb0a9896 100644
--- a/src/fix_respa.h
+++ b/src/fix_respa.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,12 +16,14 @@
 
 #include "fix.h"
 
+namespace LAMMPS_NS {
+
 class FixRespa : public Fix {
   friend class Respa;
   friend class FixShake;
 
  public:
-  FixRespa(int, char **);
+  FixRespa(class LAMMPS *, int, char **);
   ~FixRespa();
   int setmask();
   void init() {}
@@ -37,4 +39,6 @@ class FixRespa : public Fix {
   double ***f_level;            // force at each rRESPA level
 };
 
+}
+
 #endif
diff --git a/src/fix_rigid.cpp b/src/fix_rigid.cpp
index 5c9130fe55e51955518ec7611b9bb8c6e1123511..85b93f3a49273d2c28d06a62c33c1f01f24f523d 100644
--- a/src/fix_rigid.cpp
+++ b/src/fix_rigid.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -27,6 +27,8 @@
 #include "memory.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define TOLERANCE 1.0e-6
 #define EPSILON 1.0e-7
 #define MAXJACOBI 50
@@ -36,18 +38,13 @@
 
 /* ---------------------------------------------------------------------- */
 
-FixRigid::FixRigid(int narg, char **arg) : Fix(narg, arg)
+FixRigid::FixRigid(LAMMPS *lmp, int narg, char **arg) :
+  Fix(lmp, narg, arg)
 {
   int i,ibody;
 
-  // can't use with pure granular style since mass arrays are different
-  // hybrid granular style would be OK if fix were on non-granular atoms
-
-  if (strcmp(atom->style,"granular") == 0)
-    error->all("Cannot use fix rigid with atom style granular");
-
   // perform initial allocation of atom-based arrays
-  // register with atom class
+  // register with Atom class
   
   body = NULL;
   displace = NULL;
@@ -220,10 +217,9 @@ FixRigid::FixRigid(int narg, char **arg) : Fix(narg, arg)
 
 FixRigid::~FixRigid()
 {
-  // if atom class still exists:
-  //   unregister this fix so atom class doesn't invoke it any more
-  
-  if (atom) atom->delete_callback(id,0);
+  // unregister callbacks to this fix from Atom class
+
+  atom->delete_callback(id,0);
   
   // delete locally stored arrays
   
diff --git a/src/fix_rigid.h b/src/fix_rigid.h
index 51fb1044fd6c9d7be565906875d3c0ee44b0ff1c..179c38f366c509333a2fbbdf179fbb026f7f7dfa 100644
--- a/src/fix_rigid.h
+++ b/src/fix_rigid.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,9 +16,11 @@
 
 #include "fix.h"
 
+namespace LAMMPS_NS {
+
 class FixRigid : public Fix {
  public:
-  FixRigid(int, char **);
+  FixRigid(class LAMMPS *, int, char **);
   ~FixRigid();
   int setmask();
   void init();
@@ -75,4 +77,6 @@ class FixRigid : public Fix {
   void set_v(int);
 };
 
+}
+
 #endif
diff --git a/src/fix_set_force.cpp b/src/fix_set_force.cpp
index 0a1602b3777a917af538176eac1c4682251e8aae..4dddbc3b26c7be95b2d17d04f52c6a141878898b 100644
--- a/src/fix_set_force.cpp
+++ b/src/fix_set_force.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -19,9 +19,12 @@
 #include "respa.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 /* ---------------------------------------------------------------------- */
 
-FixSetForce::FixSetForce(int narg, char **arg) : Fix(narg, arg)
+FixSetForce::FixSetForce(LAMMPS *lmp, int narg, char **arg) :
+  Fix(lmp, narg, arg)
 {
   if (narg != 6) error->all("Illegal fix setforce command");
 
diff --git a/src/fix_set_force.h b/src/fix_set_force.h
index f149fe4457b1d305a0788b5773e0b5e7ae35b694..25fe322eb9c30adacf8a3a85de5b246a38c8d2bc 100644
--- a/src/fix_set_force.h
+++ b/src/fix_set_force.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,10 +16,11 @@
 
 #include "fix.h"
 
+namespace LAMMPS_NS {
+
 class FixSetForce : public Fix {
  public:
-  FixSetForce(int, char **);
-  ~FixSetForce() {}
+  FixSetForce(class LAMMPS *, int, char **);
   int setmask();
   void init();
   void setup();
@@ -34,4 +35,6 @@ class FixSetForce : public Fix {
   int nlevels_respa;
 };
 
+}
+
 #endif
diff --git a/src/fix_shake.cpp b/src/fix_shake.cpp
index f1767798a7deb22743fea7d527ab8f1157792809..e466e566ad6a3dc702e5de50ebdc521eee6c2bb6 100644
--- a/src/fix_shake.cpp
+++ b/src/fix_shake.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -31,6 +31,8 @@
 #include "memory.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define BIG 1.0e20
 #define MASSDELTA 0.1
 #define MIN(a,b) ((a) < (b) ? (a) : (b))
@@ -38,7 +40,8 @@
 
 /* ---------------------------------------------------------------------- */
 
-FixShake::FixShake(int narg, char **arg) : Fix(narg, arg)
+FixShake::FixShake(LAMMPS *lmp, int narg, char **arg) :
+  Fix(lmp, narg, arg)
 {
   MPI_Comm_rank(world,&me);
   MPI_Comm_size(world,&nprocs);
@@ -51,7 +54,7 @@ FixShake::FixShake(int narg, char **arg) : Fix(narg, arg)
     error->all("Cannot use fix shake with non-molecular system");
 
   // perform initial allocation of atom-based arrays
-  // register with atom class
+  // register with Atom class
 
   shake_flag = NULL;
   shake_atom = shake_type = NULL;
@@ -60,6 +63,10 @@ FixShake::FixShake(int narg, char **arg) : Fix(narg, arg)
   grow_arrays(atom->nmax);
   atom->add_callback(0);
 
+  // set comm size needed by this Fix
+
+  comm_forward = 3;
+
   // parse SHAKE args
 
   if (narg < 8) error->all("Illegal fix shake command");
@@ -165,44 +172,42 @@ FixShake::FixShake(int narg, char **arg) : Fix(narg, arg)
 
 FixShake::~FixShake()
 {
-  // if atom class still exists:
-  //   unregister this fix so atom class doesn't invoke it any more
-  //   set bond_type and angle_type back to positive for SHAKE clusters
-  //     must set for all SHAKE bonds and angles stored by each atom
-
-  if (atom) {
-    atom->delete_callback(id,0);
-
-    int **bond_type = atom->bond_type;
-    int **angle_type = atom->angle_type;
-    int nlocal = atom->nlocal;
-
-    int n;
-    for (int i = 0; i < nlocal; i++) {
-      if (shake_flag[i] == 0) continue;
-      else if (shake_flag[i] == 1) {
-	n = bondfind(i,shake_atom[i][0],shake_atom[i][1]);
-	if (n >= 0) bond_type[i][n] = -bond_type[i][n];
-	n = bondfind(i,shake_atom[i][0],shake_atom[i][2]);
-	if (n >= 0) bond_type[i][n] = -bond_type[i][n];
-	n = anglefind(i,shake_atom[i][1],shake_atom[i][2]);
-	if (n >= 0) angle_type[i][n] = -angle_type[i][n];
-      } else if (shake_flag[i] == 2) {
-	n = bondfind(i,shake_atom[i][0],shake_atom[i][1]);
-	if (n >= 0) bond_type[i][n] = -bond_type[i][n];
-      } else if (shake_flag[i] == 3) {
-	n = bondfind(i,shake_atom[i][0],shake_atom[i][1]);
-	if (n >= 0) bond_type[i][n] = -bond_type[i][n];
-	n = bondfind(i,shake_atom[i][0],shake_atom[i][2]);
-	if (n >= 0) bond_type[i][n] = -bond_type[i][n];
-      } else if (shake_flag[i] == 4) {
-	n = bondfind(i,shake_atom[i][0],shake_atom[i][1]);
-	if (n >= 0) bond_type[i][n] = -bond_type[i][n];
-	n = bondfind(i,shake_atom[i][0],shake_atom[i][2]);
-	if (n >= 0) bond_type[i][n] = -bond_type[i][n];
-	n = bondfind(i,shake_atom[i][0],shake_atom[i][3]);
-	if (n >= 0) bond_type[i][n] = -bond_type[i][n];
-      }
+  // unregister callbacks to this fix from Atom class
+
+  atom->delete_callback(id,0);
+
+  // set bond_type and angle_type back to positive for SHAKE clusters
+  // must set for all SHAKE bonds and angles stored by each atom
+
+  int **bond_type = atom->bond_type;
+  int **angle_type = atom->angle_type;
+  int nlocal = atom->nlocal;
+
+  int n;
+  for (int i = 0; i < nlocal; i++) {
+    if (shake_flag[i] == 0) continue;
+    else if (shake_flag[i] == 1) {
+      n = bondfind(i,shake_atom[i][0],shake_atom[i][1]);
+      if (n >= 0) bond_type[i][n] = -bond_type[i][n];
+      n = bondfind(i,shake_atom[i][0],shake_atom[i][2]);
+      if (n >= 0) bond_type[i][n] = -bond_type[i][n];
+      n = anglefind(i,shake_atom[i][1],shake_atom[i][2]);
+      if (n >= 0) angle_type[i][n] = -angle_type[i][n];
+    } else if (shake_flag[i] == 2) {
+      n = bondfind(i,shake_atom[i][0],shake_atom[i][1]);
+      if (n >= 0) bond_type[i][n] = -bond_type[i][n];
+    } else if (shake_flag[i] == 3) {
+      n = bondfind(i,shake_atom[i][0],shake_atom[i][1]);
+      if (n >= 0) bond_type[i][n] = -bond_type[i][n];
+      n = bondfind(i,shake_atom[i][0],shake_atom[i][2]);
+      if (n >= 0) bond_type[i][n] = -bond_type[i][n];
+    } else if (shake_flag[i] == 4) {
+      n = bondfind(i,shake_atom[i][0],shake_atom[i][1]);
+      if (n >= 0) bond_type[i][n] = -bond_type[i][n];
+      n = bondfind(i,shake_atom[i][0],shake_atom[i][2]);
+      if (n >= 0) bond_type[i][n] = -bond_type[i][n];
+      n = bondfind(i,shake_atom[i][0],shake_atom[i][3]);
+      if (n >= 0) bond_type[i][n] = -bond_type[i][n];
     }
   }
 
@@ -296,10 +301,6 @@ void FixShake::init()
     step_respa = ((Respa *) update->integrate)->step;
   }
 
-  // set communication size in comm class
-
-  comm->maxforward_fix = MAX(comm->maxforward_fix,3);
-
   // set equilibrium bond distances
 
   if (force->bond == NULL)
diff --git a/src/fix_shake.h b/src/fix_shake.h
index fdde440ffe74a0842d000cf9b8b7785db123070c..47cdf7be29a9148874ef3a6f9d578d6c10a5534f 100644
--- a/src/fix_shake.h
+++ b/src/fix_shake.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,9 +16,11 @@
 
 #include "fix.h"
 
+namespace LAMMPS_NS {
+
 class FixShake : public Fix {
  public:
-  FixShake(int, char **);
+  FixShake(class LAMMPS *, int, char **);
   ~FixShake();
   int setmask();
   void init();
@@ -100,4 +102,6 @@ class FixShake : public Fix {
   int anglefind(int, int, int);
 };
 
+}
+
 #endif
diff --git a/src/fix_shear_history.h b/src/fix_shear_history.h
index f9e9be0fd28f27ff8bb3b329ae904c20bfe4ef3c..7b2d7346b5cd962f9b9491ff16ae4dd5f9cd8b2c 100644
--- a/src/fix_shear_history.h
+++ b/src/fix_shear_history.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,12 +16,14 @@
 
 #include "fix.h"
 
+namespace LAMMPS_NS {
+
 class FixShearHistory : public Fix {
   friend class Neighbor;
   friend class FixPour;
 
  public:
-  FixShearHistory(int, char **);
+  FixShearHistory(class LAMMPS *, int, char **);
   ~FixShearHistory();
   int setmask();
   void init();
@@ -43,4 +45,6 @@ class FixShearHistory : public Fix {
   double ***shearpartner;       // 3 shear values with the partner
 };
 
+}
+
 #endif
diff --git a/src/fix_spring.cpp b/src/fix_spring.cpp
index fa3c15ebe19af7d61c2412c4c3e76b2768836a65..14f5f3d02dfc832e6aaf8541cdae98e5f6f985b3 100644
--- a/src/fix_spring.cpp
+++ b/src/fix_spring.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -26,12 +26,15 @@
 #include "error.h"
 #include "group.h"
 
+using namespace LAMMPS_NS;
+
 #define TETHER 0
 #define COUPLE 1
 
 /* ---------------------------------------------------------------------- */
 
-FixSpring::FixSpring(int narg, char **arg) : Fix(narg, arg)
+FixSpring::FixSpring(LAMMPS *lmp, int narg, char **arg) :
+  Fix(lmp, narg, arg)
 {
   if (narg < 9) error->all("Illegal fix spring command");
 
diff --git a/src/fix_spring.h b/src/fix_spring.h
index 18fc8dab0dddab1e65dfb8b9ef99c4b003e9e441..2c638bc2e46b74528fa488b524e22f43f7d177b8 100644
--- a/src/fix_spring.h
+++ b/src/fix_spring.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,10 +16,11 @@
 
 #include "fix.h"
 
+namespace LAMMPS_NS {
+
 class FixSpring : public Fix {
  public:
-  FixSpring(int, char **);
-  ~FixSpring() {}
+  FixSpring(class LAMMPS *, int, char **);
   int setmask();
   void init();
   void setup();
@@ -39,4 +40,6 @@ class FixSpring : public Fix {
   void spring_couple();
 };
 
+}
+
 #endif
diff --git a/src/fix_spring_rg.cpp b/src/fix_spring_rg.cpp
index 72e2dfc9b227fdb1d356306640f95f0fb178295d..0588297b7e70a2ac77066a4c2e71c415466be64b 100644
--- a/src/fix_spring_rg.cpp
+++ b/src/fix_spring_rg.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -27,9 +27,12 @@
 #include "domain.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 /* ---------------------------------------------------------------------- */
 
-FixSpringRG::FixSpringRG(int narg, char **arg) : Fix(narg, arg)
+FixSpringRG::FixSpringRG(LAMMPS *lmp, int narg, char **arg) :
+  Fix(lmp, narg, arg)
 {
   if (narg != 5) error->all("Illegal fix spring/rg command");
 
diff --git a/src/fix_spring_rg.h b/src/fix_spring_rg.h
index b4083589df6ccd4745dbf770f6c20a0eb956f114..ab91c57aa79516b9bdedff9c348665c9512f69b4 100644
--- a/src/fix_spring_rg.h
+++ b/src/fix_spring_rg.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,10 +16,11 @@
 
 #include "fix.h"
 
+namespace LAMMPS_NS {
+
 class FixSpringRG : public Fix {
  public:
-  FixSpringRG(int, char **);
-  ~FixSpringRG() {}
+  FixSpringRG(class LAMMPS *, int, char **);
   int setmask();
   void init();
   void setup();
@@ -31,4 +32,6 @@ class FixSpringRG : public Fix {
   double rg0,k,masstotal;
 };
 
+}
+
 #endif
diff --git a/src/fix_spring_self.cpp b/src/fix_spring_self.cpp
index 5259a82b6930b8283e318f2211cfe5a2e8d304ef..81041f23dfcb72d3418ede5eb1f396d29bfdc3c9 100644
--- a/src/fix_spring_self.cpp
+++ b/src/fix_spring_self.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -25,9 +25,12 @@
 #include "memory.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 /* ---------------------------------------------------------------------- */
 
-FixSpringSelf::FixSpringSelf(int narg, char **arg) : Fix(narg, arg)
+FixSpringSelf::FixSpringSelf(LAMMPS *lmp, int narg, char **arg) :
+  Fix(lmp, narg, arg)
 {
   if (narg != 4) error->all("Illegal fix spring/self command");
 
@@ -37,7 +40,7 @@ FixSpringSelf::FixSpringSelf(int narg, char **arg) : Fix(narg, arg)
   if (k <= 0.0) error->all("Illegal fix spring/self command");
 
   // perform initial allocation of atom-based array
-  // register with atom class
+  // register with Atom class
 
   xoriginal = NULL;
   grow_arrays(atom->nmax);
@@ -72,11 +75,10 @@ FixSpringSelf::FixSpringSelf(int narg, char **arg) : Fix(narg, arg)
 
 FixSpringSelf::~FixSpringSelf()
 {
-  // if atom class still exists:
-  //   unregister this fix so atom class doesn't invoke it any more
- 
-  if (atom) atom->delete_callback(id,0);
-  if (atom) atom->delete_callback(id,1);
+  // unregister callbacks to this fix from Atom class
+
+  atom->delete_callback(id,0);
+  atom->delete_callback(id,1);
 
   // delete locally stored array
 
diff --git a/src/fix_spring_self.h b/src/fix_spring_self.h
index ad590272e7d2fd8f7ffe9a0fbb857a9ca14499c5..10269e5ed5f60d5466974e5e50486a65d55f76be 100644
--- a/src/fix_spring_self.h
+++ b/src/fix_spring_self.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,9 +16,11 @@
 
 #include "fix.h"
 
+namespace LAMMPS_NS {
+
 class FixSpringSelf : public Fix {
  public:
-  FixSpringSelf(int, char **);
+  FixSpringSelf(class LAMMPS *, int, char **);
   ~FixSpringSelf();
   int setmask();
   void init();
@@ -42,4 +44,6 @@ class FixSpringSelf : public Fix {
   int nlevels_respa;
 };
 
+}
+
 #endif
diff --git a/src/fix_stress.cpp b/src/fix_stress.cpp
deleted file mode 100644
index 8549bd18a83c094ea28d58c2a36d531e8eb5c0c9..0000000000000000000000000000000000000000
--- a/src/fix_stress.cpp
+++ /dev/null
@@ -1,260 +0,0 @@
-/* ----------------------------------------------------------------------
-   LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
-
-   Copyright (2003) Sandia Corporation.  Under the terms of Contract
-   DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
-   certain rights in this software.  This software is distributed under 
-   the GNU General Public License.
-
-   See the README file in the top-level LAMMPS directory.
-------------------------------------------------------------------------- */
-
-#include "string.h"
-#include "fix_stress.h"
-#include "atom.h"
-#include "neighbor.h"
-#include "modify.h"
-#include "comm.h"
-#include "update.h"
-#include "force.h"
-#include "pair.h"
-#include "memory.h"
-#include "error.h"
-
-#define MIN(a,b) ((a) < (b) ? (a) : (b))
-#define MAX(a,b) ((a) > (b) ? (a) : (b))
-
-/* ---------------------------------------------------------------------- */
-
-FixStress::FixStress(int narg, char **arg) : Fix(narg, arg)
-{
-  if (narg != 3) error->all("Illegal fix stress command");
-
-  neigh_half_once = 1;
-  nmax = 0;
-  stress = NULL;
-}
-
-/* ---------------------------------------------------------------------- */
-
-FixStress::~FixStress()
-{
-  memory->destroy_2d_double_array(stress);
-}
-
-/* ---------------------------------------------------------------------- */
-
-int FixStress::setmask()
-{
-  int mask = 0;
-  return mask;
-}
-
-/* ---------------------------------------------------------------------- */
-
-void FixStress::init()
-{
-  if (force->pair == NULL || force->pair->single_enable == 0)
-    error->all("Pair style does not support dumping per-atom stress");
-
-  // set communication size in comm class
-
-  comm->maxreverse_fix = MAX(comm->maxreverse_fix,6);
-
-  // warn if more than one stress fix
-  
-  int count = 0;
-  for (int i = 0; i < modify->nfix; i++)
-    if (strcmp(modify->fix[i]->style,"STRESS") == 0) count++;
-  if (count > 1 && comm->me == 0)
-    error->warning("More than one dump custom with a stress attribute");
-}
-
-/* ---------------------------------------------------------------------- */
-
-void FixStress::dump()
-{
-  int i,j,k,n,itype,jtype,numneigh;
-  double xtmp,ytmp,ztmp,delx,dely,delz,rsq;
-  double factor_coul,factor_lj,fforce,rmass;
-  int *neighs;
-  Pair::One one;
-
-  // grow stress array if necessary
-
-  if (atom->nmax > nmax) {
-    memory->destroy_2d_double_array(stress);
-    nmax = atom->nmax;
-    stress = memory->create_2d_double_array(nmax,6,"stress:stress");
-  }
-
-  // clear stress array
-  // n includes ghosts only if newton_pair flag is set
-
-  if (force->newton_pair) n = atom->nlocal + atom->nghost;
-  else n = atom->nlocal;
-
-  for (i = 0; i < n; i++) {
-    stress[i][0] = 0.0;
-    stress[i][1] = 0.0;
-    stress[i][2] = 0.0;
-    stress[i][3] = 0.0;
-    stress[i][4] = 0.0;
-    stress[i][5] = 0.0;
-  }
-
-  // if needed, build a half neighbor list
-
-  if (!neighbor->half_every) neighbor->build_half();
-
-  // compute pairwise stress for all atoms via pair->single()
-  // use half neighbor list
-
-  double *special_coul = force->special_coul;
-  double *special_lj = force->special_lj;
-  double **cutsq = force->pair->cutsq;
-
-  double **x = atom->x;
-  int *type = atom->type;
-  int nlocal = atom->nlocal;
-  int nall = atom->nlocal + atom->nghost;
-
-  for (i = 0; i < nlocal; i++) {
-    xtmp = x[i][0];
-    ytmp = x[i][1];
-    ztmp = x[i][2];
-    itype = type[i];
-    neighs = neighbor->firstneigh[i];
-    numneigh = neighbor->numneigh[i];
-    
-    for (k = 0; k < numneigh; k++) {
-      j = neighs[k];
-
-      if (j < nall) factor_coul = factor_lj = 1.0;
-      else {
-	factor_coul = special_coul[j/nall];
-	factor_lj = special_lj[j/nall];
-	j %= nall;
-      }
-
-      delx = xtmp - x[j][0];
-      dely = ytmp - x[j][1];
-      delz = ztmp - x[j][2];
-      rsq = delx*delx + dely*dely + delz*delz;
-      jtype = type[j];
-
-      if (rsq < cutsq[itype][jtype]) {
-	force->pair->single(i,j,itype,jtype,rsq,factor_coul,factor_lj,0,one);
-	fforce = one.fforce;
-
-	stress[i][0] -= delx*delx*fforce;
-	stress[i][1] -= dely*dely*fforce;
-	stress[i][2] -= delz*delz*fforce;
-	stress[i][3] -= delx*dely*fforce;
-	stress[i][4] -= delx*delz*fforce;
-	stress[i][5] -= dely*delz*fforce;
-	if (force->newton_pair || j < nlocal) {
-	  stress[j][0] -= delx*delx*fforce;
-	  stress[j][1] -= dely*dely*fforce;
-	  stress[j][2] -= delz*delz*fforce;
-	  stress[j][3] -= delx*dely*fforce;
-	  stress[j][4] -= delx*delz*fforce;
-	  stress[j][5] -= dely*delz*fforce;
-	}
-      }
-    }
-  }
-
-  // communicate stress between neighbor procs
-
-  if (force->newton_pair) comm->reverse_comm_fix(this);
-
-  // remove double counting of per-atom stress
-
-  for (i = 0; i < nlocal; i++) {
-    stress[i][0] *= 0.5;
-    stress[i][1] *= 0.5;
-    stress[i][2] *= 0.5;
-    stress[i][3] *= 0.5;
-    stress[i][4] *= 0.5;
-    stress[i][5] *= 0.5;
-  }
-
-  // include kinetic energy term for each atom
-  // mvv2e converts mv^2 to energy
-
-  double **v = atom->v;
-  double *mass = atom->mass;
-  double mvv2e = force->mvv2e;
-
-  for (i = 0; i < nlocal; i++) {
-    rmass = mvv2e * mass[type[i]];
-    stress[i][0] -= rmass*v[i][0]*v[i][0];
-    stress[i][1] -= rmass*v[i][1]*v[i][1];
-    stress[i][2] -= rmass*v[i][2]*v[i][2];
-    stress[i][3] -= rmass*v[i][0]*v[i][1];
-    stress[i][4] -= rmass*v[i][0]*v[i][2];
-    stress[i][5] -= rmass*v[i][1]*v[i][2];
-  }
-
-  // convert to pressure units (actually stress/volume = pressure)
-
-  double nktv2p = force->nktv2p;
-  for (i = 0; i < nlocal; i++) {
-    stress[i][0] *= nktv2p;
-    stress[i][1] *= nktv2p;
-    stress[i][2] *= nktv2p;
-    stress[i][3] *= nktv2p;
-    stress[i][4] *= nktv2p;
-    stress[i][5] *= nktv2p;
-  }
-}
-
-/* ---------------------------------------------------------------------- */
-
-int FixStress::pack_reverse_comm(int n, int first, double *buf)
-{
-  int i,m,last;
-
-  m = 0;
-  last = first + n;
-  for (i = first; i < last; i++) {
-    buf[m++] = stress[i][0];
-    buf[m++] = stress[i][1];
-    buf[m++] = stress[i][2];
-    buf[m++] = stress[i][3];
-    buf[m++] = stress[i][4];
-    buf[m++] = stress[i][5];
-  }
-  return 6;
-}
-
-/* ---------------------------------------------------------------------- */
-
-void FixStress::unpack_reverse_comm(int n, int *list, double *buf)
-{
-  int i,j,m;
-
-  m = 0;
-  for (i = 0; i < n; i++) {
-    j = list[i];
-    stress[j][0] += buf[m++];
-    stress[j][1] += buf[m++];
-    stress[j][2] += buf[m++];
-    stress[j][3] += buf[m++];
-    stress[j][4] += buf[m++];
-    stress[j][5] += buf[m++];
-  }
-}
-
-/* ----------------------------------------------------------------------
-   memory usage of local atom-based array
-------------------------------------------------------------------------- */
-
-int FixStress::memory_usage()
-{
-  int bytes = nmax*6 * sizeof(double);
-  return bytes;
-}
diff --git a/src/fix_stress.h b/src/fix_stress.h
deleted file mode 100644
index 2e9ce043ebc05ab57e8785a912fe38fd64764b31..0000000000000000000000000000000000000000
--- a/src/fix_stress.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/* ----------------------------------------------------------------------
-   LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
-
-   Copyright (2003) Sandia Corporation.  Under the terms of Contract
-   DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
-   certain rights in this software.  This software is distributed under 
-   the GNU General Public License.
-
-   See the README file in the top-level LAMMPS directory.
-------------------------------------------------------------------------- */
-
-#ifndef FIX_STRESS_H
-#define FIX_STRESS_H
-
-#include "fix.h"
-
-class FixStress : public Fix {
-  friend class DumpCustom;
-
- public:
-  FixStress(int, char **);
-  ~FixStress();
-  int setmask();
-  void init();
-  void dump();
-  int pack_reverse_comm(int, int, double *);
-  void unpack_reverse_comm(int, int *, double *);
-  int memory_usage();
-
- private:
-  int nmax;
-  double **stress;
-};
-
-#endif
diff --git a/src/fix_temp_rescale.cpp b/src/fix_temp_rescale.cpp
index 2c6455548e3d624f0473ca45eb5557525b3ef633..65e3b2a89bf898329c7f380f62576158e1fe8af2 100644
--- a/src/fix_temp_rescale.cpp
+++ b/src/fix_temp_rescale.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -22,12 +22,16 @@
 #include "domain.h"
 #include "region.h"
 #include "comm.h"
-#include "temperature.h"
+#include "modify.h"
+#include "compute.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 /* ---------------------------------------------------------------------- */
 
-FixTempRescale::FixTempRescale(int narg, char **arg) : Fix(narg, arg)
+FixTempRescale::FixTempRescale(LAMMPS *lmp, int narg, char **arg) :
+  Fix(lmp, narg, arg)
 {
   if (narg < 8) error->all("Illegal fix temp/rescale command");
   nevery = atoi(arg[3]);
@@ -53,22 +57,37 @@ FixTempRescale::FixTempRescale(int narg, char **arg) : Fix(narg, arg)
     } else error->all("Illegal fix temp/rescale command");
   }
 
-  // create a new temperature full or region style with fix ID and fix group
+  // create a new compute temp or temp/region style
+  // id = fix-ID + temp, compute group = fix group
+
+  int n = strlen(id) + 6;
+  id_temp = new char[n];
+  strcpy(id_temp,id);
+  strcat(id_temp,"_temp");
 
   char **newarg = new char*[4];
-  newarg[0] = id;
+  newarg[0] = id_temp;
   newarg[1] = group->names[igroup];
   if (iregion == -1) {
-    newarg[2] = "full";
-    force->add_temp(3,newarg,1);
+    newarg[2] = "temp";
+    modify->add_compute(3,newarg);
   } else {
-    newarg[2] = "region";
+    newarg[2] = "temp/region";
     newarg[3] = domain->regions[iregion]->id;
-    force->add_temp(4,newarg,1);
+    modify->add_compute(4,newarg);
   }
   delete [] newarg;
+  tflag = 1;
+}
+
+/* ---------------------------------------------------------------------- */
 
-  temperature = force->find_temp(id);
+FixTempRescale::~FixTempRescale()
+{
+  // delete temperature if fix created it
+
+  if (tflag) modify->delete_compute(id_temp);
+  delete [] id_temp;
 }
 
 /* ---------------------------------------------------------------------- */
@@ -77,7 +96,7 @@ int FixTempRescale::setmask()
 {
   int mask = 0;
   mask |= END_OF_STEP;
-  mask |= THERMO;
+  mask |= THERMO_ENERGY;
   return mask;
 }
 
@@ -85,15 +104,20 @@ int FixTempRescale::setmask()
 
 void FixTempRescale::init()
 {
-  energy = 0.0;
+  int icompute = modify->find_compute(id_temp);
+  if (icompute < 0) error->all("Temp ID for fix temp/rescale does not exist");
+  temperature = modify->compute[icompute];
+
+  temperature->init();              // not yet called by Modify::init()
   efactor = (0.5 * force->boltz * temperature->dof);
+  energy = 0.0;
 }
 
 /* ---------------------------------------------------------------------- */
 
 void FixTempRescale::end_of_step()
 {
-  double t_current = temperature->compute();
+  double t_current = temperature->compute_scalar();
   double delta = update->ntimestep - update->beginstep;
   delta /= update->endstep - update->beginstep;
   double t_target = t_start + delta * (t_end-t_start);
@@ -138,14 +162,23 @@ int FixTempRescale::modify_param(int narg, char **arg)
 {
   if (strcmp(arg[0],"temp") == 0) {
     if (narg < 2) error->all("Illegal fix_modify command");
-    temperature = force->find_temp(arg[1]);
-    if (temperature == NULL)
-      error->all("Could not find fix_modify temperature ID");
+    if (tflag) {
+      modify->delete_compute(id_temp);
+      tflag = 0;
+    }
+    delete [] id_temp;
+    int n = strlen(arg[1]) + 1;
+    id_temp = new char[n];
+    strcpy(id_temp,arg[1]);
+
+    int icompute = modify->find_compute(id_temp);
+    if (icompute < 0) error->all("Could not find fix_modify temp ID");
+    temperature = modify->compute[icompute];
+
+    if (temperature->tempflag == 0)
+      error->all("Fix_modify temp ID does not compute temperature");
     if (temperature->igroup != igroup && comm->me == 0)
       error->warning("Group for fix_modify temp != fix group");
-    if (strcmp(temperature->style,"region") == 0 && iregion == -1 && 
-	comm->me == 0)
-      error->warning("Temperature for temp/rescale is style region");
     return 2;
   }
   return 0;
@@ -153,18 +186,8 @@ int FixTempRescale::modify_param(int narg, char **arg)
 
 /* ---------------------------------------------------------------------- */
 
-int FixTempRescale::thermo_fields(int n, int *flags, char **keywords)
-{
-  if (n == 0) return 1;
-  flags[0] = 3;
-  strcpy(keywords[0],"EngTRscl");
-  return 1;
-}
-
-/* ---------------------------------------------------------------------- */
-
-int FixTempRescale::thermo_compute(double *values)
+double FixTempRescale::thermo(int n)
 {
-  values[0] = energy;
-  return 1;
+  if (n == 0) return energy;
+  else return 0.0;
 }
diff --git a/src/fix_temp_rescale.h b/src/fix_temp_rescale.h
index 2dd21ff0a42138021112edb2b8fe0d118be4e7eb..01531f9f191d7f9d0be6ab36f05036300793dc76 100644
--- a/src/fix_temp_rescale.h
+++ b/src/fix_temp_rescale.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,24 +16,28 @@
 
 #include "fix.h"
 
-class Temperature;
+namespace LAMMPS_NS {
 
 class FixTempRescale : public Fix {
  public:
-  FixTempRescale(int, char **);
-  ~FixTempRescale() {}
+  FixTempRescale(class LAMMPS *, int, char **);
+  ~FixTempRescale();
   int setmask();
   void init();
   void end_of_step();
+  double thermo(int);
   int modify_param(int, char **);
-  int thermo_fields(int, int *, char **);
-  int thermo_compute(double *);
 
  private:
   int iregion;
   double t_start,t_end,t_window;
   double fraction,energy,efactor;
-  Temperature *temperature;
+
+  char *id_temp;
+  class Compute *temperature;
+  int tflag;
 };
 
+}
+
 #endif
diff --git a/src/fix_tmd.cpp b/src/fix_tmd.cpp
index 388d75e53262880c91e8e51658524fd8c71c655a..b8f5cab7c158667a2bfb221bd27905808d42fefe 100644
--- a/src/fix_tmd.cpp
+++ b/src/fix_tmd.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -31,12 +31,15 @@
 #include "memory.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define CHUNK 1000
 #define MAXLINE 256
 
 /* ---------------------------------------------------------------------- */
 
-FixTMD::FixTMD(int narg, char **arg) : Fix(narg, arg)
+FixTMD::FixTMD(LAMMPS *lmp, int narg, char **arg) :
+  Fix(lmp, narg, arg)
 {
   if (narg < 6) error->all("Illegal fix tmd command");
 
@@ -48,7 +51,7 @@ FixTMD::FixTMD(int narg, char **arg) : Fix(narg, arg)
   MPI_Comm_rank(world,&me);
 
   // perform initial allocation of atom-based arrays
-  // register with atom class
+  // register with Atom class
 
   xf = NULL;
   xold = NULL;
@@ -126,10 +129,9 @@ FixTMD::~FixTMD()
 {
   if (nfileevery && me == 0) fclose(fp);
 
-  // if atom class still exists:
-  //   unregister this fix so atom class doesn't invoke it any more
- 
-  if (atom) atom->delete_callback(id,0);
+  // unregister callbacks to this fix from Atom class
+
+  atom->delete_callback(id,0);
 
   // delete locally stored arrays
 
diff --git a/src/fix_tmd.h b/src/fix_tmd.h
index adf140a0067aea4344f0ac6aada459f2c70dcc36..f0e41e1397d089bc41e91f083f1e75734588b08e 100644
--- a/src/fix_tmd.h
+++ b/src/fix_tmd.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -17,9 +17,11 @@
 #include "stdio.h"
 #include "fix.h"
 
+namespace LAMMPS_NS {
+
 class FixTMD : public Fix {
  public:
-  FixTMD(int, char **);
+  FixTMD(class LAMMPS *, int, char **);
   ~FixTMD();
   int setmask();
   void init();
@@ -45,4 +47,6 @@ class FixTMD : public Fix {
   void open(char *);
 };
 
+}
+
 #endif
diff --git a/src/fix_uniaxial.cpp b/src/fix_uniaxial.cpp
index b51c1a351e1cf44ecfa607eab5fdde171e0c4ae4..a63a136b1754c581b474662bfb63e3d120950ea3 100644
--- a/src/fix_uniaxial.cpp
+++ b/src/fix_uniaxial.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -29,9 +29,12 @@
 #include "kspace.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 /* ---------------------------------------------------------------------- */
 
-FixUniaxial::FixUniaxial(int narg, char **arg) : Fix(narg, arg)
+FixUniaxial::FixUniaxial(LAMMPS *lmp, int narg, char **arg) :
+  Fix(lmp, narg, arg)
 {
   if (narg != 6) error->all("Illegal fix uniaxial command");
   nevery = atoi(arg[3]);
diff --git a/src/fix_uniaxial.h b/src/fix_uniaxial.h
index 156d3568044980f309e39ea64dfabb102ca3e909..c06f5add4beaf4c08433e592c94313e81474326b 100644
--- a/src/fix_uniaxial.h
+++ b/src/fix_uniaxial.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,9 +16,11 @@
 
 #include "fix.h"
 
+namespace LAMMPS_NS {
+
 class FixUniaxial : public Fix {
  public:
-  FixUniaxial(int, char **);
+  FixUniaxial(class LAMMPS *, int, char **);
   ~FixUniaxial();
   int setmask();
   void init();
@@ -44,4 +46,6 @@ class FixUniaxial : public Fix {
 
 #endif
 
+}
+
 
diff --git a/src/fix_viscous.cpp b/src/fix_viscous.cpp
index 4c676dd1c336b480fcd5089bc4689946f41106af..8fdbb0da89202f8eab16a5c3411f7b893cc2ce68 100644
--- a/src/fix_viscous.cpp
+++ b/src/fix_viscous.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -20,9 +20,12 @@
 #include "respa.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 /* ---------------------------------------------------------------------- */
 
-FixViscous::FixViscous(int narg, char **arg) : Fix(narg, arg)
+FixViscous::FixViscous(LAMMPS *lmp, int narg, char **arg) :
+  Fix(lmp, narg, arg)
 {
   if (narg < 4) error->all("Illegal fix viscous command");
 
diff --git a/src/fix_viscous.h b/src/fix_viscous.h
index c6a63a8cd2221ac91b4dacef4833dffaa13cd838..a682c99bdebe22b0c7880e2d53f7e575858bc4cf 100644
--- a/src/fix_viscous.h
+++ b/src/fix_viscous.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,9 +16,11 @@
 
 #include "fix.h"
 
+namespace LAMMPS_NS {
+
 class FixViscous : public Fix {
  public:
-  FixViscous(int, char **);
+  FixViscous(class LAMMPS *, int, char **);
   ~FixViscous();
   int setmask();
   void init();
@@ -31,4 +33,6 @@ class FixViscous : public Fix {
   int nlevels_respa;
 };
 
+}
+
 #endif
diff --git a/src/fix_volume_rescale.cpp b/src/fix_volume_rescale.cpp
index d2dc96013b8752ad9d2299c9edbb307d60bf638e..78ece5b58ba36c4b51e7e590d23feb611ed45a9a 100644
--- a/src/fix_volume_rescale.cpp
+++ b/src/fix_volume_rescale.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -23,9 +23,12 @@
 #include "atom.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 /* ---------------------------------------------------------------------- */
 
-FixVolRescale::FixVolRescale(int narg, char **arg) : Fix(narg, arg)
+FixVolRescale::FixVolRescale(LAMMPS *lmp, int narg, char **arg) :
+  Fix(lmp, narg, arg)
 {
   if (narg < 7) error->all("Illegal fix volume/rescale command");
   nevery = atoi(arg[3]);
diff --git a/src/fix_volume_rescale.h b/src/fix_volume_rescale.h
index 7714fdac1b24a907d28d7e82fe9fecd8d9b2a234..d19fe080744f7abaa269c53989a5ca754ff7e506 100644
--- a/src/fix_volume_rescale.h
+++ b/src/fix_volume_rescale.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,9 +16,11 @@
 
 #include "fix.h"
 
+namespace LAMMPS_NS {
+
 class FixVolRescale : public Fix {
  public:
-  FixVolRescale(int, char **);
+  FixVolRescale(class LAMMPS *, int, char **);
   ~FixVolRescale();
   int setmask();
   void init();
@@ -34,4 +36,6 @@ class FixVolRescale : public Fix {
   int *rfix;                       // indices of rigid fixes
 };
 
+}
+
 #endif
diff --git a/src/fix_wall_lj126.cpp b/src/fix_wall_lj126.cpp
index 2b7f90685914f4cbc23a6ef1e92a27e0b269b94b..6ef6e151910ff7e00b1fdd9e1c610b0a6f356553 100644
--- a/src/fix_wall_lj126.cpp
+++ b/src/fix_wall_lj126.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -25,9 +25,12 @@
 #include "respa.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 /* ---------------------------------------------------------------------- */
 
-FixWallLJ126::FixWallLJ126(int narg, char **arg) : Fix(narg, arg)
+FixWallLJ126::FixWallLJ126(LAMMPS *lmp, int narg, char **arg) :
+  Fix(lmp, narg, arg)
 {
   if (narg != 8) error->all("Illegal fix wall/lj126 command");
 
@@ -72,7 +75,7 @@ int FixWallLJ126::setmask()
 {
   int mask = 0;
   mask |= POST_FORCE;
-  mask |= THERMO;
+  mask |= THERMO_ENERGY;
   mask |= POST_FORCE_RESPA;
   mask |= MIN_POST_FORCE;
   return mask;
@@ -84,16 +87,13 @@ void FixWallLJ126::init()
 {
   if (strcmp(update->integrate_style,"respa") == 0)
     nlevels_respa = ((Respa *) update->integrate)->nlevels;
-
-  if (thermo_print || thermo_energy) thermo_flag = 1;
-  else thermo_flag = 0;
 }
 
 /* ---------------------------------------------------------------------- */
 
 void FixWallLJ126::setup()
 {
-  eflag_on = 1;
+  eflag_enable = 1;
   if (strcmp(update->integrate_style,"verlet") == 0)
     post_force(1);
   else {
@@ -101,14 +101,14 @@ void FixWallLJ126::setup()
     post_force_respa(1,nlevels_respa-1,0);
     ((Respa *) update->integrate)->copy_f_flevel(nlevels_respa-1);
   }
-  eflag_on = 0;
+  eflag_enable = 0;
 }
 
 /* ---------------------------------------------------------------------- */
 
 void FixWallLJ126::min_setup()
 {
-  eflag_on = 1;
+  eflag_enable = 1;
   post_force(1);
 }
 
@@ -117,17 +117,15 @@ void FixWallLJ126::min_setup()
 void FixWallLJ126::post_force(int vflag)
 {
   bool eflag = false;
-  if (thermo_flag) {
-    if (eflag_on) eflag = true;
-    else if (output->next_thermo == update->ntimestep) eflag = true;
-  }
+  if (eflag_enable) eflag = true;
+  else if (output->next_thermo == update->ntimestep) eflag = true;
 
   double **x = atom->x;
   double **f = atom->f;
   int *mask = atom->mask;
   int nlocal = atom->nlocal;
 
-  double delta,rinv,r2inv,r6inv;
+  double delta,rinv,r2inv,r6inv,eng;
   if (eflag) eng = 0.0;
 
   for (int i = 0; i < nlocal; i++)
@@ -162,18 +160,8 @@ void FixWallLJ126::min_post_force(int vflag)
 
 /* ---------------------------------------------------------------------- */
 
-int FixWallLJ126::thermo_fields(int n, int *flags, char **keywords)
-{
-  if (n == 0) return 1;
-  flags[0] = 3;
-  strcpy(keywords[0],"Wall");
-  return 1;
-}
-
-/* ---------------------------------------------------------------------- */
-
-int FixWallLJ126::thermo_compute(double *values)
+double FixWallLJ126::thermo(int n)
 {
-  values[0] = etotal;
-  return 1;
+  if (n == 0) return etotal;
+  else return 0.0;
 }
diff --git a/src/fix_wall_lj126.h b/src/fix_wall_lj126.h
index 490fd0a966ae5fa79bf3425fa4ee5aa09229abe6..e5087f2d8627e7e402a327593d6ea43450486da4 100644
--- a/src/fix_wall_lj126.h
+++ b/src/fix_wall_lj126.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,10 +16,11 @@
 
 #include "fix.h"
 
+namespace LAMMPS_NS {
+
 class FixWallLJ126 : public Fix {
  public:
-  FixWallLJ126(int, char **);
-  ~FixWallLJ126() {}
+  FixWallLJ126(class LAMMPS *, int, char **);
   int setmask();
   void init();
   void setup();
@@ -27,17 +28,17 @@ class FixWallLJ126 : public Fix {
   void post_force(int);
   void post_force_respa(int, int, int);
   void min_post_force(int);
-
-  int thermo_fields(int, int *, char **);
-  int thermo_compute(double *);
+  double thermo(int);
 
  private:
-  int dim,side,thermo_flag,eflag_on;
+  int dim,side,thermo_flag,eflag_enable;
   double coord,epsilon,sigma,cutoff;
   double coeff1,coeff2,coeff3,coeff4,offset;
-  double eng,etotal;
+  double etotal;
   int nlevels_respa;
 };
 
 #endif
+}
+
 
diff --git a/src/fix_wall_lj93.cpp b/src/fix_wall_lj93.cpp
index 7677403c0e2cdb45316829c1685188122fa60daa..fa9099ca001b597be3ee2f5327006b2b7b10ecf9 100644
--- a/src/fix_wall_lj93.cpp
+++ b/src/fix_wall_lj93.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -21,9 +21,12 @@
 #include "respa.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 /* ---------------------------------------------------------------------- */
 
-FixWallLJ93::FixWallLJ93(int narg, char **arg) : Fix(narg, arg)
+FixWallLJ93::FixWallLJ93(LAMMPS *lmp, int narg, char **arg) :
+  Fix(lmp, narg, arg)
 {
   if (narg != 8) error->all("Illegal fix wall/lj93 command");
 
@@ -60,7 +63,6 @@ FixWallLJ93::FixWallLJ93(int narg, char **arg) : Fix(narg, arg)
   double rinv = 1.0/cutoff;
   double r2inv = rinv*rinv;
   double r4inv = r2inv*r2inv;
-  double r10inv = r4inv*r4inv*r2inv;
   offset = coeff3*r4inv*r4inv*rinv - coeff4*r2inv*rinv;
 }
 
@@ -70,7 +72,7 @@ int FixWallLJ93::setmask()
 {
   int mask = 0;
   mask |= POST_FORCE;
-  mask |= THERMO;
+  mask |= THERMO_ENERGY;
   mask |= POST_FORCE_RESPA;
   mask |= MIN_POST_FORCE;
   return mask;
@@ -82,16 +84,13 @@ void FixWallLJ93::init()
 {
   if (strcmp(update->integrate_style,"respa") == 0)
     nlevels_respa = ((Respa *) update->integrate)->nlevels;
-
-  if (thermo_print || thermo_energy) thermo_flag = 1;
-  else thermo_flag = 0;
 }
 
 /* ---------------------------------------------------------------------- */
 
 void FixWallLJ93::setup()
 {
-  eflag_on = 1;
+  eflag_enable = 1;
   if (strcmp(update->integrate_style,"verlet") == 0)
     post_force(1);
   else {
@@ -99,14 +98,14 @@ void FixWallLJ93::setup()
     post_force_respa(1,nlevels_respa-1,0);
     ((Respa *) update->integrate)->copy_f_flevel(nlevels_respa-1);
   }
-  eflag_on = 0;
+  eflag_enable = 0;
 }
 
 /* ---------------------------------------------------------------------- */
 
 void FixWallLJ93::min_setup()
 {
-  eflag_on = 1;
+  eflag_enable = 1;
   post_force(1);
 }
 
@@ -115,17 +114,15 @@ void FixWallLJ93::min_setup()
 void FixWallLJ93::post_force(int vflag)
 {
   bool eflag = false;
-  if (thermo_flag) {
-    if (eflag_on) eflag = true;
-    else if (output->next_thermo == update->ntimestep) eflag = true;
-  }
+  if (eflag_enable) eflag = true;
+  else if (output->next_thermo == update->ntimestep) eflag = true;
 
   double **x = atom->x;
   double **f = atom->f;
   int *mask = atom->mask;
   int nlocal = atom->nlocal;
 
-  double delta,rinv,r2inv,r4inv,r10inv;
+  double delta,rinv,r2inv,r4inv,r10inv,eng;
   if (eflag) eng = 0.0;
 
   for (int i = 0; i < nlocal; i++)
@@ -161,18 +158,8 @@ void FixWallLJ93::min_post_force(int vflag)
 
 /* ---------------------------------------------------------------------- */
 
-int FixWallLJ93::thermo_fields(int n, int *flags, char **keywords)
-{
-  if (n == 0) return 1;
-  flags[0] = 3;
-  strcpy(keywords[0],"Wall");
-  return 1;
-}
-
-/* ---------------------------------------------------------------------- */
-
-int FixWallLJ93::thermo_compute(double *values)
+double FixWallLJ93::thermo(int n)
 {
-  values[0] = etotal;
-  return 1;
+  if (n == 0) return etotal;
+  else return 0.0;
 }
diff --git a/src/fix_wall_lj93.h b/src/fix_wall_lj93.h
index 2febca5d0c66a7bc1a6ddd263191a0fc8aad57f3..ae846ba6d0120051c44a98c3642d20be0063f11a 100644
--- a/src/fix_wall_lj93.h
+++ b/src/fix_wall_lj93.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,9 +16,11 @@
 
 #include "fix.h"
 
+namespace LAMMPS_NS {
+
 class FixWallLJ93 : public Fix {
  public:
-  FixWallLJ93(int, char **);
+  FixWallLJ93(class LAMMPS *, int, char **);
   ~FixWallLJ93() {}
   int setmask();
   void init();
@@ -27,15 +29,16 @@ class FixWallLJ93 : public Fix {
   void post_force(int);
   void post_force_respa(int, int, int);
   void min_post_force(int);
-  int thermo_fields(int, int *, char **);
-  int thermo_compute(double *);
+  double thermo(int);
 
  private:
-  int dim,side,thermo_flag,eflag_on;
+  int dim,side,thermo_flag,eflag_enable;
   double coord,epsilon,sigma,cutoff;
   double coeff1,coeff2,coeff3,coeff4,offset;
-  double eng,etotal;
+  double etotal;
   int nlevels_respa;
 };
 
+}
+
 #endif
diff --git a/src/fix_wall_reflect.cpp b/src/fix_wall_reflect.cpp
index e0ad276ea3ec87489a6ba266b97d160c2b4fcdfe..0479a6f4e45ff0f3ace3e5785980004e184db5c6 100644
--- a/src/fix_wall_reflect.cpp
+++ b/src/fix_wall_reflect.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -17,9 +17,12 @@
 #include "domain.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 /* ---------------------------------------------------------------------- */
 
-FixWallReflect::FixWallReflect(int narg, char **arg) : Fix(narg, arg)
+FixWallReflect::FixWallReflect(LAMMPS *lmp, int narg, char **arg) :
+  Fix(lmp, narg, arg)
 {
   if (narg < 4) error->all("Illegal fix wall/reflect command");
 
diff --git a/src/fix_wall_reflect.h b/src/fix_wall_reflect.h
index a1aa3961a51fef0cb7be81164b3ddaab7ff412e6..7e7a80ab88400a8d1c49e0896a95ba6ae148c9d9 100644
--- a/src/fix_wall_reflect.h
+++ b/src/fix_wall_reflect.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,10 +16,11 @@
 
 #include "fix.h"
 
+namespace LAMMPS_NS {
+
 class FixWallReflect : public Fix {
  public:
-  FixWallReflect(int, char **);
-  ~FixWallReflect() {}
+  FixWallReflect(class LAMMPS *, int, char **);
   int setmask();
   void initial_integrate();
 
@@ -27,4 +28,6 @@ class FixWallReflect : public Fix {
   int xloflag,xhiflag,yloflag,yhiflag,zloflag,zhiflag;
 };
 
+}
+
 #endif
diff --git a/src/fix_wiggle.cpp b/src/fix_wiggle.cpp
index d2e95f7f283d5cd98f0848a86589e5547bce3ca3..24b2491f18ddc6f0fd2d97c1ce87998c876dcf30 100644
--- a/src/fix_wiggle.cpp
+++ b/src/fix_wiggle.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -21,9 +21,12 @@
 #include "memory.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 /* ---------------------------------------------------------------------- */
 
-FixWiggle::FixWiggle(int narg, char **arg) : Fix(narg, arg)
+FixWiggle::FixWiggle(LAMMPS *lmp, int narg, char **arg) :
+  Fix(lmp, narg, arg)
 {
   if (narg != 6) error->all("Illegal fix wiggle command");
 
@@ -38,7 +41,7 @@ FixWiggle::FixWiggle(int narg, char **arg) : Fix(narg, arg)
   period = atof(arg[5]);
 
   // perform initial allocation of atom-based array
-  // register with atom class
+  // register with Atom class
   
   original = NULL;
   grow_arrays(atom->nmax);
@@ -65,10 +68,9 @@ FixWiggle::FixWiggle(int narg, char **arg) : Fix(narg, arg)
 
 FixWiggle::~FixWiggle()
 {
-  // if atom class still exists:
-  //   unregister this fix so atom class doesn't invoke it any more
+  // unregister callbacks to this fix from Atom class
 
-  if (atom) atom->delete_callback(id,0);
+  atom->delete_callback(id,0);
 
   // delete locally stored array
 
diff --git a/src/fix_wiggle.h b/src/fix_wiggle.h
index 09ead6223962d2ace3d49d5a4b16724f6413d741..21b74f5613bbc90b9c17b668cb906fd5feb9f041 100644
--- a/src/fix_wiggle.h
+++ b/src/fix_wiggle.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,9 +16,11 @@
 
 #include "fix.h"
 
+namespace LAMMPS_NS {
+
 class FixWiggle : public Fix {
  public:
-  FixWiggle(int, char **);
+  FixWiggle(class LAMMPS *, int, char **);
   ~FixWiggle();
   int setmask();
   void init();
@@ -39,4 +41,6 @@ class FixWiggle : public Fix {
   int nlevels_respa;
 };
 
+}
+
 #endif
diff --git a/src/force.cpp b/src/force.cpp
index 2f7e7edc6ae1d83f04efa93e191c1146863a4742..e6219464809fa78628524be0571eac6dbc0e288a 100644
--- a/src/force.cpp
+++ b/src/force.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -24,8 +24,6 @@
 #include "dihedral.h"
 #include "improper.h"
 #include "kspace.h"
-#include "temperature.h"
-#include "pressure.h"
 #include "group.h"
 #include "memory.h"
 #include "error.h"
@@ -36,7 +34,6 @@
 #define ImproperInclude
 #define PairInclude
 #define KSpaceInclude
-#define TempInclude
 #include "style.h"
 #undef BondInclude
 #undef AngleInclude
@@ -44,16 +41,15 @@
 #undef ImproperInclude
 #undef PairInclude
 #undef KSpaceInclude
-#undef TempInclude
+
+using namespace LAMMPS_NS;
 
 #define MIN(a,b) ((a) < (b) ? (a) : (b))
 #define MAX(a,b) ((a) > (b) ? (a) : (b))
 
-#define DELTA 1
-
 /* ---------------------------------------------------------------------- */
 
-Force::Force()
+Force::Force(LAMMPS *lmp) : Pointers(lmp)
 {
   dimension = 3;
   newton = newton_pair = newton_bond = 1;
@@ -84,20 +80,6 @@ Force::Force()
   strcpy(improper_style,str);
   kspace_style = new char[n];
   strcpy(kspace_style,str);
-
-  // default temperature = group all and style full
-
-  ntemp = maxtemp = 0;
-  templist = NULL;
-
-  char **arg = new char*[3];
-  arg[0] = "default";
-  arg[1] = "all";
-  arg[2] = "full";
-  add_temp(3,arg,0);
-  delete [] arg;
-
-  pressure = new Pressure;
 }
 
 /* ---------------------------------------------------------------------- */
@@ -117,10 +99,6 @@ Force::~Force()
   if (dihedral) delete dihedral;
   if (improper) delete improper;
   if (kspace) delete kspace;
-
-  for (int i = 0; i < ntemp; i++) delete templist[i];
-  memory->sfree(templist);
-  delete pressure;
 }
 
 /* ---------------------------------------------------------------------- */
@@ -137,9 +115,6 @@ void Force::init()
   if (angle) angle->init();
   if (dihedral) dihedral->init();
   if (improper) improper->init();
-
-  for (int itemp = 0; itemp < ntemp; itemp++) templist[itemp]->init();
-  pressure->init();
 }
 
 /* ----------------------------------------------------------------------
@@ -167,7 +142,7 @@ Pair *Force::new_pair(char *style)
 
 #define PairClass
 #define PairStyle(key,Class) \
-  else if (strcmp(style,#key) == 0) return new Class();
+  else if (strcmp(style,#key) == 0) return new Class(lmp);
 #include "style.h"
 #undef PairClass
 
@@ -176,16 +151,18 @@ Pair *Force::new_pair(char *style)
 }
 
 /* ----------------------------------------------------------------------
-   return ptr to current pair class or hybrid sub-class if matches style
+   return ptr to current pair class or hybrid sub-class if it contains word
+   else return NULL
 ------------------------------------------------------------------------- */
 
-Pair *Force::pair_match(char *style)
+Pair *Force::pair_match(char *word)
 {
-  if (strcmp(pair_style,style) == 0) return pair;
+  if (strstr(pair_style,word) == 0) return pair;
   else if (strcmp(pair_style,"hybrid") == 0) {
-    PairHybrid *hpair = (PairHybrid *) pair;
-    for (int i = 0; i < hpair->nstyles; i++)
-      if (strcmp(hpair->keywords[i],style) == 0) return hpair->styles[i];
+    PairHybrid *pair_hybrid = (PairHybrid *) pair;
+    for (int i = 0; i < pair_hybrid->nstyles; i++)
+      if (strstr(pair_hybrid->keywords[i],word) == 0)
+	return pair_hybrid->styles[i];
   }
   return NULL;
 }
@@ -215,7 +192,7 @@ Bond *Force::new_bond(char *style)
 
 #define BondClass
 #define BondStyle(key,Class) \
-  else if (strcmp(style,#key) == 0) return new Class();
+  else if (strcmp(style,#key) == 0) return new Class(lmp);
 #include "style.h"
 #undef BondClass
 
@@ -263,7 +240,7 @@ Angle *Force::new_angle(char *style)
 
 #define AngleClass
 #define AngleStyle(key,Class) \
-  else if (strcmp(style,#key) == 0) return new Class();
+  else if (strcmp(style,#key) == 0) return new Class(lmp);
 #include "style.h"
 #undef AngleClass
 
@@ -296,7 +273,7 @@ Dihedral *Force::new_dihedral(char *style)
 
 #define DihedralClass
 #define DihedralStyle(key,Class) \
-  else if (strcmp(style,#key) == 0) return new Class();
+  else if (strcmp(style,#key) == 0) return new Class(lmp);
 #include "style.h"
 #undef DihedralClass
 
@@ -329,7 +306,7 @@ Improper *Force::new_improper(char *style)
 
 #define ImproperClass
 #define ImproperStyle(key,Class) \
-  else if (strcmp(style,#key) == 0) return new Class();
+  else if (strcmp(style,#key) == 0) return new Class(lmp);
 #include "style.h"
 #undef ImproperClass
 
@@ -350,7 +327,7 @@ void Force::create_kspace(int narg, char **arg)
 
 #define KSpaceClass
 #define KSpaceStyle(key,Class) \
-  else if (strcmp(arg[0],#key) == 0) kspace = new Class(narg-1,&arg[1]);
+  else if (strcmp(arg[0],#key) == 0) kspace = new Class(lmp,narg-1,&arg[1]);
 #include "style.h"
 #undef KSpaceClass
 
@@ -397,88 +374,6 @@ void Force::set_special(int narg, char **arg)
   } else error->all("Illegal special_bonds command");
 }
 
-/* ----------------------------------------------------------------------
-   create a new temperature
-   called from input script or fixes that create temperature
-   if flag, then allow overwrite of existing temperature with same ID
-------------------------------------------------------------------------- */
-
-void Force::add_temp(int narg, char **arg, int flag)
-{
-  if (narg < 3) error->all("Illegal temperature command");
-
-  // error checks
-
-  int itemp;
-  for (itemp = 0; itemp < ntemp; itemp++)
-    if (strcmp(arg[0],templist[itemp]->id) == 0) break;
-  if (flag == 0 && itemp < ntemp) error->all("Reuse of temperature ID");
-
-  int igroup = group->find(arg[1]);
-  if (igroup == -1) error->all("Could not find temperature group ID");
-
-  // if resetting existing temperature, delete it first
-
-  int newflag = 1;
-  if (itemp < ntemp) {
-    newflag = 0;
-    delete templist[itemp];
-  }
-
-  // extend Temperature list if necessary
-
-  if (itemp == maxtemp) {
-    maxtemp += DELTA;
-    templist = (Temperature **) 
-      memory->srealloc(templist,maxtemp*sizeof(Temperature *),
-		       "modify:templist");
-  }
-
-  // create the Temperature class
-
-  if (0) return;         // dummy line to enable else-if macro expansion
-
-#define TempClass
-#define TempStyle(key,Class) \
-  else if (strcmp(arg[2],#key) == 0) templist[itemp] = new Class(narg,arg);
-#include "style.h"
-#undef TempClass
-
-  else error->all("Invalid temperature style");
-
-  if (newflag) ntemp++;
-}
-
-/* ----------------------------------------------------------------------
-   return ptr to temperature that matches ID
-   else return NULL
-------------------------------------------------------------------------- */
-
-Temperature *Force::find_temp(char *id)
-{
-  for (int itemp = 0; itemp < ntemp; itemp++)
-    if (strcmp(id,templist[itemp]->id) == 0) return templist[itemp];
-  return NULL;
-}
-
-/* ----------------------------------------------------------------------
-   modify temperature parameters
-------------------------------------------------------------------------- */
-
-void Force::modify_temp(int narg, char **arg)
-{
-  if (narg < 2) error->all("Illegal temperature_modify command");
-
-  // lookup Temperature ID
-
-  int itemp;
-  for (itemp = 0; itemp < ntemp; itemp++)
-    if (strcmp(arg[0],templist[itemp]->id) == 0) break;
-  if (itemp == ntemp) error->all("Could not find temp_modify ID");
-  
-  templist[itemp]->modify_params(narg-1,&arg[1]);
-}
-
 /* ----------------------------------------------------------------------
    compute bounds implied by numeric str with a possible wildcard asterik
    nmax = upper bound
diff --git a/src/force.h b/src/force.h
index 0e6127ba266900c2dfe8ef00c7681d2c350a8e6a..14008b0a0d70f51bac5b2ebaaa7e5b54e9ab75c9 100644
--- a/src/force.h
+++ b/src/force.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -14,18 +14,11 @@
 #ifndef FORCE_H
 #define FORCE_H
 
-#include "lammps.h"
+#include "pointers.h"
 
-class Pair;
-class Bond;
-class Angle;
-class Dihedral;
-class Improper;
-class KSpace;
-class Temperature;
-class Pressure;
+namespace LAMMPS_NS {
 
-class Force : public LAMMPS {
+class Force : protected Pointers {
  public:
   double boltz;                      // Boltzmann constant (eng/degree-K)
   double mvv2e;                      // conversion of mv^2 to energy
@@ -39,34 +32,28 @@ class Force : public LAMMPS {
   int dimension;                        // 2 = 2d, 3 = 3d
   int newton,newton_pair,newton_bond;   // Newton's 3rd law settings
 
-  Pair *pair;
+  class Pair *pair;
   char *pair_style;
 
-  Bond *bond;
+  class Bond *bond;
   char *bond_style;
 
-  Angle *angle;
+  class Angle *angle;
   char *angle_style;
 
-  Dihedral *dihedral;
+  class Dihedral *dihedral;
   char *dihedral_style;
 
-  Improper *improper;
+  class Improper *improper;
   char *improper_style;
 
-  KSpace *kspace;
+  class KSpace *kspace;
   char *kspace_style;
                              // index [0] is not used in these arrays
   double special_lj[4];      // 1-2, 1-3, 1-4 prefactors for LJ
   double special_coul[4];    // 1-2, 1-3, 1-4 prefactors for Coulombics
 
-  int ntemp;                   // # of defined Temperatures
-  int maxtemp;                 // max number list can hold
-  Temperature **templist;      // list of defined Temperatures
-
-  Pressure *pressure;          // single defined Pressure
-
-  Force();
+  Force(class LAMMPS *);
   ~Force();
   void init();
 
@@ -90,11 +77,10 @@ class Force : public LAMMPS {
   void create_kspace(int, char **);
 
   void set_special(int, char **);
-  void add_temp(int, char **, int);
-  Temperature *find_temp(char *);
-  void modify_temp(int, char **);
   void bounds(char *, int, int &, int &);
   int memory_usage();
 };
 
+}
+
 #endif
diff --git a/src/group.cpp b/src/group.cpp
index 6850f5b91d721c359821de612f8c30a2e2329f8e..2f1059351b954a87cef911bc1d8b17c6a595348d 100644
--- a/src/group.cpp
+++ b/src/group.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -18,10 +18,13 @@
 #include "stdlib.h"
 #include "group.h"
 #include "domain.h"
+#include "atom.h"
+#include "atom_vec_hybrid.h"
 #include "region.h"
 #include "memory.h"
 #include "error.h"
-#include "atom.h"
+
+using namespace LAMMPS_NS;
 
 #define MAX_GROUP 32
 
@@ -44,7 +47,7 @@
    initialize group memory
 ------------------------------------------------------------------------- */
 
-Group::Group()
+Group::Group(LAMMPS *lmp) : Pointers(lmp)
 {
   MPI_Comm_rank(world,&me);
 
@@ -124,7 +127,29 @@ void Group::assign(int narg, char **arg)
       if (domain->regions[iregion]->match(x[i][0],x[i][1],x[i][2]))
 	mask[i] |= bit;
 
-    // style = logical condition
+  // style = hybrid
+
+  } else if (strcmp(arg[1],"hybrid") == 0) {
+
+    if (narg != 3) error->all("Illegal group command");
+    if (strcmp(atom->atom_style,"hybrid") != 0)
+      error->all("Group hybrid command requires atom style hybrid");
+    
+    AtomVecHybrid *avec_hybrid = (AtomVecHybrid *) atom->avec;
+    int ihybrid;
+    for (ihybrid = 0; ihybrid < avec_hybrid->nstyles; ihybrid++)
+      if (strcmp(avec_hybrid->keywords[ihybrid],arg[2]) == 0) break;
+    if (ihybrid == avec_hybrid->nstyles)
+      error->all("Group hybrid sub-style does not exist");
+
+    // add to group if atom matches hybrid sub-style
+
+    int *hybrid = atom->hybrid;
+
+    for (i = 0; i < nlocal; i++)
+      if (hybrid[i] == ihybrid)	mask[i] |= bit;
+
+  // style = logical condition
 
   } else if (strcmp(arg[2],"<") == 0 || strcmp(arg[2],">") == 0 || 
 	     strcmp(arg[2],"<=") == 0 || strcmp(arg[2],">=") == 0 || 
@@ -173,7 +198,7 @@ void Group::assign(int narg, char **arg)
 	if (attribute[i] >= bound1 && attribute[i] <= bound2) mask[i] |= bit;
     }
 
-    // style = list of values
+  // style = list of values
 
   } else if (strcmp(arg[1],"type") == 0 || strcmp(arg[1],"molecule") == 0 ||
 	     strcmp(arg[1],"id") == 0) {
@@ -205,7 +230,7 @@ void Group::assign(int narg, char **arg)
 
     delete [] list;
     
-    // style = subtract
+  // style = subtract
 
   } else if (strcmp(arg[1],"subtract") == 0) {
 
@@ -241,7 +266,7 @@ void Group::assign(int narg, char **arg)
 
     delete [] list;
 
-    // style = union
+  // style = union
 
   } else if (strcmp(arg[1],"union") == 0) {
 
@@ -269,7 +294,7 @@ void Group::assign(int narg, char **arg)
 
     delete [] list;
 
-    // style = intersect
+  // style = intersect
 
   } else if (strcmp(arg[1],"intersect") == 0) {
 
@@ -300,7 +325,7 @@ void Group::assign(int narg, char **arg)
 
     delete [] list;
 
-    // not a valid group style
+  // not a valid group style
 
   } else error->all("Illegal group command");
 
@@ -443,7 +468,7 @@ double Group::mass(int igroup)
 
   double m = 0.0;
 
-  if (atom->mass_require) {
+  if (mass) {
     for (int i = 0; i < nlocal; i++)
       if (mask[i] & groupbit) m += mass[type[i]];
   } else {
@@ -547,7 +572,7 @@ void Group::xcm(int igroup, double masstotal, double *cm)
   int xbox,ybox,zbox;
   double massone;
 
-  if (atom->mass_require) {
+  if (mass) {
     for (int i = 0; i < nlocal; i++)
       if (mask[i] & groupbit) {
 	xbox = (image[i] & 1023) - 512;
@@ -596,7 +621,7 @@ void Group::vcm(int igroup, double masstotal, double *cm)
   double p[3],massone;
   p[0] = p[1] = p[2] = 0.0;
 
-  if (atom->mass_require) {
+  if (mass) {
     for (int i = 0; i < nlocal; i++)
       if (mask[i] & groupbit) {
 	massone = mass[type[i]];
@@ -636,7 +661,6 @@ double Group::gyration(int igroup, double masstotal, double *cm)
   double *mass = atom->mass;
   double *rmass = atom->rmass;
   int nlocal = atom->nlocal;
-  int mass_require = atom->mass_require;
 
   int xbox,ybox,zbox;
   double dx,dy,dz,massone;
@@ -653,7 +677,7 @@ double Group::gyration(int igroup, double masstotal, double *cm)
       dx = (x[i][0] + xbox*xprd) - cm[0];
       dy = (x[i][1] + ybox*yprd) - cm[1];
       dz = (x[i][2] + zbox*zprd) - cm[2];
-      if (mass_require) massone = mass[type[i]];
+      if (mass) massone = mass[type[i]];
       else massone = rmass[i];
       rg += (dx*dx + dy*dy + dz*dz) * massone;
     }
@@ -680,7 +704,6 @@ void Group::angmom(int igroup, double *cm, double *lmom)
   double *mass = atom->mass;
   double *rmass = atom->rmass;
   int nlocal = atom->nlocal;
-  int mass_require = atom->mass_require;
 
   int xbox,ybox,zbox;
   double dx,dy,dz,massone;
@@ -698,7 +721,7 @@ void Group::angmom(int igroup, double *cm, double *lmom)
       dx = (x[i][0] + xbox*xprd) - cm[0];
       dy = (x[i][1] + ybox*yprd) - cm[1];
       dz = (x[i][2] + zbox*zprd) - cm[2];
-      if (mass_require) massone = mass[type[i]];
+      if (mass) massone = mass[type[i]];
       else massone = rmass[i];
       p[0] += massone * (dy*v[i][2] - dz*v[i][1]);
       p[1] += massone * (dz*v[i][0] - dx*v[i][2]);
@@ -726,7 +749,6 @@ void Group::inertia(int igroup, double *cm, double itensor[3][3])
   double *mass = atom->mass;
   double *rmass = atom->rmass;
   int nlocal = atom->nlocal;
-  int mass_require = atom->mass_require;
 
   int xbox,ybox,zbox;
   double dx,dy,dz,massone;
@@ -746,7 +768,7 @@ void Group::inertia(int igroup, double *cm, double itensor[3][3])
       dx = (x[i][0] + xbox*xprd) - cm[0];
       dy = (x[i][1] + ybox*yprd) - cm[1];
       dz = (x[i][2] + zbox*zprd) - cm[2];
-      if (mass_require) massone = mass[type[i]];
+      if (mass) massone = mass[type[i]];
       else massone = rmass[i];
       ione[0][0] += massone * (dy*dy + dz*dz);
       ione[1][1] += massone * (dx*dx + dz*dz);
@@ -764,14 +786,11 @@ void Group::inertia(int igroup, double *cm, double itensor[3][3])
 
 /* ----------------------------------------------------------------------
    compute angular velocity omega from L = Iw, inverting I to solve for w
+   really not a group operation, but L and I were computed for a group
 ------------------------------------------------------------------------- */
 
-void Group::omega(int igroup, double *angmom, double inertia[3][3], double *w)
+void Group::omega(double *angmom, double inertia[3][3], double *w)
 {
-  int i,j;
-
-  int groupbit = bitmask[igroup];
-
   double inverse[3][3];
 
   inverse[0][0] = inertia[1][1]*inertia[2][2] - inertia[1][2]*inertia[2][1];
@@ -793,6 +812,7 @@ void Group::omega(int igroup, double *angmom, double inertia[3][3], double *w)
     inertia[0][1]*inertia[1][0]*inertia[2][2] - 
     inertia[2][0]*inertia[1][1]*inertia[0][2]; 
 
+  int i,j;
   for (i = 0; i < 3; i++)
     for (j = 0; j < 3; j++)
       inverse[i][j] /= determinant;
diff --git a/src/group.h b/src/group.h
index ed24b62726f766086d3a970f259f745bb3fd85bc..f44e13883a2e7dd947409a884e34ae52076a9d1e 100644
--- a/src/group.h
+++ b/src/group.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -15,9 +15,11 @@
 #define GROUP_H
 
 #include "stdio.h"
-#include "lammps.h"
+#include "pointers.h"
 
-class Group : public LAMMPS {
+namespace LAMMPS_NS {
+
+class Group : protected Pointers {
  public:
   int me;
   int ngroup;                  // # of defined groups
@@ -25,7 +27,7 @@ class Group : public LAMMPS {
   int *bitmask;                // one-bit mask for each group
   int *inversemask;            // inverse mask for each group
 
-  Group();
+  Group(class LAMMPS *);
   ~Group();
   void assign(int, char **);         // assign atoms to a group
   void create(char *, int *);        // add flagged atoms to a group
@@ -41,9 +43,10 @@ class Group : public LAMMPS {
   void vcm(int, double, double *);         // center-of-mass velocity of group
   double gyration(int, double, double *);  // radius-of-gyration of group
   void angmom(int, double *, double *);    // angular momentum of group
-  void inertia(int, double *, double [3][3]);          // inertia tensor
-  void omega(int, double *, double [3][3], double *);  // angular velocity
+  void inertia(int, double *, double [3][3]);     // inertia tensor
+  void omega(double *, double [3][3], double *);  // angular velocity
 };
 
-#endif
+}
 
+#endif
diff --git a/src/improper.h b/src/improper.h
index 118d295eeedd9fab010a1ff219793c98f892a678..fef609ae6ea10c45a72a6d13f90827738aa59142 100644
--- a/src/improper.h
+++ b/src/improper.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -15,9 +15,11 @@
 #define IMPROPER_H
 
 #include "stdio.h"
-#include "lammps.h"
+#include "pointers.h"
 
-class Improper : public LAMMPS {
+namespace LAMMPS_NS {
+
+class Improper : protected Pointers {
  public:
   int allocated;
   int *setflag;
@@ -25,7 +27,7 @@ class Improper : public LAMMPS {
   double virial[6];
   double PI;
 
-  Improper();
+  Improper(class LAMMPS *);
   virtual ~Improper() {}
   virtual void init();
   virtual void compute(int, int) = 0;
@@ -36,4 +38,6 @@ class Improper : public LAMMPS {
   virtual int memory_usage() {return 0;}
 };
 
+}
+
 #endif
diff --git a/src/input.cpp b/src/input.cpp
index 51c560cc493f6f84f06e849822db102fd9d143ee..51425bbdc06743235b0ad097d7f33683d9d00bf0 100644
--- a/src/input.cpp
+++ b/src/input.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,9 +16,9 @@
 #include "stdlib.h"
 #include "string.h"
 #include "input.h"
-#include "system.h"
 #include "universe.h"
 #include "atom.h"
+#include "atom_vec.h"
 #include "comm.h"
 #include "group.h"
 #include "domain.h"
@@ -40,18 +40,18 @@
 #include "error.h"
 #include "memory.h"
 
-#define AtomInclude
 #define CommandInclude
 #include "style.h"
-#undef AtomInclude
 #undef CommandInclude
 
+using namespace LAMMPS_NS;
+
 #define MAXLINE 2048
 #define DELTA 4
 
 /* ---------------------------------------------------------------------- */
 
-Input::Input(int argc, char **argv)
+Input::Input(LAMMPS *lmp, int argc, char **argv) : Pointers(lmp)
 {
   MPI_Comm_rank(world,&me);
 
@@ -74,7 +74,7 @@ Input::Input(int argc, char **argv)
     infiles[0] = infile;
   } else infiles = NULL;
 
-  variable = new Variable;
+  variable = new Variable(lmp);
 
   // process command-line args
   // check for args "-var" and "-echo"
@@ -119,7 +119,7 @@ Input::~Input()
 
 void Input::file()
 {
-  int n,flag;
+  int n;
 
   while (1) {
     
@@ -389,14 +389,25 @@ int Input::execute_command()
 {
   int flag = 1;
 
-  if (!strcmp(command,"angle_coeff")) angle_coeff();
+  if (!strcmp(command,"clear")) clear();
+  else if (!strcmp(command,"echo")) echo();
+  else if (!strcmp(command,"include")) include();
+  else if (!strcmp(command,"jump")) jump();
+  else if (!strcmp(command,"label")) label();
+  else if (!strcmp(command,"log")) log();
+  else if (!strcmp(command,"next")) next_command();
+  else if (!strcmp(command,"print")) print();
+  else if (!strcmp(command,"variable")) variable_command();
+
+  else if (!strcmp(command,"angle_coeff")) angle_coeff();
   else if (!strcmp(command,"angle_style")) angle_style();
   else if (!strcmp(command,"atom_modify")) atom_modify();
   else if (!strcmp(command,"atom_style")) atom_style();
   else if (!strcmp(command,"bond_coeff")) bond_coeff();
   else if (!strcmp(command,"bond_style")) bond_style();
   else if (!strcmp(command,"boundary")) boundary();
-  else if (!strcmp(command,"clear")) clear();
+  else if (!strcmp(command,"compute")) compute();
+  else if (!strcmp(command,"compute_modify")) compute_modify();
   else if (!strcmp(command,"dielectric")) dielectric();
   else if (!strcmp(command,"dihedral_coeff")) dihedral_coeff();
   else if (!strcmp(command,"dihedral_style")) dihedral_style();
@@ -404,39 +415,30 @@ int Input::execute_command()
   else if (!strcmp(command,"dipole")) dipole();
   else if (!strcmp(command,"dump")) dump();
   else if (!strcmp(command,"dump_modify")) dump_modify();
-  else if (!strcmp(command,"echo")) echo();
   else if (!strcmp(command,"fix")) fix();
   else if (!strcmp(command,"fix_modify")) fix_modify();
   else if (!strcmp(command,"group")) group_command();
   else if (!strcmp(command,"improper_coeff")) improper_coeff();
   else if (!strcmp(command,"improper_style")) improper_style();
-  else if (!strcmp(command,"include")) include();
-  else if (!strcmp(command,"jump")) jump();
   else if (!strcmp(command,"kspace_modify")) kspace_modify();
   else if (!strcmp(command,"kspace_style")) kspace_style();
-  else if (!strcmp(command,"label")) label();
   else if (!strcmp(command,"lattice")) lattice();
-  else if (!strcmp(command,"log")) log();
   else if (!strcmp(command,"mass")) mass();
   else if (!strcmp(command,"min_modify")) min_modify();
   else if (!strcmp(command,"min_style")) min_style();
   else if (!strcmp(command,"neigh_modify")) neigh_modify();
   else if (!strcmp(command,"neighbor")) neighbor_command();
   else if (!strcmp(command,"newton")) newton();
-  else if (!strcmp(command,"next")) next_command();
   else if (!strcmp(command,"pair_coeff")) pair_coeff();
   else if (!strcmp(command,"pair_modify")) pair_modify();
   else if (!strcmp(command,"pair_style")) pair_style();
   else if (!strcmp(command,"pair_write")) pair_write();
-  else if (!strcmp(command,"print")) print();
   else if (!strcmp(command,"processors")) processors();
   else if (!strcmp(command,"region")) region();
   else if (!strcmp(command,"reset_timestep")) reset_timestep();
   else if (!strcmp(command,"restart")) restart();
   else if (!strcmp(command,"run_style")) run_style();
   else if (!strcmp(command,"special_bonds")) special_bonds();
-  else if (!strcmp(command,"temp_modify")) temp_modify();
-  else if (!strcmp(command,"temperature")) temperature();
   else if (!strcmp(command,"thermo")) thermo();
   else if (!strcmp(command,"thermo_modify")) thermo_modify();
   else if (!strcmp(command,"thermo_style")) thermo_style();
@@ -444,7 +446,7 @@ int Input::execute_command()
   else if (!strcmp(command,"undump")) undump();
   else if (!strcmp(command,"unfix")) unfix();
   else if (!strcmp(command,"units")) units();
-  else if (!strcmp(command,"variable")) variable_command();
+
   else flag = 0;
 
   if (flag) return 0;
@@ -454,7 +456,7 @@ int Input::execute_command()
 #define CommandClass
 #define CommandStyle(key,Class)         \
   else if (strcmp(command,#key) == 0) { \
-    Class key;                          \
+    Class key(lmp);			\
     key.command(narg,arg);              \
     return 0;                           \
   }
@@ -468,8 +470,159 @@ int Input::execute_command()
 /* ---------------------------------------------------------------------- */
 /* ---------------------------------------------------------------------- */
 
+/* ---------------------------------------------------------------------- */
+
+void Input::clear()
+{
+  if (narg > 0) error->all("Illegal clear command");
+  lmp->destroy();
+  lmp->create();
+}
+
+/* ---------------------------------------------------------------------- */
+
+void Input::echo()
+{
+  if (narg != 1) error->all("Illegal echo command");
+
+  if (strcmp(arg[0],"none") == 0) {
+    echo_screen = 0;
+    echo_log = 0;
+  } else if (strcmp(arg[0],"screen") == 0) {
+    echo_screen = 1;
+    echo_log = 0;
+  } else if (strcmp(arg[0],"log") == 0) {
+    echo_screen = 0;
+    echo_log = 1;
+  } else if (strcmp(arg[0],"both") == 0) {
+    echo_screen = 1;
+    echo_log = 1;
+  } else error->all("Illegal echo command");
+}
+
+/* ---------------------------------------------------------------------- */
+
+void Input::include()
+{
+  if (narg != 1) error->all("Illegal include command");
+
+  if (me == 0) {
+    if (nfile == maxfile) {
+      maxfile++;
+      infiles = (FILE **) 
+        memory->srealloc(infiles,maxfile*sizeof(FILE *),"input:infiles");
+    }
+    infile = fopen(arg[0],"r");
+    if (infile == NULL) {
+      char str[128];
+      sprintf(str,"Cannot open input script %s",arg[0]);
+      error->one(str);
+    }
+    infiles[nfile++] = infile;
+  }
+}
+
+/* ---------------------------------------------------------------------- */
+
+void Input::jump()
+{
+  if (narg < 1 || narg > 2) error->all("Illegal jump command");
+
+  if (jump_skip) {
+    jump_skip = 0;
+    return;
+  }
+
+  if (me == 0) {
+    if (infile != stdin) fclose(infile);
+    infile = fopen(arg[0],"r");
+    if (infile == NULL) {
+      char str[128];
+      sprintf(str,"Cannot open input script %s",arg[0]);
+      error->one(str);
+    }
+    infiles[nfile-1] = infile;
+  }
+
+  if (narg == 2) {
+    label_active = 1;
+    if (labelstr) delete [] labelstr;
+    int n = strlen(arg[1]) + 1;
+    labelstr = new char[n];
+    strcpy(labelstr,arg[1]);
+  }
+}
+
+/* ---------------------------------------------------------------------- */
+
+void Input::label()
+{
+  if (narg != 1) error->all("Illegal label command");
+  if (label_active && strcmp(labelstr,arg[0]) == 0) label_active = 0;
+}
+
+/* ---------------------------------------------------------------------- */
+
+void Input::log()
+{
+  if (narg != 1) error->all("Illegal log command");
+
+  if (me == 0) {
+    if (logfile) fclose(logfile);
+    if (strcmp(arg[0],"none") == 0) logfile = NULL;
+    else {
+      logfile = fopen(arg[0],"w");
+      if (logfile == NULL) {
+	char str[128];
+	sprintf(str,"Cannot open logfile %s",arg[0]);
+	error->one(str);
+      }
+    }
+    if (universe->nworlds == 1) universe->ulogfile = logfile;
+  }
+}
+
+/* ---------------------------------------------------------------------- */
+
+void Input::next_command()
+{
+  if (variable->next(narg,arg)) jump_skip = 1;
+}
+
+/* ---------------------------------------------------------------------- */
+
+void Input::print()
+{
+  if (narg < 1) error->all("Illegal print command");
+
+  char *str = new char[MAXLINE];
+  str[0] = '\0';
+  for (int iarg = 0; iarg < narg; iarg++) {
+    strcat(str,arg[iarg]);
+    strcat(str," ");
+  }
+  
+  if (me == 0) {
+    if (screen) fprintf(screen,"%s\n",str);
+    if (logfile) fprintf(logfile,"%s\n",str);
+  }
+
+  delete [] str;
+}
+
+/* ---------------------------------------------------------------------- */
+
+void Input::variable_command()
+{
+  variable->set(narg,arg);
+}
+
+/* ---------------------------------------------------------------------- */
+/* ---------------------------------------------------------------------- */
+/* ---------------------------------------------------------------------- */
+
 /* ----------------------------------------------------------------------
-   one function for each input command executed here
+   one function for each LAMMPS-specific input script command
 ------------------------------------------------------------------------- */
 
 void Input::angle_coeff()
@@ -478,7 +631,7 @@ void Input::angle_coeff()
     error->all("Angle_coeff command before simulation box is defined");
   if (force->angle == NULL) 
     error->all("Angle_coeff command before angle_style is defined");
-  if (atom->angles_allow == 0) 
+  if (atom->avec->angles_allow == 0) 
     error->all("Angle_coeff command when no angles allowed");
   force->angle->coeff(0,narg,arg);
 }
@@ -488,6 +641,8 @@ void Input::angle_coeff()
 void Input::angle_style()
 {
   if (narg < 1) error->all("Illegal angle_style command");
+  if (atom->avec->angles_allow == 0) 
+    error->all("Angle_style command when no angles allowed");
   force->create_angle(arg[0]);
   if (force->angle) force->angle->settings(narg-1,&arg[1]);
 }
@@ -498,7 +653,6 @@ void Input::atom_modify()
 {
   if (domain->box_exist) 
     error->all("Atom_modify command after simulation box is defined");
-  if (!atom) error->all("Atom_modify command before atom_style command");
   atom->modify_params(narg,arg);
 }
 
@@ -506,26 +660,10 @@ void Input::atom_modify()
 
 void Input::atom_style()
 {
+  if (narg < 1) error->all("Illegal atom_style command");
   if (domain->box_exist) 
     error->all("Atom_style command after simulation box is defined");
-  if (narg < 1) error->all("Illegal atom_style command");
-
-  Atom *old = atom;
-
-  if (strcmp(arg[0],"none") == 0) error->all("Invalid atom style");
-
-#define AtomClass
-#define AtomStyle(key,Class) \
-  else if (strcmp(arg[0],#key) == 0) atom = new Class(narg,arg);
-#include "style.h"
-#undef AtomClass
-
-  else error->all("Invalid atom style");
-
-  if (old) {
-    atom->settings(old);
-    delete old;
-  }
+  atom->create_avec(arg[0],narg-1,&arg[1]);
 }
 
 /* ---------------------------------------------------------------------- */
@@ -536,7 +674,7 @@ void Input::bond_coeff()
     error->all("Bond_coeff command before simulation box is defined");
   if (force->bond == NULL) 
     error->all("Bond_coeff command before bond_style is defined");
-  if (atom->bonds_allow == 0) 
+  if (atom->avec->bonds_allow == 0) 
     error->all("Bond_coeff command when no bonds allowed");
   force->bond->coeff(narg,arg);
 }
@@ -546,6 +684,8 @@ void Input::bond_coeff()
 void Input::bond_style()
 {
   if (narg < 1) error->all("Illegal bond_style command");
+  if (atom->avec->bonds_allow == 0) 
+    error->all("Bond_style command when no bonds allowed");
   force->create_bond(arg[0]);
   if (force->bond) force->bond->settings(narg-1,&arg[1]);
 }
@@ -561,11 +701,16 @@ void Input::boundary()
 
 /* ---------------------------------------------------------------------- */
 
-void Input::clear()
+void Input::compute()
 {
-  if (narg > 0) error->all("Illegal clear command");
-  sys->destroy();
-  sys->create();
+  modify->add_compute(narg,arg);
+}
+
+/* ---------------------------------------------------------------------- */
+
+void Input::compute_modify()
+{
+  modify->modify_compute(narg,arg);
 }
 
 /* ---------------------------------------------------------------------- */
@@ -584,7 +729,7 @@ void Input::dihedral_coeff()
     error->all("Dihedral_coeff command before simulation box is defined");
   if (force->dihedral == NULL) 
     error->all("Dihedral_coeff command before dihedral_style is defined");
-  if (atom->dihedrals_allow == 0) 
+  if (atom->avec->dihedrals_allow == 0) 
     error->all("Dihedral_coeff command when no dihedrals allowed");
   force->dihedral->coeff(0,narg,arg);
 }
@@ -594,6 +739,8 @@ void Input::dihedral_coeff()
 void Input::dihedral_style()
 {
   if (narg < 1) error->all("Illegal dihedral_style command");
+  if (atom->avec->dihedrals_allow == 0) 
+    error->all("Dihedral_style command when no dihedrals allowed");
   force->create_dihedral(arg[0]);
   if (force->dihedral) force->dihedral->settings(narg-1,&arg[1]);
 }
@@ -602,9 +749,9 @@ void Input::dihedral_style()
 
 void Input::dimension()
 {
+  if (narg != 1) error->all("Illegal dimension command");
   if (domain->box_exist) 
     error->all("Dimension command after simulation box is defined");
-  if (narg != 1) error->all("Illegal dimension command");
   force->dimension = atoi(arg[0]);
 }
 
@@ -612,9 +759,9 @@ void Input::dimension()
 
 void Input::dipole()
 {
+  if (narg != 2) error->all("Illegal dipole command");
   if (domain->box_exist == 0)
     error->all("Dipole command before simulation box is defined");
-  if (narg != 2) error->all("Illegal dipole command");
   atom->set_dipole(narg,arg);
 }
 
@@ -634,27 +781,6 @@ void Input::dump_modify()
 
 /* ---------------------------------------------------------------------- */
 
-void Input::echo()
-{
-  if (narg != 1) error->all("Illegal echo command");
-
-  if (strcmp(arg[0],"none") == 0) {
-    echo_screen = 0;
-    echo_log = 0;
-  } else if (strcmp(arg[0],"screen") == 0) {
-    echo_screen = 1;
-    echo_log = 0;
-  } else if (strcmp(arg[0],"log") == 0) {
-    echo_screen = 0;
-    echo_log = 1;
-  } else if (strcmp(arg[0],"both") == 0) {
-    echo_screen = 1;
-    echo_log = 1;
-  } else error->all("Illegal echo command");
-}
-
-/* ---------------------------------------------------------------------- */
-
 void Input::fix()
 {
   modify->add_fix(narg,arg);
@@ -682,7 +808,7 @@ void Input::improper_coeff()
     error->all("Improper_coeff command before simulation box is defined");
   if (force->improper == NULL) 
     error->all("Improper_coeff command before improper_style is defined");
-  if (atom->impropers_allow == 0) 
+  if (atom->avec->impropers_allow == 0) 
     error->all("Improper_coeff command when no impropers allowed");
   force->improper->coeff(0,narg,arg);
 }
@@ -692,65 +818,14 @@ void Input::improper_coeff()
 void Input::improper_style()
 {
   if (narg < 1) error->all("Illegal improper_style command");
+  if (atom->avec->impropers_allow == 0) 
+    error->all("Improper_style command when no impropers allowed");
   force->create_improper(arg[0]);
   if (force->improper) force->improper->settings(narg-1,&arg[1]);
 }
 
 /* ---------------------------------------------------------------------- */
 
-void Input::include()
-{
-  if (narg != 1) error->all("Illegal include command");
-
-  if (me == 0) {
-    if (nfile == maxfile) {
-      maxfile++;
-      infiles = (FILE **) 
-        memory->srealloc(infiles,maxfile*sizeof(FILE *),"input:infiles");
-    }
-    infile = fopen(arg[0],"r");
-    if (infile == NULL) {
-      char str[128];
-      sprintf(str,"Cannot open input script %s",arg[0]);
-      error->one(str);
-    }
-    infiles[nfile++] = infile;
-  }
-}
-
-/* ---------------------------------------------------------------------- */
-
-void Input::jump()
-{
-  if (narg < 1 || narg > 2) error->all("Illegal jump command");
-
-  if (jump_skip) {
-    jump_skip = 0;
-    return;
-  }
-
-  if (me == 0) {
-    if (infile != stdin) fclose(infile);
-    infile = fopen(arg[0],"r");
-    if (infile == NULL) {
-      char str[128];
-      sprintf(str,"Cannot open input script %s",arg[0]);
-      error->one(str);
-    }
-    infiles[nfile-1] = infile;
-  }
-
-  if (narg == 2) {
-    label_active = 1;
-    if (labelstr) delete [] labelstr;
-    int n = strlen(arg[1]) + 1;
-    labelstr = new char[n];
-    strcpy(labelstr,arg[1]);
-  }
-}
-
-/* ---------------------------------------------------------------------- */
-
 void Input::kspace_modify()
 {
   if (force->kspace == NULL) error->all("KSpace style has not yet been set");
@@ -766,14 +841,6 @@ void Input::kspace_style()
 
 /* ---------------------------------------------------------------------- */
 
-void Input::label()
-{
-  if (narg != 1) error->all("Illegal label command");
-  if (label_active && strcmp(labelstr,arg[0]) == 0) label_active = 0;
-}
-
-/* ---------------------------------------------------------------------- */
-
 void Input::lattice()
 {
   domain->set_lattice(narg,arg);
@@ -781,35 +848,11 @@ void Input::lattice()
 
 /* ---------------------------------------------------------------------- */
 
-void Input::log()
-{
-  if (narg != 1) error->all("Illegal log command");
-
-  if (me == 0) {
-    if (logfile) fclose(logfile);
-    if (strcmp(arg[0],"none") == 0) logfile = NULL;
-    else {
-      // char fname[128];
-      // if (universe->nworlds == 1) strcpy(fname,arg[0]);
-      // else sprintf(fname,"%s.%d",arg[0],universe->iworld);
-      logfile = fopen(arg[0],"w");
-      if (logfile == NULL) {
-	char str[128];
-	sprintf(str,"Cannot open logfile %s",arg[0]);
-	error->one(str);
-      }
-    }
-    if (universe->nworlds == 1) universe->ulogfile = logfile;
-  }
-}
-
-/* ---------------------------------------------------------------------- */
-
 void Input::mass()
 {
+  if (narg != 2) error->all("Illegal mass command");
   if (domain->box_exist == 0)
     error->all("Mass command before simulation box is defined");
-  if (narg != 2) error->all("Illegal mass command");
   atom->set_mass(narg,arg);
 }
 
@@ -885,13 +928,6 @@ void Input::newton()
 
 /* ---------------------------------------------------------------------- */
 
-void Input::next_command()
-{
-  if (variable->next(narg,arg)) jump_skip = 1;
-}
-
-/* ---------------------------------------------------------------------- */
-
 void Input::pair_coeff()
 {
   if (domain->box_exist == 0)
@@ -937,32 +973,11 @@ void Input::pair_write()
 
 /* ---------------------------------------------------------------------- */
 
-void Input::print()
-{
-  if (narg < 1) error->all("Illegal print command");
-
-  char *str = new char[MAXLINE];
-  str[0] = '\0';
-  for (int iarg = 0; iarg < narg; iarg++) {
-    strcat(str,arg[iarg]);
-    strcat(str," ");
-  }
-  
-  if (me == 0) {
-    if (screen) fprintf(screen,"%s\n",str);
-    if (logfile) fprintf(logfile,"%s\n",str);
-  }
-
-  delete [] str;
-}
-
-/* ---------------------------------------------------------------------- */
-
 void Input::processors()
 {
+  if (narg != 3) error->all("Illegal processors command");
   if (domain->box_exist)
     error->all("Processors command after simulation box is defined");
-  if (narg != 3) error->all("Illegal processors command");
   comm->user_procgrid[0] = atoi(arg[0]);
   comm->user_procgrid[1] = atoi(arg[1]);
   comm->user_procgrid[2] = atoi(arg[2]);
@@ -1018,7 +1033,7 @@ void Input::special_bonds()
   if (domain->box_exist && atom->molecular) {
     if (lj2 != force->special_lj[2] || lj3 != force->special_lj[3] ||
 	coul2 != force->special_coul[2] || coul3 != force->special_coul[3]) {
-      Special special;
+      Special special(lmp);
       special.build();
     }
   }
@@ -1026,20 +1041,6 @@ void Input::special_bonds()
 
 /* ---------------------------------------------------------------------- */
 
-void Input::temp_modify()
-{
-  force->modify_temp(narg,arg);
-}
-
-/* ---------------------------------------------------------------------- */
-
-void Input::temperature()
-{
-  force->add_temp(narg,arg,0);
-}
-
-/* ---------------------------------------------------------------------- */
-
 void Input::thermo()
 {
   if (narg != 1) error->all("Illegal thermo command");
@@ -1088,15 +1089,8 @@ void Input::unfix()
 
 void Input::units()
 {
+  if (narg != 1) error->all("Illegal units command");
   if (domain->box_exist) 
     error->all("Units command after simulation box is defined");
-  if (narg != 1) error->all("Illegal units command");
   update->set_units(arg[0]);
 }
-
-/* ---------------------------------------------------------------------- */
-
-void Input::variable_command()
-{
-  variable->set(narg,arg);
-}
diff --git a/src/input.h b/src/input.h
index eec6ddc8c67ec8b990ea20d20b75387c5b157b6f..2a8b2353bdc273d5a342285981909ef79ec2a6eb 100644
--- a/src/input.h
+++ b/src/input.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -15,17 +15,18 @@
 #define INPUT_H
 
 #include "stdio.h"
-#include "lammps.h"
+#include "pointers.h"
 
-class Variable;
+namespace LAMMPS_NS {
 
-class Input : public LAMMPS {
+class Input : protected Pointers {
+ public:
  public:
   int narg;                    // # of command args
   char **arg;                  // parsed args for command
-  Variable *variable;          // defined variables
+  class Variable *variable;    // defined variables
 
-  Input(int, char **);
+  Input(class LAMMPS *, int, char **);
   ~Input();
   void file();                   // process all input
   void file(char *);             // process an input script
@@ -49,14 +50,25 @@ class Input : public LAMMPS {
   void parse();                // parse an input text line
   int execute_command();       // execute a single command
 
-  void angle_coeff();          // individual commands
+  void clear();                // input script commands
+  void echo();
+  void include();
+  void jump();
+  void label();
+  void log();
+  void next_command();
+  void print();
+  void variable_command();
+
+  void angle_coeff();          // LAMMPS commands
   void angle_style();
   void atom_modify();
   void atom_style();
   void bond_coeff();
   void bond_style();
   void boundary();
-  void clear();
+  void compute();
+  void compute_modify();
   void dielectric();
   void dihedral_coeff();
   void dihedral_style();
@@ -64,39 +76,30 @@ class Input : public LAMMPS {
   void dipole();
   void dump();
   void dump_modify();
-  void echo();
   void fix();
   void fix_modify();
   void group_command();
   void improper_coeff();
   void improper_style();
-  void include();
-  void jump();
   void kspace_modify();
   void kspace_style();
-  void label();
   void lattice();
-  void log();
   void mass();
   void min_modify();
   void min_style();
   void neigh_modify();
   void neighbor_command();
   void newton();
-  void next_command();
   void pair_coeff();
   void pair_modify();
   void pair_style();
   void pair_write();
-  void print();
   void processors();
   void region();
   void reset_timestep();
   void restart();
   void run_style();
   void special_bonds();
-  void temp_modify();
-  void temperature();
   void thermo();
   void thermo_modify();
   void thermo_style();
@@ -104,7 +107,8 @@ class Input : public LAMMPS {
   void undump();
   void unfix();
   void units();
-  void variable_command();
 };
 
+}
+
 #endif
diff --git a/src/integrate.h b/src/integrate.h
index beab2d88acc604b12c74b25c12eb7f12b40817d0..1221f582db8cd9009898c4a8bb6e15d2b865b1c3 100644
--- a/src/integrate.h
+++ b/src/integrate.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -14,11 +14,13 @@
 #ifndef INTEGRATE_H
 #define INTEGRATE_H
 
-#include "lammps.h"
+#include "pointers.h"
 
-class Integrate : public LAMMPS {
+namespace LAMMPS_NS {
+
+class Integrate : protected Pointers {
  public:
-  Integrate(int, char **) {}
+  Integrate(class LAMMPS *lmp, int, char **) : Pointers(lmp) {}
   virtual ~Integrate() {}
   virtual void init() = 0;
   virtual void setup() = 0;
@@ -27,4 +29,6 @@ class Integrate : public LAMMPS {
   virtual int memory_usage() {return 0;}
 };
 
+}
+
 #endif
diff --git a/src/kspace.cpp b/src/kspace.cpp
index 5c90fa394ef65e37229ea751ba23f4b2798d949a..216e74474a45ea947b1eef8fb14967922bee0e35 100644
--- a/src/kspace.cpp
+++ b/src/kspace.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,9 +16,11 @@
 #include "kspace.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 /* ---------------------------------------------------------------------- */
 
-KSpace::KSpace(int narg, char **arg)
+KSpace::KSpace(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp)
 {
   energy = 0.0;
   order = 5;
diff --git a/src/kspace.h b/src/kspace.h
index 500a318ddbf02d260afd4612adb671c170b5fef9..e758be5b457e9bd31028fa261b5edaf57e0c0aa3 100644
--- a/src/kspace.h
+++ b/src/kspace.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -14,9 +14,11 @@
 #ifndef KSPACE_H
 #define KSPACE_H
 
-#include "lammps.h"
+#include "pointers.h"
 
-class KSpace : public LAMMPS {
+namespace LAMMPS_NS {
+
+class KSpace : protected Pointers {
  public:
   double energy;
   double virial[6];
@@ -28,7 +30,7 @@ class KSpace : public LAMMPS {
   int order;
   int slabflag;
  
-  KSpace(int, char **);
+  KSpace(class LAMMPS *, int, char **);
   virtual ~KSpace() {}
   void modify_params(int, char **);
   virtual void init() = 0;
@@ -38,4 +40,6 @@ class KSpace : public LAMMPS {
   virtual int memory_usage() {return 0;}
 };
 
+}
+
 #endif
diff --git a/src/lammps.cpp b/src/lammps.cpp
index fde2329e98c549338a4a08638e19c9867b91a040..c54506f81d41baa42a7bd689faa948184a06b9df 100644
--- a/src/lammps.cpp
+++ b/src/lammps.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -11,54 +11,325 @@
    See the README file in the top-level LAMMPS directory.
 ------------------------------------------------------------------------- */
 
-// parent class for all of LAMMPS
-// all other classes inherit from this
-// contains static ptrs to single instance of other classes
-// contains MPI communicator and file handles for my world of procs
-
 #include "mpi.h"
-#include "stdlib.h"
+#include "string.h"
 #include "lammps.h"
-#include "system.h"
-
-// set static ptrs to NULL
-
-System *LAMMPS::sys = NULL;
-Universe *LAMMPS::universe = NULL;
-Input *LAMMPS::input = NULL;
-Memory *LAMMPS::memory = NULL;
-Error *LAMMPS::error = NULL;
-
-Atom *LAMMPS::atom = NULL;
-Update *LAMMPS::update = NULL;
-Neighbor *LAMMPS::neighbor = NULL;
-Comm *LAMMPS::comm = NULL;
-Domain *LAMMPS::domain = NULL;
-Force *LAMMPS::force = NULL;
-Modify *LAMMPS::modify = NULL;
-Group *LAMMPS::group = NULL;
-Output *LAMMPS::output = NULL;
-Timer *LAMMPS::timer = NULL;
-
-MPI_Comm LAMMPS::world = 0;
-FILE *LAMMPS::infile = NULL;
-FILE *LAMMPS::screen = NULL;
-FILE *LAMMPS::logfile = NULL;
-
-/* ---------------------------------------------------------------------- */
-
-void LAMMPS::open(int narg, char **arg, MPI_Comm communicator)
+#include "memory.h"
+#include "error.h"
+#include "universe.h"
+#include "input.h"
+#include "atom.h"
+#include "update.h"
+#include "neighbor.h"
+#include "comm.h"
+#include "domain.h"
+#include "force.h"
+#include "modify.h"
+#include "group.h"
+#include "output.h"
+#include "timer.h"
+
+using namespace LAMMPS_NS;
+
+/* ----------------------------------------------------------------------
+   start up LAMMPS
+   allocate fundamental classes (memory, error, universe, input)
+   parse input switches
+   initialize communicators, screen & logfile output
+   input is allocated at end after MPI info is setup
+------------------------------------------------------------------------- */
+
+LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator)
+{
+  memory = new Memory(this);
+  error = new Error(this);
+  universe = new Universe(this,communicator);
+
+  // parse input switches
+
+  int inflag = 0;
+  int screenflag = 0;
+  int logflag = 0;
+  int iarg = 1;
+
+  while (iarg < narg) {
+    if (strcmp(arg[iarg],"-partition") == 0) {
+      if (iarg+1 > narg) 
+	error->universe_all("Invalid command-line argument");
+      iarg++;
+      while (iarg < narg && arg[iarg][0] != '-') {
+	universe->add_world(arg[iarg]);
+	iarg++;
+      }
+    } else if (strcmp(arg[iarg],"-in") == 0) {
+      if (iarg+2 > narg) 
+	error->universe_all("Invalid command-line argument");
+      inflag = iarg + 1;
+      iarg += 2;
+    } else if (strcmp(arg[iarg],"-screen") == 0) {
+      if (iarg+2 > narg) 
+	error->universe_all("Invalid command-line argument");
+      screenflag = iarg + 1;
+      iarg += 2;
+    } else if (strcmp(arg[iarg],"-log") == 0) {
+      if (iarg+2 > narg) 
+	error->universe_all("Invalid command-line argument");
+      logflag = iarg + 1;
+      iarg += 2;
+    } else if (strcmp(arg[iarg],"-var") == 0) {
+      if (iarg+3 > narg) 
+	error->universe_all("Invalid command-line argument");
+      iarg += 3;
+    } else if (strcmp(arg[iarg],"-echo") == 0) {
+      if (iarg+2 > narg) 
+	error->universe_all("Invalid command-line argument");
+      iarg += 2;
+    } else error->universe_all("Invalid command-line argument");
+  }
+
+  // if procs was not a command-line switch, universe is one world w/ all procs
+
+  if (universe->nworlds == 0) universe->add_world(NULL);
+
+  // sum of procs in all worlds must equal total # of procs
+
+  if (!universe->consistent())
+    error->universe_all("Processor partitions are inconsistent");
+
+  // multiple-world universe must define input file
+
+  if (universe->nworlds > 1 && inflag == 0)
+    error->universe_all("Must use -in switch with multiple partitions");
+
+  // set universe screen and logfile
+
+  if (universe->me == 0) {
+    if (screenflag == 0)
+      universe->uscreen = stdout;
+    else if (strcmp(arg[screenflag],"none") == 0)
+      universe->uscreen = NULL;
+    else {
+      universe->uscreen = fopen(arg[screenflag],"w");
+      if (universe->uscreen == NULL) 
+	error->universe_one("Cannot open universe screen file");
+    }
+    if (logflag == 0) {
+      universe->ulogfile = fopen("log.lammps","w");
+      if (universe->ulogfile == NULL) 
+	error->universe_one("Cannot open log.lammps");
+    } else if (strcmp(arg[logflag],"none") == 0)
+      universe->ulogfile = NULL;
+    else {
+      universe->ulogfile = fopen(arg[logflag],"w");
+      if (universe->ulogfile == NULL) 
+	error->universe_one("Cannot open universe log file");
+    }
+  }
+
+  if (universe->me > 0) {
+    if (screenflag == 0) universe->uscreen = stdout;
+    else universe->uscreen = NULL;
+    universe->ulogfile = NULL;
+  }
+
+  // universe is single world
+  // inherit settings from universe
+  // set world screen, logfile, communicator, infile
+  // open input script if from file
+
+  if (universe->nworlds == 1) {
+    screen = universe->uscreen;
+    logfile = universe->ulogfile;
+    world = universe->uworld;
+    infile = NULL;
+
+    if (universe->me == 0) {
+      if (inflag == 0) infile = stdin;
+      else infile = fopen(arg[inflag],"r");
+      if (infile == NULL) {
+	char str[128];
+	sprintf(str,"Cannot open input script %s",arg[inflag]);
+	error->one(str);
+      }
+    }
+
+    if (universe->me == 0) {
+      if (screen) fprintf(screen,"LAMMPS (%s)\n",universe->version);
+      if (logfile) fprintf(logfile,"LAMMPS (%s)\n",universe->version);
+    }
+
+  // universe is multiple worlds
+  // split into separate communicators
+  // set world screen, logfile, communicator, infile
+  // open input script
+
+  } else {
+    int me;
+    MPI_Comm_split(universe->uworld,universe->iworld,0,&world);
+    MPI_Comm_rank(world,&me);
+
+    if (me == 0) {
+      if (screenflag == 0) {
+	char str[32];
+	sprintf(str,"screen.%d",universe->iworld);
+	screen = fopen(str,"w");
+	if (screen == NULL) error->one("Cannot open screen file");
+      } else if (strcmp(arg[screenflag],"none") == 0)
+	screen = NULL;
+      else {
+	char str[128];
+	sprintf(str,"%s.%d",arg[screenflag],universe->iworld);
+	screen = fopen(str,"w");
+	if (screen == NULL) error->one("Cannot open screen file");
+      }
+    } else screen = NULL;
+    
+    if (me == 0) {
+      if (logflag == 0) {
+	char str[32];
+	sprintf(str,"log.lammps.%d",universe->iworld);
+	logfile = fopen(str,"w");
+	if (logfile == NULL) error->one("Cannot open logfile");
+      } else if (strcmp(arg[logflag],"none") == 0)
+	logfile = NULL;
+      else {
+	char str[128];
+	sprintf(str,"%s.%d",arg[logflag],universe->iworld);
+	logfile = fopen(str,"w");
+	if (logfile == NULL) error->one("Cannot open logfile");
+      }
+    } else logfile = NULL;
+    
+    if (me == 0) {
+      infile = fopen(arg[inflag],"r");
+      if (infile == NULL) {
+	char str[128];
+	sprintf(str,"Cannot open input script %s",arg[inflag]);
+	error->one(str);
+      }
+    } else infile = NULL;
+    
+    // screen and logfile messages for universe and world
+    
+    if (universe->me == 0) {
+      if (universe->uscreen) {
+	fprintf(universe->uscreen,"LAMMPS (%s)\n",universe->version);
+	fprintf(universe->uscreen,"Running on %d partitions of processors\n",
+		universe->nworlds);
+      }
+      if (universe->ulogfile) {
+	fprintf(universe->ulogfile,"LAMMPS (%s)\n",universe->version);
+	fprintf(universe->ulogfile,"Running on %d partitions of processors\n",
+		universe->nworlds);
+      }
+    }
+    
+    if (me == 0) {
+      if (screen) {
+	fprintf(screen,"LAMMPS (%s)\n",universe->version);
+	fprintf(screen,"Processor partition = %d\n",universe->iworld);
+      }
+      if (logfile) {
+	fprintf(logfile,"LAMMPS (%s)\n",universe->version);
+	fprintf(logfile,"Processor partition = %d\n",universe->iworld);
+      }
+    }
+  }
+
+  // allocate input class now that MPI is fully setup
+
+  input = new Input(this,narg,arg);
+
+  // allocate top-level classes
+
+  create();
+}
+
+/* ----------------------------------------------------------------------
+   shutdown LAMMPS
+   delete top-level classes
+   close screen and log files in world and universe
+   output files were already closed in destroy()
+   delete fundamental classes
+------------------------------------------------------------------------- */
+
+LAMMPS::~LAMMPS()
+{
+  destroy();
+
+  if (universe->nworlds == 1) {
+    if (logfile) fclose(logfile);
+  } else {
+    if (screen && screen != stdout) fclose(screen);
+    if (logfile) fclose(logfile);
+    if (universe->ulogfile) fclose(universe->ulogfile);
+  }
+
+  if (world != universe->uworld) MPI_Comm_free(&world);
+
+  delete input;
+  delete universe;
+  delete error;
+  delete memory;
+}
+
+/* ----------------------------------------------------------------------
+   allocate single instance of top-level classes
+   fundamental classes are allocated in constructor
+------------------------------------------------------------------------- */
+
+void LAMMPS::create()
 {
-  sys = new System();
-  sys->open(narg,arg,communicator);
-  sys->create();
+  atom = new Atom(this);
+  neighbor = new Neighbor(this);
+  comm = new Comm(this);
+  domain = new Domain(this);
+  group = new Group(this);
+  force = new Force(this);    // must be after group, to create temperature
+  modify = new Modify(this);
+  output = new Output(this);  // must be after group, so "all" exists
+                              // must be after modify so can create Computes
+  update = new Update(this);  // must be after output, force, neighbor
+  timer = new Timer(this);
 }
 
-/* ---------------------------------------------------------------------- */
+/* ----------------------------------------------------------------------
+   initialize top-level classes
+------------------------------------------------------------------------- */
+
+void LAMMPS::init()
+{
+  update->init();
+  force->init();
+  domain->init();
+  atom->init();          // atom must come after force:
+                         //   atom deletes extra array
+                         //   used by fix shear_history::unpack_restart()
+                         //   when force->pair->gran_history creates fix ??
+  modify->init();        // modify must come after update, force, atom
+  neighbor->init();      // neighbor must come after force, modify (due to min)
+  output->init();        // output must come after domain, force, modify
+  comm->init();          // comm must come after force, modify
+  timer->init();
+}
+
+/* ----------------------------------------------------------------------
+   delete single instance of top-level classes
+   fundamental classes are deleted in destructor
+------------------------------------------------------------------------- */
 
-void LAMMPS::close()
+void LAMMPS::destroy()
 {
-  sys->destroy();
-  sys->close();
-  delete sys;
+  delete update;
+  delete neighbor;
+  delete comm;
+  delete domain;
+  delete force;
+  delete group;
+  delete output;
+  delete modify;          // modify must come after output, force, update
+                          //   since they delete fixes
+  delete atom;            // must come after modify
+                          //   since fixes delete callbacks in atom
+  delete timer;
 }
diff --git a/src/lammps.h b/src/lammps.h
index cec8db9122158a1feaa17af26b7d53a4067f453b..7757823cd776f46d22082fa054a6496393209bba 100644
--- a/src/lammps.h
+++ b/src/lammps.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -14,52 +14,42 @@
 #ifndef LAMMPS_H
 #define LAMMPS_H
 
-#include "mpi.h"
 #include "stdio.h"
+#include "mpi.h"
 
-class System;
-class Universe;
-class Input;
-class Memory;
-class Error;
-
-class Atom;
-class Update;
-class Neighbor;
-class Comm;
-class Domain;
-class Force;
-class Modify;
-class Group;
-class Output;
-class Timer;
+namespace LAMMPS_NS {
 
 class LAMMPS {
  public:
-  static System *sys;             // simulation system
-  static Universe *universe;      // universe of processors
-  static Input *input;            // input script processing
-  static Memory *memory;          // memory allocation functions
-  static Error *error;            // error handling
-
-  static Atom *atom;              // atom-based quantities
-  static Update *update;          // integrators/minimizers
-  static Neighbor *neighbor;      // neighbor lists
-  static Comm *comm;              // inter-processor communication
-  static Domain *domain;          // simulation box
-  static Force *force;            // inter-particle forces
-  static Modify *modify;          // fixes
-  static Group *group;            // groups of atoms
-  static Output *output;          // thermo/dump/restart
-  static Timer *timer;            // CPU timing info
-
-  static MPI_Comm world;          // communicator for my world of procs
-  static FILE *infile;            // infile for my world
-  static FILE *screen;            // screen output for my world
-  static FILE *logfile;           // logfile for my world
-
-  void open(int, char **, MPI_Comm);
-  void close();
+                                 // ptrs to fundamental LAMMPS classes
+  class Memory *memory;             // memory allocation functions
+  class Error *error;               // error handling
+  class Universe *universe;         // universe of processors
+  class Input *input;               // input script processing
+                                 // ptrs to top-level LAMMPS-specific classes
+  class Atom *atom;                 // atom-based quantities
+  class Update *update;             // integrators/minimizers
+  class Neighbor *neighbor;         // neighbor lists
+  class Comm *comm;                 // inter-processor communication
+  class Domain *domain;             // simulation box
+  class Force *force;               // inter-particle forces
+  class Modify *modify;             // fixes and computes
+  class Group *group;               // groups of atoms
+  class Output *output;             // thermo/dump/restart
+  class Timer *timer;               // CPU timing info
+
+  MPI_Comm world;                // MPI communicator
+  FILE *infile;                  // infile
+  FILE *screen;                  // screen output
+  FILE *logfile;                 // logfile
+
+  LAMMPS(int, char **, MPI_Comm);
+  ~LAMMPS();
+  void create();
+  void init();
+  void destroy();
 };
 
+}
+
 #endif
diff --git a/src/lattice.cpp b/src/lattice.cpp
index c3a290935dbb59baff8a109400f5031f1ad6ad5c..8890e82a84b45913ec40cd9a1910c077ef562ccd 100644
--- a/src/lattice.cpp
+++ b/src/lattice.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -21,15 +21,17 @@
 #include "memory.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define MIN(A,B) ((A) < (B)) ? (A) : (B)
 #define MAX(A,B) ((A) > (B)) ? (A) : (B)
 #define BIG 1.0e30
 
-enum {NONE,SC,BCC,FCC,DIAMOND,SQ,SQ2,HEX,USER};
+enum{NONE,SC,BCC,FCC,DIAMOND,SQ,SQ2,HEX,USER};
 
 /* ---------------------------------------------------------------------- */
 
-Lattice::Lattice(int narg, char **arg)
+Lattice::Lattice(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp)
 {
   // parse style arg
 
diff --git a/src/lattice.h b/src/lattice.h
index 932adde0ca30b972ad146a4817fee28c6744faf5..f34e5474f389d20ca80f9b53698d85c224d8e6f7 100644
--- a/src/lattice.h
+++ b/src/lattice.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -14,16 +14,18 @@
 #ifndef LATTICE_H
 #define LATTICE_H
 
-#include "lammps.h"
+#include "pointers.h"
 
-class Lattice : public LAMMPS {
+namespace LAMMPS_NS {
+
+class Lattice : protected Pointers {
  public:
   int style;                           // enum list of NONE,SC,FCC,etc
   double xlattice,ylattice,zlattice;   // lattice scale factors in 3 dims
   int nbasis;                          // # of atoms in basis of unit cell
   double **basis;                      // fractional coords of each basis atom
                                        // within unit cell (0 <= coord < 1)
-  Lattice(int, char **);
+  Lattice(class LAMMPS *, int, char **);
   ~Lattice();
   void lattice2box(double &, double &, double &);
   void box2lattice(double &, double &, double &);
@@ -52,4 +54,6 @@ private:
   void cross(double *, double *, double *);
 };
 
+}
+
 #endif
diff --git a/src/library.cpp b/src/library.cpp
index b3d604a8aac37b347649ec17621d1345302b3c34..d341a33725dc71e4f4fef82fc8dfd6aa791a7118 100644
--- a/src/library.cpp
+++ b/src/library.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -11,8 +11,8 @@
    See the README file in the top-level LAMMPS directory.
 ------------------------------------------------------------------------- */
 
-// LAMMPS as a library that can be called from another program
-// C-style interface
+// C or Fortran style library interface to LAMMPS
+// new LAMMPS-specific functions can be added
 
 #include "mpi.h"
 #include "library.h"
@@ -20,58 +20,68 @@
 #include "input.h"
 #include "atom.h"
 
-// variable visible to all library functions
-
-LAMMPS *lammps;
+using namespace LAMMPS_NS;
 
 /* ----------------------------------------------------------------------
-   minimal library interface functions
+   create an instance of LAMMPS and return pointer to it
+   pass in command-line args and MPI communicator to run on
 ------------------------------------------------------------------------- */
 
-void lammps_open(int argc, char **argv, MPI_Comm communicator)
+void lammps_open(int argc, char **argv, MPI_Comm communicator, void **ptr)
 {
-  lammps = new LAMMPS();
-  lammps->open(argc,argv,communicator);
+  LAMMPS *lammps = new LAMMPS(argc,argv,communicator);
+  *ptr = (void *) lammps;
 }
 
-/* ---------------------------------------------------------------------- */
+/* ----------------------------------------------------------------------
+   destruct an instance of LAMMPS
+------------------------------------------------------------------------- */
 
-void lammps_close()
+void lammps_close(void *ptr)
 {
-  lammps->close();
+  LAMMPS *lammps = (LAMMPS *) ptr;
   delete lammps;
 }
 
-/* ---------------------------------------------------------------------- */
+/* ----------------------------------------------------------------------
+   process an input script in filename str
+------------------------------------------------------------------------- */
 
-void lammps_file(char *str)
+void lammps_file(void *ptr, char *str)
 {
+  LAMMPS *lammps = (LAMMPS *) ptr;
   lammps->input->file(str);
 }
 
-/* ---------------------------------------------------------------------- */
+/* ----------------------------------------------------------------------
+   process a single input command in str
+------------------------------------------------------------------------- */
 
-char *lammps_command(char *str)
+char *lammps_command(void *ptr, char *str)
 {
+  LAMMPS *lammps = (LAMMPS *) ptr;
   return lammps->input->one(str);
 }
 
 /* ----------------------------------------------------------------------
-   add application-specific library functions here
+   add LAMMPS-specific library functions
+   all must receive LAMMPS pointer as argument
 ------------------------------------------------------------------------- */
 
 /* ---------------------------------------------------------------------- */
 
-int lammps_get_natoms()
+int lammps_get_natoms(void *ptr)
 {
+  LAMMPS *lammps = (LAMMPS *) ptr;
   int natoms = static_cast<int> (lammps->atom->natoms);
   return natoms;
 }
 
 /* ---------------------------------------------------------------------- */
 
-void lammps_get_coords(double *coords)
+void lammps_get_coords(void *ptr, double *coords)
 {
+  LAMMPS *lammps = (LAMMPS *) ptr;
   int natoms = static_cast<int> (lammps->atom->natoms);
   double *copy = new double[3*natoms];
   for (int i = 0; i < 3*natoms; i++) copy[i] = 0.0;
@@ -95,12 +105,12 @@ void lammps_get_coords(double *coords)
 
 /* ---------------------------------------------------------------------- */
 
-void lammps_put_coords(double *coords)
+void lammps_put_coords(void *ptr, double *coords)
 {
+  LAMMPS *lammps = (LAMMPS *) ptr;
   int natoms = static_cast<int> (lammps->atom->natoms);
 
   double **x = lammps->atom->x;
-  int nlocal = lammps->atom->nlocal;
 
   int m,offset;
   for (int i = 0; i < natoms; i++) {
diff --git a/src/library.h b/src/library.h
index 383a74136608184821ec3e8056c5478a492f5b8d..0e9d377e33b57eaea0c089e93c35d81a670886e7 100644
--- a/src/library.h
+++ b/src/library.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -11,20 +11,29 @@
    See the README file in the top-level LAMMPS directory.
 ------------------------------------------------------------------------- */
 
-// library interface to LAMMPS
-// new application-specific functions can be added
+/* 
+   C or Fortran style library interface to LAMMPS
+   new LAMMPS-specific functions can be added
+*/
 
 #include "mpi.h"
 
+/* ifdef allow this file to be included in a C program */
+
+#ifdef __cplusplus
 extern "C" {
+#endif
 
-void lammps_open(int, char **, MPI_Comm); // start LAMMPS w/ command-line args
-void lammps_close();                      // shut-down LAMMPS
-void lammps_file(char *);                 // execute an input script
-char *lammps_command(char *);             // execute a single LAMMPS command
+void lammps_open(int, char **, MPI_Comm, void **);  /* start-up LAMMPS */
+void lammps_close(void *);                          /* shut-down LAMMPS */
+void lammps_file(void *, char *);                   /* run an input script */
+char *lammps_command(void *, char *);               /* execute a command */
 
-int lammps_get_natoms();               // return # of atoms
-void lammps_get_coords(double *);      // retrieve atom coords from all procs
-void lammps_put_coords(double *);      // overwrite atom coords on all procs
+int lammps_get_natoms(void *);              /* return # of atoms */
+void lammps_get_coords(void *, double *);   /* get atom x from all procs */
+void lammps_put_coords(void *, double *);   /* put atom x on all procs */
 
+#ifdef __cplusplus
 }
+#endif
+
diff --git a/src/main.cpp b/src/main.cpp
index 034a864e4e53da4ac26bf6cafaaba1af8cd734e2..a3764872ec02e8898cb7dae934012464fd7bef1d 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -15,6 +15,8 @@
 #include "lammps.h"
 #include "input.h"
 
+using namespace LAMMPS_NS;
+
 /* ----------------------------------------------------------------------
    main program to drive LAMMPS
 ------------------------------------------------------------------------- */
@@ -23,10 +25,8 @@ int main(int argc, char **argv)
 {
   MPI_Init(&argc,&argv);
 
-  LAMMPS *lammps = new LAMMPS();
-  lammps->open(argc,argv,MPI_COMM_WORLD);
+  LAMMPS *lammps = new LAMMPS(argc,argv,MPI_COMM_WORLD);
   lammps->input->file();
-  lammps->close();
   delete lammps;
 
   MPI_Finalize();
diff --git a/src/memory.cpp b/src/memory.cpp
index 0ff88da3495e18935d30c76aced936230a476e7d..930e08bf02e704a29ec93cc99fc89438a7ea7e96 100644
--- a/src/memory.cpp
+++ b/src/memory.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -18,6 +18,12 @@
 #include "memory.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
+/* ---------------------------------------------------------------------- */
+
+Memory::Memory(LAMMPS *lmp) : Pointers(lmp) {}
+
 /* ----------------------------------------------------------------------
    safe malloc 
 ------------------------------------------------------------------------- */
@@ -428,5 +434,3 @@ void Memory::destroy_4d_double_array(double ****array)
   sfree(array[0]);
   sfree(array);
 }
-
-
diff --git a/src/memory.h b/src/memory.h
index 62cf2484e2f336995fe31cc287e076aec62d7e59..e5f2cf73daf81e9b9349b0bc7ca7e628049d00a9 100644
--- a/src/memory.h
+++ b/src/memory.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -14,12 +14,13 @@
 #ifndef MEMORY_H
 #define MEMORY_H
 
-#include "lammps.h"
+#include "pointers.h"
 
-class Memory : public LAMMPS {
+namespace LAMMPS_NS {
+
+class Memory : protected Pointers {
  public:
-  Memory() {}
-  ~Memory() {}
+  Memory(class LAMMPS *);
 
   void *smalloc(int n, char *);
   void sfree(void *);
@@ -56,5 +57,6 @@ class Memory : public LAMMPS {
   void destroy_4d_double_array(double ****);
 };
 
-#endif
+}
 
+#endif
diff --git a/src/memory.hold.h b/src/memory.hold.h
deleted file mode 100644
index 596b0bf0af32908a4fbc55fb7866285e8338447c..0000000000000000000000000000000000000000
--- a/src/memory.hold.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/* ----------------------------------------------------------------------
-   LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
-
-   Copyright (2003) Sandia Corporation.  Under the terms of Contract
-   DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
-   certain rights in this software.  This software is distributed under 
-   the GNU General Public License.
-
-   See the README file in the top-level LAMMPS directory.
-------------------------------------------------------------------------- */
-
-#ifndef MEMORY_H
-#define MEMORY_H
-
-#include "lammps.h"
-
-class Memory : public LAMMPS {
- public:
-  Memory() {}
-  ~Memory() {}
-
-  void *smalloc(int n, char *);
-  void sfree(void *);
-  void *srealloc(void *, int n, char *name);
-
-  double *create_1d_double_array(int, int, char *);
-  void destroy_1d_double_array(double *, int);
-  
-  double **create_2d_double_array(int, int, char *);
-  void destroy_2d_double_array(double **);
-  double **grow_2d_double_array(double **, int, int, char *);
-
-  int **create_2d_int_array(int, int, char *);
-  void destroy_2d_int_array(int **);
-  int **grow_2d_int_array(int **, int, int, char *);
-
-  double **create_2d_double_array(int, int, int, char *);
-  void destroy_2d_double_array(double **, int);
-
-  double ***create_3d_double_array(int, int, int, char *);
-  void destroy_3d_double_array(double ***);
-  double ***grow_3d_double_array(double ***, int, int, int, char *);
-
-  double ***create_3d_double_array(int, int, int, int, char *);
-  void destroy_3d_double_array(double ***, int);
-
-  double ***create_3d_double_array(int, int, int, int, int, int, char *);
-  void destroy_3d_double_array(double ***, int, int, int);
-};
-
-#endif
diff --git a/src/min.cpp b/src/min.cpp
index 745a68bc107fd4e4c79fa4c1159fe36a303bd54d..de282eefd7d2ead870b1f8936a03bbef3d61daf4 100644
--- a/src/min.cpp
+++ b/src/min.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,12 +16,14 @@
 #include "min.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define SCAN   0   // same as in min_cg.cpp
 #define SECANT 1
 
 /* ---------------------------------------------------------------------- */
 
-Min::Min()
+Min::Min(LAMMPS *lmp) : Pointers(lmp)
 {
   linestyle = SECANT;
   dmin = 1.0e-5;
diff --git a/src/min.h b/src/min.h
index 26d1c147db4e81683da56c79ba7db5092175f060..afd46984931e00aaeae2ec134b27c5b437df2c47 100644
--- a/src/min.h
+++ b/src/min.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -14,9 +14,11 @@
 #ifndef MIN_H
 #define MIN_H
 
-#include "lammps.h"
+#include "pointers.h"
 
-class Min : public LAMMPS {
+namespace LAMMPS_NS {
+
+class Min : protected Pointers {
  public:
   double einitial,efinal,eprevious;
   double gnorm2_init,gnorminf_init,gnorm2_final,gnorminf_final;
@@ -24,7 +26,7 @@ class Min : public LAMMPS {
   double dmin,dmax;
   int linestyle,lineiter;
 
-  Min();
+  Min(class LAMMPS *);
   virtual ~Min() {}
   virtual void init() = 0;
   virtual void run() = 0;
@@ -33,4 +35,6 @@ class Min : public LAMMPS {
   void modify_params(int, char **);
 };
 
+}
+
 #endif
diff --git a/src/min_cg.cpp b/src/min_cg.cpp
index 4750d147d01a4ef1815173ebf7e119aa378b98b1..44abd303e799d3ae1f8510b68e95b5c7fd0b3f37 100644
--- a/src/min_cg.cpp
+++ b/src/min_cg.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -36,12 +36,13 @@
 #include "thermo.h"
 #include "update.h"
 #include "modify.h"
-#include "fix.h"
 #include "fix_minimize.h"
 #include "timer.h"
 #include "memory.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define MIN(A,B) ((A) < (B)) ? (A) : (B)
 #define MAX(A,B) ((A) > (B)) ? (A) : (B)
 
@@ -52,9 +53,11 @@
 #define SCAN   0   // same as in min.cpp
 #define SECANT 1
 
-/* ----------------------------------------------------------------------
-   initialization before run 
-------------------------------------------------------------------------- */
+/* ---------------------------------------------------------------------- */
+
+MinCG::MinCG(LAMMPS *lmp) : Min(lmp) {}
+
+/* ---------------------------------------------------------------------- */
 
 void MinCG::init()
 {
@@ -67,9 +70,7 @@ void MinCG::init()
   fixarg[2] = "MINIMIZE";
   modify->add_fix(3,fixarg);
   delete [] fixarg;
-
-  for (int i = 0; i < modify->nfix; i++)
-    if (strcmp(modify->fix[i]->style,"MINIMIZE") == 0) ifix_minimize = i;
+  fix_minimize = (FixMinimize *) modify->fix[modify->nfix-1];
 
   // zero gradient vectors before first atom exchange
 
@@ -92,7 +93,7 @@ void MinCG::init()
   granflag = 0;
   if (atom->check_style("granular")) granflag = 1;
   pairflag = 1;
-  if (strcmp(atom->style,"granular") == 0) pairflag = 0;
+  if (strcmp(atom->atom_style,"granular") == 0) pairflag = 0;
 
   // reset reneighboring criteria if necessary
 
@@ -132,7 +133,6 @@ void MinCG::run()
 
   setup();
   setup_vectors();
-  output->thermo->fix_compute_pe();
   output->thermo->compute_pe();
   ecurrent = output->thermo->potential_energy;
 
@@ -337,9 +337,9 @@ void MinCG::iterate(int n)
 void MinCG::setup_vectors()
 {
   ndof = 3 * atom->nlocal;
-  if (ndof) g = ((FixMinimize *) modify->fix[ifix_minimize])->gradient[0];
+  if (ndof) g = fix_minimize->gradient[0];
   else g = NULL;
-  if (ndof) h = ((FixMinimize *) modify->fix[ifix_minimize])->searchdir[0];
+  if (ndof) h = fix_minimize->searchdir[0];
   else h = NULL;
 }
 
@@ -415,7 +415,6 @@ void MinCG::eng_force(int *pndof, double **px, double **ph, double *peng)
 
   // compute potential energy of system via Thermo
 
-  output->thermo->fix_compute_pe();
   output->thermo->compute_pe();
   ecurrent = output->thermo->potential_energy;
 
diff --git a/src/min_cg.h b/src/min_cg.h
index 5d7e57be4d195c239f1f56ed0f617c8100b8a3f4..f8fcfaaf9e396afa66196e5d354018858897c790 100644
--- a/src/min_cg.h
+++ b/src/min_cg.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,10 +16,11 @@
 
 #include "min.h"
 
+namespace LAMMPS_NS {
+
 class MinCG : public Min {
  public:
-  MinCG() {}
-  virtual ~MinCG() {}
+  MinCG(class LAMMPS *);
   void init();
   void run();
 
@@ -33,9 +34,9 @@ class MinCG : public Min {
   int maxpair;            // copies of Update quantities
   double **f_pair;
 
-  int ifix_minimize;      // fix that stores gradient vecs
-  double ecurrent;        // current potential energy
-  double mindist,maxdist; // min/max dist for any coord delta in line search
+  class FixMinimize *fix_minimize;  // fix that stores gradient vecs
+  double ecurrent;            // current potential energy
+  double mindist,maxdist;     // min/max dist for coord delta in line search
 
   int ndof;               // # of degrees-of-freedom on this proc
   double *g,*h;           // local portion of gradient, searchdir vectors
@@ -55,4 +56,6 @@ class MinCG : public Min {
   void force_clear(int);
 };
 
+}
+
 #endif
diff --git a/src/min_cg_fr.cpp b/src/min_cg_fr.cpp
index 5c14525ab3a41768118f29f05952915c98031107..fbac308558eaed63e53849b2a0341e088af17c2d 100644
--- a/src/min_cg_fr.cpp
+++ b/src/min_cg_fr.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -19,11 +19,17 @@
 #include "output.h"
 #include "timer.h"
 
+using namespace LAMMPS_NS;
+
 #define MIN(A,B) ((A) < (B)) ? (A) : (B)
 #define MAX(A,B) ((A) > (B)) ? (A) : (B)
 
 #define EPS       1.0e-6
 
+/* ---------------------------------------------------------------------- */
+
+MinCGFR::MinCGFR(LAMMPS *lmp) : MinCG(lmp) {}
+
 /* ----------------------------------------------------------------------
    minimization via conjugate gradient iterations
    Fletcher-Reeves formulation
diff --git a/src/min_cg_fr.h b/src/min_cg_fr.h
index 09be190f2920813c5ce35dc0d4a90d123a48635a..d82dfeae7ec94b10c25b8381930e49e018098d76 100644
--- a/src/min_cg_fr.h
+++ b/src/min_cg_fr.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,9 +16,14 @@
 
 #include "min_cg.h"
 
+namespace LAMMPS_NS {
+
 class MinCGFR : public MinCG {
  public:
+  MinCGFR(class LAMMPS *lmp);
   void iterate(int);
 };
 
+}
+
 #endif
diff --git a/src/min_sd.cpp b/src/min_sd.cpp
index db7db43e661d9679d0bced74aa0c246493b6cc92..83a678af10c3446a9356156875eed9ddc6067d89 100644
--- a/src/min_sd.cpp
+++ b/src/min_sd.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -19,8 +19,14 @@
 #include "output.h"
 #include "timer.h"
 
+using namespace LAMMPS_NS;
+
 #define EPS       1.0e-6
 
+/* ---------------------------------------------------------------------- */
+
+MinSD::MinSD(LAMMPS *lmp) : MinCG(lmp) {}
+
 /* ----------------------------------------------------------------------
    minimization via steepest descent
 ------------------------------------------------------------------------- */
diff --git a/src/min_sd.h b/src/min_sd.h
index 84f4fd04c24c5eca42c335e3d11deaaa7a171b33..70f7add92cac857574e5316d6e536c6cc54ec925 100644
--- a/src/min_sd.h
+++ b/src/min_sd.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,9 +16,14 @@
 
 #include "min_cg.h"
 
+namespace LAMMPS_NS {
+
 class MinSD : public MinCG {
  public:
+  MinSD(class LAMMPS *);
   void iterate(int);
 };
 
+}
+
 #endif
diff --git a/src/minimize.cpp b/src/minimize.cpp
index 0af5dc78e290744bb8e2635ee766a33b864cf608..d35c1cfd590a89546163c32f2f2933dda76e7870 100644
--- a/src/minimize.cpp
+++ b/src/minimize.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -13,13 +13,18 @@
 
 #include "stdlib.h"
 #include "minimize.h"
-#include "system.h"
 #include "domain.h"
 #include "update.h"
 #include "min.h"
 #include "finish.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
+/* ---------------------------------------------------------------------- */
+
+Minimize::Minimize(LAMMPS *lmp) : Pointers(lmp) {}
+
 /* ---------------------------------------------------------------------- */
 
 void Minimize::command(int narg, char **arg)
@@ -38,10 +43,10 @@ void Minimize::command(int narg, char **arg)
 
   update->whichflag = 1;
 
-  sys->init();
+  lmp->init();
   update->minimize->run();
 
-  Finish finish;
+  Finish finish(lmp);
   finish.end(1);
   update->whichflag = -1;
 }
diff --git a/src/minimize.h b/src/minimize.h
index e177d95a4acb4b40008cd02664a090e888e709f3..3f0c86eba85daf7b81f65793a845baedba356572 100644
--- a/src/minimize.h
+++ b/src/minimize.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -14,13 +14,16 @@
 #ifndef MINIMIZE_H
 #define MINIMIZE_H
 
-#include "lammps.h"
+#include "pointers.h"
 
-class Minimize : public LAMMPS {
+namespace LAMMPS_NS {
+
+class Minimize : protected Pointers {
  public:
-  Minimize() {}
-  ~Minimize() {}
+  Minimize(class LAMMPS *);
   void command(int, char **);
 };
 
+}
+
 #endif
diff --git a/src/modify.cpp b/src/modify.cpp
index 48b6cbe220e003b446f68be850cca605f402ee4a..cc8415db5b892ce32d4a25dd966cfc4282fd83a6 100644
--- a/src/modify.cpp
+++ b/src/modify.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -17,19 +17,24 @@
 #include "atom.h"
 #include "comm.h"
 #include "fix.h"
+#include "compute.h"
 #include "group.h"
 #include "update.h"
 #include "domain.h"
 #include "memory.h"
 #include "error.h"
 
+#define ComputeInclude
 #define FixInclude
 #include "style.h"
+#undef ComputeInclude
 #undef FixInclude
 
-#define DELTA 1
+using namespace LAMMPS_NS;
 
-// mask settings - same as mask settings in fix.cpp
+#define DELTA 4
+
+// mask settings - same as in fix.cpp
 
 #define INITIAL_INTEGRATE  1
 #define PRE_EXCHANGE       2
@@ -37,22 +42,20 @@
 #define POST_FORCE         8
 #define FINAL_INTEGRATE   16
 #define END_OF_STEP       32
-#define THERMO            64
+#define THERMO_ENERGY     64
 #define INITIAL_INTEGRATE_RESPA 128
 #define POST_FORCE_RESPA        256
 #define FINAL_INTEGRATE_RESPA   512
 #define MIN_POST_FORCE         1024
 
-enum {NEITHER,PRINT,ENERGY,BOTH};   // same as thermo.cpp
-
 /* ---------------------------------------------------------------------- */
 
-Modify::Modify()
+Modify::Modify(LAMMPS *lmp) : Pointers(lmp)
 {
   nfix = maxfix = 0;
   n_initial_integrate = 0;
   n_pre_exchange = n_pre_neighbor = 0;
-  n_post_force = n_final_integrate = n_end_of_step = n_thermo = 0;
+  n_post_force = n_final_integrate = n_end_of_step = n_thermo_energy = 0;
   n_initial_integrate_respa = n_post_force_respa = n_final_integrate_respa = 0;
   n_min_post_force = 0;
 
@@ -61,7 +64,7 @@ Modify::Modify()
   list_initial_integrate = NULL;
   list_pre_exchange = list_pre_neighbor = NULL;
   list_post_force = list_final_integrate = list_end_of_step = NULL;
-  list_thermo = NULL;
+  list_thermo_energy = NULL;
   list_initial_integrate_respa = list_post_force_respa = NULL;
   list_final_integrate_respa = NULL;
   list_min_post_force = NULL;
@@ -73,6 +76,9 @@ Modify::Modify()
   nfix_restart_peratom = 0;
   id_restart_peratom = style_restart_peratom = NULL;
   index_restart_peratom = NULL;
+
+  ncompute = maxcompute = 0;
+  compute = NULL;
 }
 
 /* ---------------------------------------------------------------------- */
@@ -80,9 +86,9 @@ Modify::Modify()
 Modify::~Modify()
 {
   // delete all fixes
-  // don't invoke atom->update_callback() since atom has already been deleted
+  // do it via delete_fix() so callbacks in Atom are also updated correctly
 
-  for (int i = 0; i < nfix; i++) delete fix[i];
+  while (nfix) delete_fix(fix[0]->id);
   memory->sfree(fix);
   memory->sfree(fmask);
 
@@ -92,7 +98,7 @@ Modify::~Modify()
   delete [] list_post_force;
   delete [] list_final_integrate;
   delete [] list_end_of_step;
-  delete [] list_thermo;
+  delete [] list_thermo_energy;
   delete [] list_initial_integrate_respa;
   delete [] list_post_force_respa;
   delete [] list_final_integrate_respa;
@@ -101,10 +107,15 @@ Modify::~Modify()
   delete [] end_of_step_every;
 
   restart_deallocate();
+
+  // delete all computes
+
+  for (int i = 0; i < ncompute; i++) delete compute[i];
+  memory->sfree(compute);
 }
 
 /* ----------------------------------------------------------------------
-   initialize all fixes and lists of fixes
+   initialize all fixes and computes
 ------------------------------------------------------------------------- */
 
 void Modify::init()
@@ -128,7 +139,7 @@ void Modify::init()
   list_init(POST_FORCE,n_post_force,list_post_force);
   list_init(FINAL_INTEGRATE,n_final_integrate,list_final_integrate);
   list_init_end_of_step(END_OF_STEP,n_end_of_step,list_end_of_step);
-  list_init_thermo(THERMO,n_thermo,list_thermo);
+  list_init_thermo_energy(THERMO_ENERGY,n_thermo_energy,list_thermo_energy);
 
   list_init(INITIAL_INTEGRATE_RESPA,
 	    n_initial_integrate_respa,list_initial_integrate_respa);
@@ -138,6 +149,10 @@ void Modify::init()
 	    n_final_integrate_respa,list_final_integrate_respa);
 
   list_init(MIN_POST_FORCE,n_min_post_force,list_min_post_force);
+
+  // init each compute
+
+  for (i = 0; i < ncompute; i++) compute[i]->init();
 }
 
 /* ----------------------------------------------------------------------
@@ -215,45 +230,17 @@ void Modify::end_of_step()
 }
 
 /* ----------------------------------------------------------------------
-   thermo_fields call only for relevant fixes
-   called with n = 0, just query how many fields each fix returns
-   called with n > 0, get the field names
+   thermo energy call only for relevant fixes
+   called by Thermo clas
+   arg to Fix thermo() is 0, so fix will return its energy contribution
 ------------------------------------------------------------------------- */
 
-int Modify::thermo_fields(int n, int *flags, char **keywords)
+double Modify::thermo_energy()
 {
-  int i,j,nfirst,flag_print,flag_energy;
-
-  int m = 0;
-  if (n == 0)
-    for (i = 0; i < n_thermo; i++)
-      m += fix[list_thermo[i]]->thermo_fields(0,NULL,NULL);
-  else
-    for (i = 0; i < n_thermo; i++) {
-      nfirst = m;
-      m += fix[list_thermo[i]]->thermo_fields(n,&flags[m],&keywords[m]);
-      for (j = nfirst; j < m; j++) {
-	if (fix[list_thermo[i]]->thermo_print && 
-	    (flags[j] == PRINT || flags[j] == BOTH)) flag_print = PRINT;
-	else flag_print = NEITHER;
-	if (fix[list_thermo[i]]->thermo_energy && 
-	    (flags[j] == ENERGY || flags[j] == BOTH)) flag_energy = ENERGY;
-	else flag_energy = NEITHER;
-	flags[j] = flag_print + flag_energy;
-      }
-    }
-  return m;
-}
-
-/* ----------------------------------------------------------------------
-   thermo_compute call only for relevant fixes
-------------------------------------------------------------------------- */
-
-void Modify::thermo_compute(double *values)
-{
-  int m = 0;
-  for (int i = 0; i < n_thermo; i++)
-    m += fix[list_thermo[i]]->thermo_compute(&values[m]);
+  double energy = 0.0;
+  for (int i = 0; i < n_thermo_energy; i++)
+    energy += fix[list_thermo_energy[i]]->thermo(0);
+  return energy;
 }
 
 /* ----------------------------------------------------------------------
@@ -351,7 +338,7 @@ void Modify::add_fix(int narg, char **arg)
 
 #define FixClass
 #define FixStyle(key,Class) \
-  else if (strcmp(arg[2],#key) == 0) fix[ifix] = new Class(narg,arg);
+  else if (strcmp(arg[2],#key) == 0) fix[ifix] = new Class(lmp,narg,arg);
 #include "style.h"
 #undef FixClass
 
@@ -416,20 +403,15 @@ void Modify::modify_fix(int narg, char **arg)
 
 /* ----------------------------------------------------------------------
    delete a Fix from list of Fixes
+   Atom class must update indices in its list of callbacks to fixes
 ------------------------------------------------------------------------- */
 
 void Modify::delete_fix(char *id)
 {
-  int ifix;
-
-  // find which fix it is and delete it
-
-  for (ifix = 0; ifix < nfix; ifix++)
-    if (strcmp(id,fix[ifix]->id) == 0) break;
-  if (ifix == nfix) error->all("Could not find unfix ID");
-
+  int ifix = find_fix(id);
+  if (ifix < 0) error->all("Could not find fix ID to delete");
   delete fix[ifix];
-  if (atom) atom->update_callback(ifix);
+  atom->update_callback(ifix);
 
   // move other Fixes and fmask down in list one slot
 
@@ -438,6 +420,107 @@ void Modify::delete_fix(char *id)
   nfix--;
 }
 
+/* ----------------------------------------------------------------------
+   find a fix by ID
+   return index of fix or -1 if not found
+------------------------------------------------------------------------- */
+
+int Modify::find_fix(char *id)
+{
+  int ifix;
+  for (ifix = 0; ifix < nfix; ifix++)
+    if (strcmp(id,fix[ifix]->id) == 0) break;
+  if (ifix == nfix) return -1;
+  return ifix;
+}
+
+/* ----------------------------------------------------------------------
+   add a new compute
+------------------------------------------------------------------------- */
+
+void Modify::add_compute(int narg, char **arg)
+{
+  if (narg < 3) error->all("Illegal compute command");
+
+  // error checks
+
+  for (int icompute = 0; icompute < ncompute; icompute++)
+    if (strcmp(arg[0],compute[icompute]->id) == 0)
+      error->all("Reuse of compute ID");
+  int igroup = group->find(arg[1]);
+  if (igroup == -1) error->all("Could not find compute group ID");
+
+  // extend Compute list if necessary
+
+  if (ncompute == maxcompute) {
+    maxcompute += DELTA;
+    compute = (Compute **)
+      memory->srealloc(compute,maxcompute*sizeof(Compute *),"modify:compute");
+  }
+
+  // create the Compute
+
+  if (0) return;         // dummy line to enable else-if macro expansion
+
+#define ComputeClass
+#define ComputeStyle(key,Class) \
+  else if (strcmp(arg[2],#key) == 0) \
+    compute[ncompute] = new Class(lmp,narg,arg);
+#include "style.h"
+
+  else error->all("Invalid compute style");
+
+  ncompute++;
+}
+
+/* ----------------------------------------------------------------------
+   modify a Compute's parameters
+------------------------------------------------------------------------- */
+
+void Modify::modify_compute(int narg, char **arg)
+{
+  if (narg < 2) error->all("Illegal compute_modify command");
+
+  // lookup Compute ID
+
+  int icompute;
+  for (icompute = 0; icompute < ncompute; icompute++)
+    if (strcmp(arg[0],compute[icompute]->id) == 0) break;
+  if (icompute == ncompute) error->all("Could not find compute_modify ID");
+  
+  compute[icompute]->modify_params(narg-1,&arg[1]);
+}
+
+/* ----------------------------------------------------------------------
+   delete a Compute from list of Computes
+------------------------------------------------------------------------- */
+
+void Modify::delete_compute(char *id)
+{
+  int icompute = find_compute(id);
+  if (icompute < 0) error->all("Could not find compute ID to delete");
+  delete compute[icompute];
+
+  // move other Computes down in list one slot
+
+  for (int i = icompute+1; i < ncompute; i++) compute[i-1] = compute[i];
+  ncompute--;
+}
+
+/* ----------------------------------------------------------------------
+   find a compute by ID
+   return index of compute or -1 if not found
+------------------------------------------------------------------------- */
+
+int Modify::find_compute(char *id)
+{
+  int icompute;
+  for (icompute = 0; icompute < ncompute; icompute++)
+    if (strcmp(id,compute[icompute]->id) == 0) break;
+  if (icompute == ncompute) return -1;
+  return icompute;
+}
+
 /* ----------------------------------------------------------------------
    write to restart file for all Fixes with restart info
    (1) fixes that have global state
@@ -648,22 +731,22 @@ void Modify::list_init_end_of_step(int mask, int &n, int *&list)
 }
 
 /* ----------------------------------------------------------------------
-   create list of fix indices for thermo fixes
-   also must have thermo print/energy flag set via fix_modify
+   create list of fix indices for thermo energy fixes
+   only added to list if its thermo_energy flag was set via fix_modify
 ------------------------------------------------------------------------- */
 
-void Modify::list_init_thermo(int mask, int &n, int *&list)
+void Modify::list_init_thermo_energy(int mask, int &n, int *&list)
 {
   delete [] list;
+
   n = 0;
   for (int i = 0; i < nfix; i++)
-    if (fmask[i] & mask && (fix[i]->thermo_print || fix[i]->thermo_energy))
-      n++;
+    if (fmask[i] & mask && fix[i]->thermo_energy) n++;
   list = new int[n];
+
   n = 0;
   for (int i = 0; i < nfix; i++)
-    if (fmask[i] & mask && (fix[i]->thermo_print || fix[i]->thermo_energy))
-      list[n++] = i;
+    if (fmask[i] & mask && fix[i]->thermo_energy) list[n++] = i;
 }
 
 /* ----------------------------------------------------------------------
@@ -674,5 +757,6 @@ int Modify::memory_usage()
 {
   int bytes = 0;
   for (int i = 0; i < nfix; i++) bytes += fix[i]->memory_usage();
+  for (int i = 0; i < ncompute; i++) bytes += compute[i]->memory_usage();
   return bytes;
 }
diff --git a/src/modify.h b/src/modify.h
index 612998ff2ef3d9963e26b245c2b757e41f89c6e5..2a6ae0f064e9c4ecdb983d6eb98f751e30c7e40a 100644
--- a/src/modify.h
+++ b/src/modify.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -15,24 +15,26 @@
 #define MODIFY_H
 
 #include "stdio.h"
-#include "lammps.h"
+#include "pointers.h"
 
-class Fix;
+namespace LAMMPS_NS {
 
-class Modify : public LAMMPS {
+class Modify : protected Pointers {
  public:
-  int nfix;
-  int maxfix;
+  int nfix,maxfix;
   int n_initial_integrate,n_pre_decide,n_pre_exchange,n_pre_neighbor;
-  int n_post_force,n_final_integrate,n_end_of_step,n_thermo;
+  int n_post_force,n_final_integrate,n_end_of_step,n_thermo_energy;
   int n_initial_integrate_respa,n_post_force_respa,n_final_integrate_respa;
   int n_min_post_force;
   int nfix_restart_peratom;
 
-  Fix **fix;                 // list of fixes
+  class Fix **fix;           // list of fixes
   int *fmask;                // bit mask for when each fix is applied
 
-  Modify();
+  int ncompute,maxcompute;   // list of computes
+  class Compute **compute;
+
+  Modify(class LAMMPS *);
   ~Modify();
   void init();
   void setup();
@@ -43,8 +45,7 @@ class Modify : public LAMMPS {
   void post_force(int);
   void final_integrate();
   void end_of_step();
-  int thermo_fields(int, int *, char **);
-  void thermo_compute(double *);
+  double thermo_energy();
 
   void initial_integrate_respa(int,int);
   void post_force_respa(int,int,int);
@@ -55,6 +56,12 @@ class Modify : public LAMMPS {
   void add_fix(int, char **);
   void modify_fix(int, char **);
   void delete_fix(char *);
+  int find_fix(char *);
+
+  void add_compute(int, char **);
+  void modify_compute(int, char **);
+  void delete_compute(char *);
+  int find_compute(char *);
 
   void write_restart(FILE *);
   int read_restart(FILE *);
@@ -66,7 +73,8 @@ class Modify : public LAMMPS {
                              // lists of fixes to apply at different times
   int *list_initial_integrate,*list_pre_decide;
   int *list_pre_exchange,*list_pre_neighbor;
-  int *list_post_force,*list_final_integrate,*list_end_of_step,*list_thermo;
+  int *list_post_force,*list_final_integrate,*list_end_of_step;
+  int *list_thermo_energy;
   int *list_initial_integrate_respa,*list_post_force_respa;
   int *list_final_integrate_respa;
   int *list_min_post_force;
@@ -84,7 +92,9 @@ class Modify : public LAMMPS {
 
   void list_init(int, int &, int *&);
   void list_init_end_of_step(int, int &, int *&);
-  void list_init_thermo(int, int &, int *&);
+  void list_init_thermo_energy(int, int &, int *&);
 };
 
+}
+
 #endif
diff --git a/src/neigh_bond.cpp b/src/neigh_bond.cpp
index 71704476aed631278a070bdf3167ad7d578d59e4..57245abd3618e8810444fa6fe0100b74cd8be1d5 100644
--- a/src/neigh_bond.cpp
+++ b/src/neigh_bond.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -18,6 +18,8 @@
 #include "memory.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define BONDDELTA 10000
 
 /* ---------------------------------------------------------------------- */
diff --git a/src/neigh_full.cpp b/src/neigh_full.cpp
index 762e2366522929ba5922da6dd4562e7e0ac9d6dc..91a12246caef0af683f9612726d36fb61ac2e3e8 100644
--- a/src/neigh_full.cpp
+++ b/src/neigh_full.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -15,6 +15,8 @@
 #include "atom.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 /* ----------------------------------------------------------------------
    N^2 search for all neighbors
    every neighbor pair appears in list of both atoms i and j
diff --git a/src/neigh_gran.cpp b/src/neigh_gran.cpp
index 19d4d26e7885893e25f0852f5aeb6143f18f58b1..21d9b380856455b6e28cb70c03aa6624e719fadf 100644
--- a/src/neigh_gran.cpp
+++ b/src/neigh_gran.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -17,6 +17,8 @@
 #include "fix_shear_history.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 /* ----------------------------------------------------------------------
    granular particles
    N^2 / 2 search for neighbor pairs with partial Newton's 3rd law
@@ -36,11 +38,10 @@ void Neighbor::granular_nsq_no_newton()
   int **partner;
   double ***shearpartner;
 
-  if (history >= 0) {
-    npartner = ((FixShearHistory *) modify->fix[history])->npartner;
-    partner = ((FixShearHistory *) modify->fix[history])->partner;
-    shearpartner = 
-      ((FixShearHistory *) modify->fix[history])->shearpartner;
+  if (fix_history) {
+    npartner = fix_history->npartner;
+    partner = fix_history->partner;
+    shearpartner = fix_history->shearpartner;
   }
 
   double **x = atom->x;
@@ -62,13 +63,13 @@ void Neighbor::granular_nsq_no_newton()
       npage++;
       if (npage == maxpage) {
 	add_pages(npage);
-	if (history >= 0) add_pages_history(npage);
+	if (fix_history) add_pages_history(npage);
       }
     }
 
     n = 0;
     neighptr = &pages[npage][npnt];
-    if (history >= 0) {
+    if (fix_history) {
       nn = 0;
       touchptr = &pages_touch[npage][npnt];
       shearptr = &pages_shear[npage][3*npnt];
@@ -94,7 +95,7 @@ void Neighbor::granular_nsq_no_newton()
       if (rsq <= cutsq) {
 	neighptr[n] = j;
 
-	if (history >= 0) {
+	if (fix_history) {
 	  if (rsq < radsum*radsum) {
 	    for (m = 0; m < npartner[i]; m++)
 	      if (partner[i][m] == tag[j]) break;
@@ -121,7 +122,7 @@ void Neighbor::granular_nsq_no_newton()
       }
     }	       
 
-    if (history >= 0) {
+    if (fix_history) {
       firsttouch[i] = touchptr;
       firstshear[i] = shearptr;
     }
@@ -235,11 +236,10 @@ void Neighbor::granular_bin_no_newton()
   int **partner;
   double ***shearpartner;
 
-  if (history >= 0) {
-    npartner = ((FixShearHistory *) modify->fix[history])->npartner;
-    partner = ((FixShearHistory *) modify->fix[history])->partner;
-    shearpartner = 
-      ((FixShearHistory *) modify->fix[history])->shearpartner;
+  if (fix_history) {
+    npartner = fix_history->npartner;
+    partner = fix_history->partner;
+    shearpartner = fix_history->shearpartner;
   }
 
   // bin local & ghost atoms
@@ -266,13 +266,13 @@ void Neighbor::granular_bin_no_newton()
       npage++;
       if (npage == maxpage) {
 	add_pages(npage);
-	if (history >= 0) add_pages_history(npage);
+	if (fix_history) add_pages_history(npage);
       }
     }
 
     n = 0;
     neighptr = &pages[npage][npnt];
-    if (history >= 0) {
+    if (fix_history) {
       nn = 0;
       touchptr = &pages_touch[npage][npnt];
       shearptr = &pages_shear[npage][3*npnt];
@@ -312,7 +312,7 @@ void Neighbor::granular_bin_no_newton()
 	if (rsq <= cutsq) {
 	  neighptr[n] = j;
 
-	  if (history >= 0) {
+	  if (fix_history) {
 	    if (rsq < radsum*radsum) {
 	      for (m = 0; m < npartner[i]; m++)
 		if (partner[i][m] == tag[j]) break;
@@ -342,7 +342,7 @@ void Neighbor::granular_bin_no_newton()
       }
     }
 
-    if (history >= 0) {
+    if (fix_history) {
       firsttouch[i] = touchptr;
       firstshear[i] = shearptr;
     }
diff --git a/src/neigh_half.cpp b/src/neigh_half.cpp
index 38dd6c1d7d1daebf7845ad903fed60cbdc78414f..af0d3c0f1126ba8eeef1b940a2cd715bbaca5b0e 100644
--- a/src/neigh_half.cpp
+++ b/src/neigh_half.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -15,6 +15,8 @@
 #include "atom.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 /* ----------------------------------------------------------------------
    N^2 / 2 search for neighbor pairs with partial Newton's 3rd law
    pair stored once if i,j are both owned and i < j
@@ -425,7 +427,7 @@ void Neighbor::half_full_newton()
 {
   int i,j,k,n,nfull;
   int *neighptr,*neighs;
-  double xtmp,ytmp,ztmp,delx,dely,delz;
+  double xtmp,ytmp,ztmp;
 
   double **x = atom->x;
   int nlocal = atom->nlocal;
diff --git a/src/neigh_respa.cpp b/src/neigh_respa.cpp
index 0a516ca8e8c641e364da243281859392cd9be294..c27d8e6ba29b9799c86a90881c44babc19c4b5e7 100644
--- a/src/neigh_respa.cpp
+++ b/src/neigh_respa.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -15,6 +15,8 @@
 #include "atom.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 /* ----------------------------------------------------------------------
    multiple respa lists
    N^2 / 2 search for neighbor pairs with partial Newton's 3rd law
diff --git a/src/neighbor.cpp b/src/neighbor.cpp
index c7e30009a18383e74e92346eabbd9b85314d8545..d329c2ba0905c649a4abf4110ddbbabba34d03cd 100644
--- a/src/neighbor.cpp
+++ b/src/neighbor.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -18,18 +18,22 @@
 #include "limits.h"
 #include "neighbor.h"
 #include "atom.h"
+#include "atom_vec.h"
 #include "force.h"
 #include "pair.h"
 #include "domain.h"
 #include "group.h"
 #include "modify.h"
 #include "fix.h"
+#include "compute.h"
 #include "update.h"
 #include "respa.h"
 #include "output.h"
 #include "memory.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define PGDELTA 1
 #define LB_FACTOR 1.5
 #define SMALL 1.0e-6
@@ -40,7 +44,7 @@
 
 /* ---------------------------------------------------------------------- */
 
-Neighbor::Neighbor()
+Neighbor::Neighbor(LAMMPS *lmp) : Pointers(lmp)
 {
   MPI_Comm_rank(world,&me);
   MPI_Comm_size(world,&nprocs);
@@ -104,7 +108,7 @@ Neighbor::Neighbor()
 
   // shear history neighbor list info
 
-  history = -1;
+  fix_history = NULL;
   firsttouch = NULL;
   firstshear = NULL;
   pages_touch = NULL;
@@ -174,7 +178,7 @@ Neighbor::~Neighbor()
   for (int i = 0; i < maxpage_full; i++) memory->sfree(pages_full[i]);
   memory->sfree(pages_full);
 
-  if (history >= 0) {
+  if (fix_history) {
     memory->sfree(firsttouch);
     memory->sfree(firstshear);
     for (int i = 0; i < maxpage; i++) memory->sfree(pages_touch[i]);
@@ -264,7 +268,7 @@ void Neighbor::init()
   // flag = 0 if both LJ/Coulomb special values are 0.0
   // flag = 1 if both LJ/Coulomb special values are 1.0
   // flag = 2 otherwise or if KSpace solver is enabled
-  // (pairwise portion of KSpace solver uses all 1-2,1-3,1-4 neighbors)
+  // pairwise portion of KSpace solver uses all 1-2,1-3,1-4 neighbors
 
   if (force->special_lj[1] == 0.0 && force->special_coul[1] == 0.0) 
     special_flag[1] = 0;
@@ -368,6 +372,7 @@ void Neighbor::init()
   // half and full pairwise neighbor lists
 
   // determine whether to build half and full lists
+  // query pair,fix,compute for their requirements
 
   maxlocal = atom->nmax;
   int half_previous = half;
@@ -385,6 +390,11 @@ void Neighbor::init()
     if (modify->fix[i]->neigh_full_once) full_once = 1;
   }
 
+  for (i = 0; i < modify->ncompute; i++) {
+    if (modify->compute[i]->neigh_half_once) half_once = 1;
+    if (modify->compute[i]->neigh_full_once) full_once = 1;
+  }
+
   half = full = 0;
   if (half_every || half_once || half_command) half = 1;
   if (full_every || full_once) full = 1;
@@ -437,15 +447,16 @@ void Neighbor::init()
   }
 
   // setup/delete memory for shear history neighbor lists
-  // history = index of granular shear history fix if it exists
+  // fix_history = granular shear history fix if it exists
   
-  int history_previous = history;
-  history = -1;
+  FixShearHistory *fix_previous = fix_history;
+  fix_history = NULL;
   if (force->pair_match("gran/history") || force->pair_match("gran/hertzian"))
     for (i = 0; i < modify->nfix; i++)
-      if (strcmp(modify->fix[i]->style,"SHEAR_HISTORY") == 0) history = i;
+      if (strcmp(modify->fix[i]->style,"SHEAR_HISTORY") == 0) 
+	fix_history = (FixShearHistory *) modify->fix[i];
 
-  if (history == -1 && history_previous >= 0) {
+  if (fix_history == NULL && fix_previous) {
     memory->sfree(firsttouch);
     memory->sfree(firstshear);
     for (i = 0; i < maxpage; i++) memory->sfree(pages_touch[i]);
@@ -454,12 +465,12 @@ void Neighbor::init()
     memory->sfree(pages_shear);
     pages_touch = NULL;
     pages_shear = NULL;
-  } else if (history >= 0 && history_previous == -1) {
+  } else if (fix_history && fix_previous == NULL) {
     firsttouch = (int **) memory->smalloc(maxlocal*sizeof(int *),"firsttouch");
     firstshear = (double **)
       memory->smalloc(maxlocal*sizeof(double *),"firstshear");
     add_pages_history(0);
-  } else if (history >= 0 && history_previous >= 0) {
+  } else if (fix_history && fix_previous >= 0) {
     memory->sfree(firsttouch);
     memory->sfree(firstshear);
     firsttouch = (int **) memory->smalloc(maxlocal*sizeof(int *),"firsttouch");
@@ -537,7 +548,7 @@ void Neighbor::init()
   // cannot combine granular and rRESPA
 
   if (half) {
-    if (strcmp(atom->style,"granular") == 0) {
+    if (atom->check_style("granular")) {
       if (style == 0) {
 	if (force->newton_pair == 0) 
 	  half_build = &Neighbor::granular_nsq_no_newton;
@@ -629,7 +640,7 @@ void Neighbor::init()
       bond_off = angle_off = 1;
   if (force->bond && force->bond_match("quartic")) bond_off = 1;
 
-  if (atom->bonds_allow) {
+  if (atom->avec->bonds_allow) {
     for (i = 0; i < atom->nlocal; i++) {
       if (bond_off) break;
       for (m = 0; m < atom->num_bond[i]; m++)
@@ -637,7 +648,7 @@ void Neighbor::init()
     }
   }
 
-  if (atom->angles_allow) {
+  if (atom->avec->angles_allow) {
     for (i = 0; i < atom->nlocal; i++) {
       if (angle_off) break;
       for (m = 0; m < atom->num_angle[i]; m++)
@@ -646,7 +657,7 @@ void Neighbor::init()
   }
 
   int dihedral_off = 0;
-  if (atom->dihedrals_allow) {
+  if (atom->avec->dihedrals_allow) {
     for (i = 0; i < atom->nlocal; i++) {
       if (dihedral_off) break;
       for (m = 0; m < atom->num_dihedral[i]; m++)
@@ -655,7 +666,7 @@ void Neighbor::init()
   }
 
   int improper_off = 0;
-  if (atom->impropers_allow) {
+  if (atom->avec->impropers_allow) {
     for (i = 0; i < atom->nlocal; i++) {
       if (improper_off) break;
       for (m = 0; m < atom->num_improper[i]; m++)
@@ -780,7 +791,7 @@ void Neighbor::build()
       memory->smalloc(maxlocal*sizeof(int *),"neigh:firstneigh_full");
     }
 
-    if (history >= 0) {
+    if (fix_history) {
       memory->sfree(firsttouch);
       memory->sfree(firstshear);
       firsttouch = (int **) 
@@ -1136,7 +1147,8 @@ void Neighbor::modify_params(int narg, char **arg)
       } else if (strcmp(arg[iarg+1],"molecule") == 0) {
 	if (iarg+3 > narg) error->all("Illegal neigh_modify command");
 	if (atom->molecular == 0) {
-	  char *str = "Must use molecular atom style with neigh_modify exclude molecule";
+	  char *str = "Must use molecular atom style with"
+	              " neigh_modify exclude molecule";
 	  error->all(str);
 	}
 	if (nex_mol == maxex_mol) {
@@ -1189,7 +1201,7 @@ int Neighbor::memory_usage()
     bytes += maxpage_full*pgsize * sizeof(int);
   }
 
-  if (history >= 0) {
+  if (fix_history) {
     bytes += maxlocal * sizeof(int *);
     bytes += maxlocal * sizeof(double *);
     bytes += maxpage*pgsize * sizeof(int);
diff --git a/src/neighbor.h b/src/neighbor.h
index f41436d74fef417f3564d41d156679f2db9cc07e..794f96109dc0ebedd73bc36d9b2eeac01218f351 100644
--- a/src/neighbor.h
+++ b/src/neighbor.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -14,9 +14,11 @@
 #ifndef NEIGHBOR_H
 #define NEIGHBOR_H
 
-#include "lammps.h"
+#include "pointers.h"
 
-class Neighbor : public LAMMPS {
+namespace LAMMPS_NS {
+
+class Neighbor : protected Pointers {
  public:
   int style;                       // 0 = nsq, 1 = binned
   int every;                       // build every this many steps
@@ -68,7 +70,7 @@ class Neighbor : public LAMMPS {
   int *numneigh_middle;            // # of middle pair neighbors for each atom
   int **firstneigh_middle;         // ptr to middle 1st neigh of each atom
 
-  Neighbor();
+  Neighbor(class LAMMPS *);
   ~Neighbor();
   void init();
   int decide();               // decide whether to build or not
@@ -125,9 +127,9 @@ class Neighbor : public LAMMPS {
   int *stencil_full;               // full neighbor stencil list of bin offsets
   int maxstencil_full;             // size of full neighbor stencil
 
-                                   // granular neighbor list
-  int history;                     // -1 if history not needed
-                                   // else stores fix shear history index
+                                         // granular neighbor list
+  class FixShearHistory *fix_history;    // NULL if history not needed
+                                         // else is ptr to fix shear history
   int **pages_touch;               // pages of touch flags
   double **pages_shear;            // pages of shear values
 
@@ -217,4 +219,6 @@ class Neighbor : public LAMMPS {
   int exclusion(int, int, int *, int *, int *);  // test for pair exclusion
 };
 
+}
+
 #endif
diff --git a/src/output.cpp b/src/output.cpp
index 6570e06bb2372500c6076be4c1cafcd5cb5ab85f..b18021be0a3236deed09a0e9a1c18949315133e9 100644
--- a/src/output.cpp
+++ b/src/output.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -33,6 +33,8 @@
 #include "style.h"
 #undef DumpInclude
 
+using namespace LAMMPS_NS;
+
 #define DELTA 1
 #define MYMIN(a,b) ((a) < (b) ? (a) : (b))
 #define MYMAX(a,b) ((a) > (b) ? (a) : (b))
@@ -41,15 +43,13 @@
    initialize all output 
 ------------------------------------------------------------------------- */
 
-Output::Output()
+Output::Output(LAMMPS *lmp) : Pointers(lmp)
 {
   thermo = NULL;
-  char **thermoarg = new char*[1];
-  thermoarg[0] = new char[strlen("one") + 1];
-  strcpy(thermoarg[0],"one");
-  thermo = new Thermo(1,thermoarg);
-  delete [] thermoarg[0];
-  delete [] thermoarg;
+  char **newarg = new char*[1];
+  newarg[0] = "one";
+  thermo = new Thermo(lmp,1,newarg);
+  delete [] newarg;
     
   thermo_every = 0;
 
@@ -134,7 +134,7 @@ void Output::setup(int flag)
 
   // print memory usage unless being called between multiple runs
 
-  if (flag) print_memory_usage();
+  if (flag) memory_usage();
 
   // always do thermo with header at start of run
   // set next_thermo to multiple of every or last step of run (if smaller)
@@ -247,11 +247,11 @@ void Output::add_dump(int narg, char **arg)
 
   // create the Dump
 
-  if (strcmp(arg[2],"none") == 0) error->all("Invalid dump style");
+  if (0) return;         // dummy line to enable else-if macro expansion
 
 #define DumpClass
 #define DumpStyle(key,Class) \
-  else if (strcmp(arg[2],#key) == 0) dump[ndump] = new Class(narg,arg);
+  else if (strcmp(arg[2],#key) == 0) dump[ndump] = new Class(lmp,narg,arg);
 #include "style.h"
 #undef DumpClass
 
@@ -324,7 +324,7 @@ void Output::create_thermo(int narg, char **arg)
 
   delete thermo;
   thermo = NULL;
-  thermo = new Thermo(narg,arg);
+  thermo = new Thermo(lmp,narg,arg);
 }
 
 /* ----------------------------------------------------------------------
@@ -346,7 +346,7 @@ void Output::create_restart(int narg, char **arg)
     return;
   }
 
-  restart = new WriteRestart;
+  restart = new WriteRestart(lmp);
   last_restart = -1;
 
   int n = strlen(arg[1]) + 3;
@@ -370,7 +370,7 @@ void Output::create_restart(int narg, char **arg)
    is only memory on proc 0, not averaged across procs
 ------------------------------------------------------------------------- */
 
-void Output::print_memory_usage()
+void Output::memory_usage()
 {
   int bytes = 0;
 
diff --git a/src/output.h b/src/output.h
index c70ddc32bd783c4d893808c4e3758aca943f2b16..c6295471d9100944e39f7962469ded1b2ac620f2 100644
--- a/src/output.h
+++ b/src/output.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -14,20 +14,18 @@
 #ifndef OUTPUT_H
 #define OUTPUT_H
 
-#include "lammps.h"
+#include "pointers.h"
 
-class Thermo;
-class Dump;
-class WriteRestart;
+namespace LAMMPS_NS {
 
-class Output : public LAMMPS {
+class Output : protected Pointers {
  public:
   int next;                    // next timestep for any kind of output
 
   int next_thermo;             // next timestep for thermo output
   int thermo_every;            // thermo output every this many steps
   int last_thermo;             // last timestep thermo was output
-  Thermo *thermo;              // Thermodynamic computations
+  class Thermo *thermo;        // Thermodynamic computations
 
   int ndump;                   // # of Dumps defined
   int max_dump;                // max size of Dump list
@@ -35,7 +33,7 @@ class Output : public LAMMPS {
   int *next_dump;              // next timestep to do each Dump
   int *dump_every;             // output of each Dump every this many steps
   int *last_dump;              // last timestep each a snapshot was output
-  Dump **dump;                 // list of defined Dumps
+  class Dump **dump;           // list of defined Dumps
 
   int next_restart;            // next timestep to write a restart file
   int restart_every;           // write a restart file every this many steps
@@ -43,9 +41,9 @@ class Output : public LAMMPS {
   int restart_toggle;          // 0 if use restart1 as prefix
                                // 1 if use restart1 as file, 2 for restart2
   char *restart1,*restart2;    // names for restart files
-  WriteRestart *restart;       // Restart output
+  class WriteRestart *restart; // Restart output
 
-  Output();
+  Output(class LAMMPS *);
   ~Output();
   void init();
   void setup(int);                   // initial output before run/min
@@ -58,7 +56,9 @@ class Output : public LAMMPS {
   void create_thermo(int, char **);  // create a thermo style
   void create_restart(int, char **); // create Restart and restart files
 
-  void print_memory_usage();         // print out memory usage
+  void memory_usage();               // print out memory usage
 };
 
+}
+
 #endif
diff --git a/src/pack.cpp b/src/pack.cpp
index e92d976a1175f44238fa70575de982762e799329..0b6ba908a9e2de208981ca4568a2e6f3ca518db0 100644
--- a/src/pack.cpp
+++ b/src/pack.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
diff --git a/src/pack.h b/src/pack.h
index 123691d4d8007f20045d1fb7591cd4bed5e422e5..bcb6208b2ecf8e5e190f82cdbf47b27c19ab608c 100644
--- a/src/pack.h
+++ b/src/pack.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
diff --git a/src/pair.cpp b/src/pair.cpp
index eb796343f44e5f34659badfaabd9a292e61ba783..0e565dddd42621598864b8c27420dc87c7cf0e98 100644
--- a/src/pair.cpp
+++ b/src/pair.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -24,7 +24,6 @@
 #include "string.h"
 #include "pair.h"
 #include "pair_soft.h"
-#include "pair_eam.h"
 #include "atom.h"
 #include "domain.h"
 #include "comm.h"
@@ -32,34 +31,38 @@
 #include "update.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define MIN(a,b) ((a) < (b) ? (a) : (b))
 #define MAX(a,b) ((a) > (b) ? (a) : (b))
 
-#define GEOMETRIC  0
-#define ARITHMETIC 1
-#define SIXTHPOWER 2
-
-#define R   1
-#define RSQ 2
-#define BMP 3
+enum{GEOMETRIC,ARITHMETIC,SIXTHPOWER};
+enum{R,RSQ,BMP};
 
 /* ---------------------------------------------------------------------- */
 
-Pair::Pair()
+Pair::Pair(LAMMPS *lmp) : Pointers(lmp)
 {
   eng_vdwl = eng_coul = 0.0;
-  allocated = 0;
-  offset_flag = 0;
-  mix_flag = GEOMETRIC;
-  ncoultablebits = 12;
-  tabinner = sqrt(2.0);
-  tail_flag = 0;
-  etail = ptail = etail_ij = ptail_ij = 0.0;
+
+  comm_forward = comm_reverse = 0;
   neigh_half_every = 1;
   neigh_full_every = 0;
+
   single_enable = 1;
   respa_enable = 0;
   one_coeff = 0;
+
+  // pair_modify settings
+
+  offset_flag = 0;
+  mix_flag = GEOMETRIC;
+  tail_flag = 0;
+  etail = ptail = etail_ij = ptail_ij = 0.0;
+  ncoultablebits = 12;
+  tabinner = sqrt(2.0);
+
+  allocated = 0;
 }
 
 /* ----------------------------------------------------------------------
@@ -256,52 +259,43 @@ void Pair::write_file(int narg, char **arg)
       fprintf(fp,"\n%s\nN %d RSQ %g %g\n\n",arg[7],n,inner,outer);
   }
 
-  // setup dummy atom vecs for use by single()
-  
-  double q[2];
-  q[0] = q[1] = 1.0;
-  if (narg == 10) {
-    q[0] = atof(arg[8]);
-    q[1] = atof(arg[9]);
-  }
-  double *qhold;
+  // initialize potentials before evaluating pair potential
+  // insures all pair coeffs are set and force constants
 
-  double eamfp[2];
-  eamfp[0] = eamfp[1] = 0.0;
-  double *eamfphold;
+  force->init();
 
-  // atom and pair styles that need dummy atom vectors
+  // if pair style = soft, set prefactor to final value
 
-  int qflag = atom->charge_allow;
-  PairEAM *eampair = NULL;
-  if (eampair = (PairEAM *) force->pair_match("eam"));
-  else if (eampair = (PairEAM *) force->pair_match("eam/alloy"));
-  else if (eampair = (PairEAM *) force->pair_match("eam/fs"));
+  Pair *spair = force->pair_match("soft");
+  if (spair)
+    ((PairSoft *) spair)->prefactor[itype][jtype] =
+      ((PairSoft *) spair)->prestop[itype][jtype];
 
-  // initialize potentials before evaluating pair potential
-  // insures all pair coeffs are set and force constants
+  // if pair style = EAM, swap in dummy fp vector
 
-  force->init();
+  double eamfp[2];
+  eamfp[0] = eamfp[1] = 0.0;
+  double *eamfp_hold;
 
-  // if pair style = soft, set prefactor used by single()
+  Pair *epair = force->pair_match("eam");
+  if (epair) epair->extract_eam(eamfp,&eamfp_hold);
 
-  Pair *anypair;
-  if (anypair = force->pair_match("soft")) {
-    ((PairSoft *) anypair)->prefactor[itype][jtype] =
-      ((PairSoft *) anypair)->prestop[itype][jtype];
-  }
+  // if atom style defines charge, swap in dummy q vec
 
-  // evaluate energy and force at each of N distances
-  // swap in dummy vecs before, swap them out after
+  double q[2];
+  q[0] = q[1] = 1.0;
+  if (narg == 10) {
+    q[0] = atof(arg[8]);
+    q[1] = atof(arg[9]);
+  }
+  double *q_hold;
 
-  if (qflag) {
-    qhold = atom->q;
+  if (atom->q) {
+    q_hold = atom->q;
     atom->q = q;
   }
-  if (eampair) {
-    eamfphold = eampair->fp;
-    eampair->fp = eamfp;
-  }
+
+  // evaluate energy and force at each of N distances
 
   int masklo,maskhi,nmask,nshiftbits;
   if (style == BMP) {
@@ -343,8 +337,11 @@ void Pair::write_file(int narg, char **arg)
     if (me == 0) fprintf(fp,"%d %g %g %g\n",i+1,r,e,f);
   }
 
-  if (qflag) atom->q = qhold;
-  if (eampair) eampair->fp = eamfphold;
+  // restore original vecs that were swapped in for
+
+  double *tmp;
+  if (epair) epair->extract_eam(eamfp_hold,&tmp);
+  if (atom->q) atom->q = q_hold;
   
   if (me == 0) fclose(fp);
 }
diff --git a/src/pair.h b/src/pair.h
index a0748e09f00d50e01d3fbf6a244245b9201e45a6..5c002819f7d129a3b9057b004a341f5895472d09 100644
--- a/src/pair.h
+++ b/src/pair.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -14,55 +14,54 @@
 #ifndef PAIR_H
 #define PAIR_H
 
-#include "lammps.h"
+#include "pointers.h"
 
-class Pair : public LAMMPS {
+namespace LAMMPS_NS {
+
+class Pair : protected Pointers {
  public:
-                                       // used by other classes
-  double cutforce;                     // max cutoff for all atom pairs
-  double eng_vdwl,eng_coul;            // accumulated energies
-  double virial[6];                    // accumulated virial
+  double eng_vdwl,eng_coul;      // accumulated energies
+  double virial[6];              // accumulated virial
 
-                                       // used by neighbor class
-  int neigh_half_every;                // 0/1 = if needs half neighbor list
-  int neigh_full_every;                // 0/1 = if needs full neighbor list
+  double cutforce;               // max cutoff for all atom pairs
+  double **cutsq;                // max cutoff sq for each atom pair
+  int **setflag;                 // 0/1 = whether each i,j has been set
 
-                                       // common to all pair classes
-  int allocated;                       // 0/1 = whether arrays are allocated
-  int **setflag;                       // 0/1 = whether each i,j has been set
-  double **cutsq;                      // max cutoff sq for each atom pair
+  int comm_forward;              // size of forward communication (0 if none)
+  int comm_reverse;              // size of reverse communication (0 if none)
+  int neigh_half_every;          // 0/1 = if needs half neighbor list
+  int neigh_full_every;          // 0/1 = if needs full neighbor list
 
-                                       // pair modify settings
-  int offset_flag,mix_flag;            // flags for offset and mixing
-  int tail_flag;                       // flag for LJ tail correction
-  double etail,ptail;                  // energy/pressure tail corrections
-  double etail_ij,ptail_ij;
-  int ncoultablebits;                  // size of Coulomb table
-  double tabinner;                     // inner cutoff for Coulomb table
+  int single_enable;             // 1 if single() routine exists
+  int respa_enable;              // 1 if inner/middle/outer rRESPA routines
+  int one_coeff;                 // 1 if allows only one coeff * * call
 
-  int single_enable;                   // 0/1 if single() routine exists
-  int respa_enable;                    // 0/1 if inner/middle/outer routines
-  int one_coeff;                       // 0/1 if allows only one coeff * * call
+  int tail_flag;                 // pair_modify flag for LJ tail correction
+  double etail,ptail;            // energy/pressure tail corrections
+  double etail_ij,ptail_ij;
 
-  struct One {                         // single interaction between 2 atoms
+  struct One {                   // single interaction between 2 atoms
     double fforce;
     double eng_vdwl,eng_coul;
     double fx,fy,fz;
     double tix,tiy,tiz,tjx,tjy,tjz;
   };
 
-  Pair();
+  Pair(class LAMMPS *);
   virtual ~Pair() {}
 
+  // top-level Pair methods
+
   void init();
   double mix_energy(double, double, double, double);
   double mix_distance(double, double);
   void virial_compute();
   void write_file(int, char **);
   void init_bitmap(double, double, int, int &, int &, int &, int &);
-
   virtual void modify_params(int, char **);
 
+  // general child-class methods
+
   virtual void compute(int, int) = 0;
   virtual void settings(int, char **) = 0;
   virtual void coeff(int, char **) = 0;
@@ -74,7 +73,6 @@ class Pair : public LAMMPS {
   virtual void compute_outer(int, int) {}
   virtual void single(int, int, int, int,
 		      double, double, double, int, One &) {}
-  virtual void single_embed(int, int, double &, int, double &) {}
 
   virtual void write_restart(FILE *) {}
   virtual void read_restart(FILE *) {}
@@ -86,6 +84,27 @@ class Pair : public LAMMPS {
   virtual int pack_reverse_comm(int, int, double *) {return 0;}
   virtual void unpack_reverse_comm(int, int *, double *) {}
   virtual int memory_usage() {return 0;}
+
+  // specific child-class methods for certain Pair styles
+  
+  virtual void single_embed(int, int, double &) {}
+  virtual void extract_charmm(double ***, double ***,
+			      double ***, double ***, int *) {}
+  virtual void extract_dipole(double ***) {}
+  virtual void extract_eam(double *, double **) {}
+  virtual void extract_gran(double *, double *, double *, int *) {}
+  virtual void extract_long(double *) {}
+  virtual void extract_tip4p(double *, int *, int *, int *, int *) {}
+
+ protected:
+  int allocated;                       // 0/1 = whether arrays are allocated
+
+                                       // pair_modify settings
+  int offset_flag,mix_flag;            // flags for offset and mixing
+  int ncoultablebits;                  // size of Coulomb table
+  double tabinner;                     // inner cutoff for Coulomb table
 };
 
+}
+
 #endif
diff --git a/src/pair_buck.cpp b/src/pair_buck.cpp
index 9c94a6a95a3d6a12f935b39e6604a2950cb7839f..820ecc948e889fe64f0ef168a94ad75f72a644a4 100644
--- a/src/pair_buck.cpp
+++ b/src/pair_buck.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -23,12 +23,16 @@
 #include "neighbor.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define MIN(a,b) ((a) < (b) ? (a) : (b))
 #define MAX(a,b) ((a) > (b) ? (a) : (b))
 
-/* ----------------------------------------------------------------------
-   free all arrays
-------------------------------------------------------------------------- */
+/* ---------------------------------------------------------------------- */
+
+PairBuck::PairBuck(LAMMPS *lmp) : Pair(lmp) {}
+
+/* ---------------------------------------------------------------------- */
 
 PairBuck::~PairBuck()
 {
diff --git a/src/pair_buck.h b/src/pair_buck.h
index c512f23abb905ae17f2a12363a357e172a6afd18..a4a1e444d94813f8debc2b20b2b91ac24ec2afd0 100644
--- a/src/pair_buck.h
+++ b/src/pair_buck.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,9 +16,11 @@
 
 #include "pair.h"
 
+namespace LAMMPS_NS {
+
 class PairBuck : public Pair {
  public:
-  PairBuck() {}
+  PairBuck(class LAMMPS *);
   ~PairBuck();
   void compute(int, int);
   void settings(int, char **);
@@ -39,4 +41,6 @@ class PairBuck : public Pair {
   void allocate();
 };
 
+}
+
 #endif
diff --git a/src/pair_buck_coul_cut.cpp b/src/pair_buck_coul_cut.cpp
index 87212bdede0f667e3f822fd11d4bdbf8f7888a3e..c957e631d4527c4737a74a2ab2a03c29665bd56d 100644
--- a/src/pair_buck_coul_cut.cpp
+++ b/src/pair_buck_coul_cut.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -27,12 +27,16 @@
 #include "neighbor.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define MIN(a,b) ((a) < (b) ? (a) : (b))
 #define MAX(a,b) ((a) > (b) ? (a) : (b))
 
-/* ----------------------------------------------------------------------
-   free all arrays
-------------------------------------------------------------------------- */
+/* ---------------------------------------------------------------------- */
+
+PairBuckCoulCut::PairBuckCoulCut(LAMMPS *lmp) : Pair(lmp) {}
+
+/* ---------------------------------------------------------------------- */
 
 PairBuckCoulCut::~PairBuckCoulCut()
 {
@@ -302,7 +306,7 @@ void PairBuckCoulCut::init_style()
 {
   // require an atom style with charge defined
 
-  if (atom->charge_allow == 0)
+  if (atom->q == NULL)
     error->all("Must use charged atom style with this pair style");
 }
 
diff --git a/src/pair_buck_coul_cut.h b/src/pair_buck_coul_cut.h
index 4482fec8679791aaaeaba750d3c006327b693f43..6bf81731f7e5db25aaec6a1f302d52c696889467 100644
--- a/src/pair_buck_coul_cut.h
+++ b/src/pair_buck_coul_cut.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,9 +16,11 @@
 
 #include "pair.h"
 
+namespace LAMMPS_NS {
+
 class PairBuckCoulCut : public Pair {
  public:
-  PairBuckCoulCut() {}
+  PairBuckCoulCut(class LAMMPS *);
   ~PairBuckCoulCut();
   void compute(int, int);
   void settings(int, char **);
@@ -41,4 +43,6 @@ class PairBuckCoulCut : public Pair {
   void allocate();
 };
 
+}
+
 #endif
diff --git a/src/pair_eam.h b/src/pair_eam.h
deleted file mode 100644
index deea67d20011ac1aace85b7091f46dd69d7df51e..0000000000000000000000000000000000000000
--- a/src/pair_eam.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/* ----------------------------------------------------------------------
-   LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
-
-   Copyright (2003) Sandia Corporation.  Under the terms of Contract
-   DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
-   certain rights in this software.  This software is distributed under 
-   the GNU General Public License.
-
-   See the README file in the top-level LAMMPS directory.
-------------------------------------------------------------------------- */
-
-#ifndef PAIR_EAM_H
-#define PAIR_EAM_H
-
-#include "pair.h"
-
-class PairEAM : public Pair {
-  friend class FixEnergy;
-
- public:
-  double *rho,*fp;
-  int nmax;
-
-  PairEAM();
-  virtual ~PairEAM();
-  void compute(int, int);
-  void settings(int, char **);
-  virtual void coeff(int, char **);
-  double init_one(int, int);
-  void init_style();
-  void single(int, int, int, int, double, double, double, int, One &);
-
-  int pack_comm(int, int *, double *, int *);
-  void unpack_comm(int, int, double *);
-  int pack_reverse_comm(int, int, double *);
-  void unpack_reverse_comm(int, int *, double *);
-  int memory_usage();
-
- protected:
-  double cutforcesq,cutmax;
-
-  // potentials as file data
-
-  int *map;                   // which element each atom type maps to
-
-  struct Funcfl {
-    char *file;
-    int nrho,nr;
-    double drho,dr,cut,mass;
-    double *frho,*rhor,*zr;
-  };
-  Funcfl *funcfl;
-  int nfuncfl;
-
-  struct Setfl {
-    char **elements;
-    int nelements,nrho,nr;
-    double drho,dr,cut;
-    double *mass;
-    double **frho,**rhor,***z2r;
-  };
-  Setfl *setfl;
-
-  struct Fs {
-    char **elements;
-    int nelements,nrho,nr;
-    double drho,dr,cut;
-    double *mass;
-    double **frho,***rhor,***z2r;
-  };
-  Fs *fs;
-
-  // potentials as array data
-
-  int nrho,nr;
-  int nfrho,nrhor,nz2r;
-  double **frho,**rhor,**z2r;
-  int *type2frho,**type2rhor,**type2z2r;
-  
-  // potentials in spline form used for force computation
-
-  double dr,rdr,drho,rdrho;
-  double ***rhor_spline,***frho_spline,***z2r_spline;
-
-  void allocate();
-  void array2spline();
-  void interpolate(int, double, double *, double **);
-  void grab(FILE *, int, double *);
-  void single_rho(int, int, double, double &, double &);
-  void single_embed(int, int, double &, int, double &);
-
-  virtual void read_file(char *);
-  virtual void file2array();
-};
-
-#endif
diff --git a/src/pair_hybrid.cpp b/src/pair_hybrid.cpp
index 97d793244796e09dc91a01b99b603f943d6027d8..aded32acba265d0abcbde44c13345b66a63c376c 100644
--- a/src/pair_hybrid.cpp
+++ b/src/pair_hybrid.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -12,9 +12,10 @@
 ------------------------------------------------------------------------- */
 
 /* ----------------------------------------------------------------------
-   Contributing authors: James Fischer (High Performance Technologies, Inc)
-                         Vincent Natoli (Stone Ridge Technology)
-			 David Richie (Stone Ridge Technology)
+   Contributing authors: 
+     James Fischer (High Performance Technologies, Inc)
+     Vincent Natoli (Stone Ridge Technology)
+     David Richie (Stone Ridge Technology)
 ------------------------------------------------------------------------- */
 
 #include "math.h"
@@ -30,6 +31,8 @@
 #include "memory.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define NEIGHEXTRA 10000
 
 #define MIN(a,b) ((a) < (b) ? (a) : (b))
@@ -37,14 +40,12 @@
 
 /* ---------------------------------------------------------------------- */
 
-PairHybrid::PairHybrid()
+PairHybrid::PairHybrid(LAMMPS *lmp) : Pair(lmp)
 {
   nstyles = 0;
 }
 
-/* ----------------------------------------------------------------------
-   free all arrays 
-------------------------------------------------------------------------- */
+/* ---------------------------------------------------------------------- */
 
 PairHybrid::~PairHybrid()
 {
@@ -445,6 +446,13 @@ void PairHybrid::settings(int narg, char **arg)
     nstyles++;
   }
 
+  // set comm_forward, comm_reverse to max of any sub-style
+
+  for (m = 0; m < nstyles; m++) {
+    if (styles[m]) comm_forward = MAX(comm_forward,styles[m]->comm_forward);
+    if (styles[m]) comm_reverse = MAX(comm_reverse,styles[m]->comm_reverse);
+  }
+
   // neigh_every = 1 if any sub-style = 1
 
   neigh_half_every = neigh_full_every = 0;
@@ -631,13 +639,12 @@ void PairHybrid::single(int i, int j, int itype, int jtype,
 
 /* ---------------------------------------------------------------------- */
 
-void PairHybrid::single_embed(int i, int itype, double &fpi,
-			      int eflag, double &phi)
+void PairHybrid::single_embed(int i, int itype, double &phi)
 {
   if (map[itype][itype] == -1)
     error->one("Invoked pair single on pair style none");
   
-  styles[map[itype][itype]]->single_embed(i,itype,fpi,eflag,phi);
+  styles[map[itype][itype]]->single_embed(i,itype,phi);
 }
 
 /* ----------------------------------------------------------------------
diff --git a/src/pair_hybrid.h b/src/pair_hybrid.h
index e7dce5fbf0d00aa5247b004767f7997ed6cef322..2686e007300d1112820d3b5de24fdd9347663d2d 100644
--- a/src/pair_hybrid.h
+++ b/src/pair_hybrid.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -17,11 +17,15 @@
 #include "stdio.h"
 #include "pair.h"
 
-class PairHybrid : public Pair {
-  friend class Force;
+namespace LAMMPS_NS {
 
+class PairHybrid : public Pair {
  public:
-  PairHybrid();
+  int nstyles;                  // # of different pair styles
+  Pair **styles;                // class list for each Pair style
+  char **keywords;              // sub-style name for each Pair style
+
+  PairHybrid(class LAMMPS *);
   ~PairHybrid();
   void compute(int, int);
   void settings(int, char **);
@@ -31,14 +35,11 @@ class PairHybrid : public Pair {
   void write_restart(FILE *);
   void read_restart(FILE *);
   void single(int, int, int, int, double, double, double, int, One &);
-  void single_embed(int, int, double &, int, double &);
+  void single_embed(int, int, double &);
   void modify_params(int narg, char **arg);
   int memory_usage();
 
  private:
-  int nstyles;                  // # of different pair styles
-  Pair **styles;                // class list for each Pair style
-  char **keywords;              // sub-style name for each Pair style
   int **map;                    // which style each itype,jtype points to
 
   int *nnlist;                  // # of half neighs in sub-style neigh lists
@@ -58,4 +59,6 @@ class PairHybrid : public Pair {
   void allocate();
 };
 
+}
+
 #endif
diff --git a/src/pair_lj_charmm_coul_long.h b/src/pair_lj_charmm_coul_long.h
deleted file mode 100644
index d25ce9879f63a10f93768a6d1d8715d5efbe6fe9..0000000000000000000000000000000000000000
--- a/src/pair_lj_charmm_coul_long.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/* ----------------------------------------------------------------------
-   LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
-
-   Copyright (2003) Sandia Corporation.  Under the terms of Contract
-   DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
-   certain rights in this software.  This software is distributed under 
-   the GNU General Public License.
-
-   See the README file in the top-level LAMMPS directory.
-------------------------------------------------------------------------- */
-
-#ifndef PAIR_LJ_CHARMM_COUL_LONG_H
-#define PAIR_LJ_CHARMM_COUL_LONG_H
-
-#include "pair.h"
-
-class PairLJCharmmCoulLong : public Pair {
- public:
-  double cut_coul;
-  // these variables are public so DihedralCharmm can see them
-  double **lj14_1,**lj14_2,**lj14_3,**lj14_4;
-
-  PairLJCharmmCoulLong();
-  ~PairLJCharmmCoulLong();
-  void compute(int, int);
-  void settings(int, char **);
-  void coeff(int, char **);
-  double init_one(int, int);
-  void init_style();
-  void write_restart(FILE *);
-  void read_restart(FILE *);
-  void write_restart_settings(FILE *);
-  void read_restart_settings(FILE *);
-  void single(int, int, int, int, double, double, double, int, One &);
-
-  void compute_inner();
-  void compute_middle();
-  void compute_outer(int, int);
-
- private:
-  double cut_lj_inner,cut_lj;
-  double cut_lj_innersq,cut_ljsq,cut_coulsq;
-  double cut_bothsq;
-  double denom_lj;
-  double **epsilon,**sigma,**eps14,**sigma14;
-  double **lj1,**lj2,**lj3,**lj4,**offset;
-  double *cut_respa;
-  double g_ewald;
-
-  double tabinnersq;
-  double *rtable,*drtable,*ftable,*dftable,*ctable,*dctable;
-  double *etable,*detable,*ptable,*dptable,*vtable,*dvtable;
-  int ncoulshiftbits,ncoulmask;
-
-  void allocate();
-  void init_tables();
-  void free_tables();
-};
-
-#endif
diff --git a/src/pair_lj_class2_coul_long.h b/src/pair_lj_class2_coul_long.h
deleted file mode 100644
index 830cb6f0ca75e04410c339f52c0255b9cc27abb7..0000000000000000000000000000000000000000
--- a/src/pair_lj_class2_coul_long.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/* ----------------------------------------------------------------------
-   LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
-
-   Copyright (2003) Sandia Corporation.  Under the terms of Contract
-   DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
-   certain rights in this software.  This software is distributed under 
-   the GNU General Public License.
-
-   See the README file in the top-level LAMMPS directory.
-------------------------------------------------------------------------- */
-
-#ifndef PAIR_LJ_CLASS2_COUL_LONG_H
-#define PAIR_LJ_CLASS2_COUL_LONG_H
-
-#include "pair.h"
-
-class PairLJClass2CoulLong : public Pair {
- public:
-  double cut_coul;
-
-  PairLJClass2CoulLong() {}
-  ~PairLJClass2CoulLong();
-  void compute(int, int);
-  void settings(int, char **);
-  void coeff(int, char **);
-  double init_one(int, int);
-  void init_style();
-  void write_restart(FILE *);
-  void read_restart(FILE *);
-  void write_restart_settings(FILE *);
-  void read_restart_settings(FILE *);
-  void single(int, int, int, int, double, double, double, int, One &);
-
- private:
-  double cut_lj_global;
-  double **cut_lj,**cut_ljsq;
-  double cut_coulsq;
-  double **epsilon,**sigma;
-  double **lj1,**lj2,**lj3,**lj4,**offset;
-  double g_ewald;
-
-  void allocate();
-};
-
-#endif
diff --git a/src/pair_lj_cut.cpp b/src/pair_lj_cut.cpp
index 2d341613a02a2d14d9d9d3f26174389e3ed5cf96..ebff9cac81c5d0ac1bc89c2b19a726ce55d33621 100644
--- a/src/pair_lj_cut.cpp
+++ b/src/pair_lj_cut.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -30,19 +30,19 @@
 #include "memory.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define MIN(a,b) ((a) < (b) ? (a) : (b))
 #define MAX(a,b) ((a) > (b) ? (a) : (b))
 
 /* ---------------------------------------------------------------------- */
 
-PairLJCut::PairLJCut()
+PairLJCut::PairLJCut(LAMMPS *lmp) : Pair(lmp)
 {
   respa_enable = 1;
 }
 
-/* ----------------------------------------------------------------------
-   free all arrays 
-------------------------------------------------------------------------- */
+/* ---------------------------------------------------------------------- */
 
 PairLJCut::~PairLJCut()
 {
diff --git a/src/pair_lj_cut.h b/src/pair_lj_cut.h
index fbe59c40ecdce58a4fa51c3919fd5e40dcdac46c..e89a4d0bddd6951362c89a69c29c101fa3071cf7 100644
--- a/src/pair_lj_cut.h
+++ b/src/pair_lj_cut.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,9 +16,11 @@
 
 #include "pair.h"
 
+namespace LAMMPS_NS {
+
 class PairLJCut : public Pair {
  public:
-  PairLJCut();
+  PairLJCut(class LAMMPS *);
   ~PairLJCut();
   void compute(int, int);
   void settings(int, char **);
@@ -34,7 +36,7 @@ class PairLJCut : public Pair {
   void compute_middle();
   void compute_outer(int, int);
 
- private:
+ protected:
   double cut_global;
   double **cut;
   double **epsilon,**sigma;
@@ -44,4 +46,6 @@ class PairLJCut : public Pair {
   void allocate();
 };
 
+}
+
 #endif
diff --git a/src/pair_lj_cut_coul_cut.cpp b/src/pair_lj_cut_coul_cut.cpp
index 03b80c860c824e53517b3f020e357639df1004b4..1d0cb8dc68627d521fbd3ab442790b68e0572056 100644
--- a/src/pair_lj_cut_coul_cut.cpp
+++ b/src/pair_lj_cut_coul_cut.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -24,12 +24,16 @@
 #include "neighbor.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define MIN(a,b) ((a) < (b) ? (a) : (b))
 #define MAX(a,b) ((a) > (b) ? (a) : (b))
 
-/* ----------------------------------------------------------------------
-   free all arrays
-------------------------------------------------------------------------- */
+/* ---------------------------------------------------------------------- */
+
+PairLJCutCoulCut::PairLJCutCoulCut(LAMMPS *lmp) : Pair(lmp) {}
+
+/* ---------------------------------------------------------------------- */
 
 PairLJCutCoulCut::~PairLJCutCoulCut()
 {
@@ -328,7 +332,7 @@ void PairLJCutCoulCut::init_style()
 {
   // require an atom style with charge defined
 
-  if (atom->charge_allow == 0)
+  if (atom->q == NULL)
     error->all("Must use charged atom style with this pair style");
 }
 
diff --git a/src/pair_lj_cut_coul_cut.h b/src/pair_lj_cut_coul_cut.h
index e11b2afd1a250501570dbcd02aaca63773bdc78b..9f831834a7e2608227005335f7eeda784ae8a88a 100644
--- a/src/pair_lj_cut_coul_cut.h
+++ b/src/pair_lj_cut_coul_cut.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,9 +16,11 @@
 
 #include "pair.h"
 
+namespace LAMMPS_NS {
+
 class PairLJCutCoulCut : public Pair {
  public:
-  PairLJCutCoulCut() {}
+  PairLJCutCoulCut(class LAMMPS *);
   ~PairLJCutCoulCut();
   virtual void compute(int, int);
   virtual void settings(int, char **);
@@ -41,4 +43,6 @@ class PairLJCutCoulCut : public Pair {
   void allocate();
 };
 
+}
+
 #endif
diff --git a/src/pair_lj_cut_coul_debye.cpp b/src/pair_lj_cut_coul_debye.cpp
index ae0e45a91be19584bba3e7d43385a33822c17525..d044ce9c5338cade8da50510a9d33c6e7271ea94 100644
--- a/src/pair_lj_cut_coul_debye.cpp
+++ b/src/pair_lj_cut_coul_debye.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -21,6 +21,12 @@
 #include "update.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
+/* ---------------------------------------------------------------------- */
+
+PairLJCutCoulDebye::PairLJCutCoulDebye(LAMMPS *lmp) : PairLJCutCoulCut(lmp) {}
+
 /* ---------------------------------------------------------------------- */
 
 void PairLJCutCoulDebye::compute(int eflag, int vflag)
diff --git a/src/pair_lj_cut_coul_debye.h b/src/pair_lj_cut_coul_debye.h
index b5aa1951018cbbbace5a6d4c5ebfdd0d79e82107..7acdee3e7d69d194f18f1eaa01b5110ff97f68ee 100644
--- a/src/pair_lj_cut_coul_debye.h
+++ b/src/pair_lj_cut_coul_debye.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,8 +16,11 @@
 
 #include "pair_lj_cut_coul_cut.h"
 
+namespace LAMMPS_NS {
+
 class PairLJCutCoulDebye : public PairLJCutCoulCut {
  public:
+  PairLJCutCoulDebye(class LAMMPS *);
   void compute(int, int);
   void settings(int, char **);
   void write_restart(FILE *);
@@ -30,4 +33,6 @@ class PairLJCutCoulDebye : public PairLJCutCoulCut {
   double kappa;
 };
 
+}
+
 #endif
diff --git a/src/pair_lj_expand.cpp b/src/pair_lj_expand.cpp
index cc9dc5a355d353bbb066f26a61a3f58c9238b914..a5a225dfef12b1f9a7960b3cc7a2bf86c140eb64 100644
--- a/src/pair_lj_expand.cpp
+++ b/src/pair_lj_expand.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -23,11 +23,17 @@
 #include "neighbor.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define MIN(a,b) ((a) < (b) ? (a) : (b))
 #define MAX(a,b) ((a) > (b) ? (a) : (b))
 
 /* ---------------------------------------------------------------------- */
 
+PairLJExpand::PairLJExpand(LAMMPS *lmp) : Pair(lmp) {}
+
+/* ---------------------------------------------------------------------- */
+
 PairLJExpand::~PairLJExpand()
 {
   if (allocated) {
diff --git a/src/pair_lj_expand.h b/src/pair_lj_expand.h
index c8a8290d190f97dba81667029cf34f775ec689f8..845fec0c48e97963745b88914b338ce52f7c5509 100644
--- a/src/pair_lj_expand.h
+++ b/src/pair_lj_expand.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,9 +16,11 @@
 
 #include "pair.h"
 
+namespace LAMMPS_NS {
+
 class PairLJExpand : public Pair {
  public:
-  PairLJExpand() {}
+  PairLJExpand(class LAMMPS *);
   ~PairLJExpand();
   void compute(int, int);
   void settings(int, char **);
@@ -39,4 +41,6 @@ class PairLJExpand : public Pair {
   void allocate();
 };
 
+}
+
 #endif
diff --git a/src/pair_lj_smooth.cpp b/src/pair_lj_smooth.cpp
index 73c66862fabc2b19686aaefa148514f049334abb..1b150d9657690be26d4e9025316163f55a8fa9ae 100644
--- a/src/pair_lj_smooth.cpp
+++ b/src/pair_lj_smooth.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -27,12 +27,16 @@
 #include "memory.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define MIN(a,b) ((a) < (b) ? (a) : (b))
 #define MAX(a,b) ((a) > (b) ? (a) : (b))
 
-/* ----------------------------------------------------------------------
-   free all arrays 
-------------------------------------------------------------------------- */
+/* ---------------------------------------------------------------------- */
+
+PairLJSmooth::PairLJSmooth(LAMMPS *lmp) : Pair(lmp) {}
+
+/* ---------------------------------------------------------------------- */
 
 PairLJSmooth::~PairLJSmooth()
 {
diff --git a/src/pair_lj_smooth.h b/src/pair_lj_smooth.h
index 558e82bf7ef31e3fad9054ad4deea2cb7011b5e1..f050199c54e447591d3d375bb5519768da741213 100644
--- a/src/pair_lj_smooth.h
+++ b/src/pair_lj_smooth.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,9 +16,11 @@
 
 #include "pair.h"
 
+namespace LAMMPS_NS {
+
 class PairLJSmooth : public Pair {
  public:
-  PairLJSmooth() {}
+  PairLJSmooth(class LAMMPS *);
   ~PairLJSmooth();
   void compute(int, int);
   void settings(int, char **);
@@ -41,4 +43,6 @@ class PairLJSmooth : public Pair {
   void allocate();
 };
 
+}
+
 #endif
diff --git a/src/pair_morse.cpp b/src/pair_morse.cpp
index 0c29807f493ce49af237a13c6c7cf9e781103cc6..bba446998abfddaec75128c160bcfb7b96209c2a 100644
--- a/src/pair_morse.cpp
+++ b/src/pair_morse.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -23,12 +23,16 @@
 #include "neighbor.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define MIN(a,b) ((a) < (b) ? (a) : (b))
 #define MAX(a,b) ((a) > (b) ? (a) : (b))
 
-/* ----------------------------------------------------------------------
-   free all arrays 
-------------------------------------------------------------------------- */
+/* ---------------------------------------------------------------------- */
+
+PairMorse::PairMorse(LAMMPS *lmp) : Pair(lmp) {}
+
+/* ---------------------------------------------------------------------- */
 
 PairMorse::~PairMorse()
 {
diff --git a/src/pair_morse.h b/src/pair_morse.h
index c5327d34b50fbf9748d4fa09c24459782152269a..fa28b42e476d0fd92281baacd9b2efa33e01c752 100644
--- a/src/pair_morse.h
+++ b/src/pair_morse.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,9 +16,11 @@
 
 #include "pair.h"
 
+namespace LAMMPS_NS {
+
 class PairMorse : public Pair {
  public:
-  PairMorse() {}
+  PairMorse(class LAMMPS *);
   ~PairMorse();
   void compute(int, int);
   void settings(int, char **);
@@ -30,7 +32,7 @@ class PairMorse : public Pair {
   void read_restart_settings(FILE *);
   void single(int, int, int, int, double, double, double, int, One &);
 
- private:
+ protected:
   double cut_global;
   double **cut;
   double **d0,**alpha,**r0;
@@ -40,4 +42,6 @@ class PairMorse : public Pair {
   void allocate();
 };
 
+}
+
 #endif
diff --git a/src/pair_soft.cpp b/src/pair_soft.cpp
index f0b28ab13cc6e2ba9bf6a7b6adcaabd78b5c7229..fe39ffa997f06987a09171d3a63a4fa1a6618ac0 100644
--- a/src/pair_soft.cpp
+++ b/src/pair_soft.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -23,12 +23,14 @@
 #include "neighbor.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define MIN(a,b) ((a) < (b) ? (a) : (b))
 #define MAX(a,b) ((a) > (b) ? (a) : (b))
 
 /* ---------------------------------------------------------------------- */
 
-PairSoft::PairSoft()
+PairSoft::PairSoft(LAMMPS *lmp) : Pair(lmp)
 {
   PI = 4.0*atan(1.0);
 }
diff --git a/src/pair_soft.h b/src/pair_soft.h
index 7901f0053eaa720d1e8ee032d07beb672efc639a..437e93dd7d9ed02d860e9d698ae7404ea320f5dd 100644
--- a/src/pair_soft.h
+++ b/src/pair_soft.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,11 +16,13 @@
 
 #include "pair.h"
 
+namespace LAMMPS_NS {
+
 class PairSoft : public Pair {
   friend class Pair;
 
  public:
-  PairSoft();
+  PairSoft(class LAMMPS *);
   ~PairSoft();
   void compute(int, int);
   void settings(int, char **);
@@ -42,4 +44,6 @@ class PairSoft : public Pair {
   void allocate();
 };
 
+}
+
 #endif
diff --git a/src/pair_table.cpp b/src/pair_table.cpp
index 3f910cc918b86d3cf418d8d43dcd25d310197065..2aefa1baf65f712ccc817df0f797baca43ab0d25 100644
--- a/src/pair_table.cpp
+++ b/src/pair_table.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -28,6 +28,8 @@
 #include "memory.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define MIN(a,b) ((a) < (b) ? (a) : (b))
 #define MAX(a,b) ((a) > (b) ? (a) : (b))
 
@@ -44,15 +46,13 @@
 
 /* ---------------------------------------------------------------------- */
 
-PairTable::PairTable()
+PairTable::PairTable(LAMMPS *lmp) : Pair(lmp)
 {
   ntables = 0;
   tables = NULL;
 }
 
-/* ----------------------------------------------------------------------
-   free all arrays 
-------------------------------------------------------------------------- */
+/* ---------------------------------------------------------------------- */
 
 PairTable::~PairTable()
 {
@@ -972,20 +972,20 @@ void PairTable::single(int i, int j, int itype, int jtype, double rsq,
 }
 
 /* ----------------------------------------------------------------------
-   return the cutoff for tabled potentials
-   called only by KSpace solvers to determine pairwise Coulombic cutoff
-   KSpace requires that all pairwise cutoffs be the same
-   loop over all tables not just those indexed by tabindex[i][j]
+   return the Coulomb cutoff for tabled potentials
+   called by KSpace solvers which require that all pairwise cutoffs be the same
+   loop over all tables not just those indexed by tabindex[i][j] since
      no way to know which tables are active since pair::init() not yet called
 ------------------------------------------------------------------------- */
 
-double PairTable::cut_coul()
+void PairTable::extract_long(double *p_cut_coul)
 {
   if (ntables == 0) error->all("All pair coeffs are not set");
 
-  double cut = tables[0].cut;
+  double cut_coul = tables[0].cut;
   for (int m = 1; m < ntables; m++)
-    if (tables[m].cut != cut)
+    if (tables[m].cut != cut_coul)
       error->all("Pair table cutoffs must all be equal to use with KSpace");
-  return cut;
+
+  *p_cut_coul = cut_coul;
 }
diff --git a/src/pair_table.h b/src/pair_table.h
index 24d6ed51e7a3c6a8b000d8af448975d0411dfb9b..38aa7deda33f1e7f39ecafbc7c7367b89c719797 100644
--- a/src/pair_table.h
+++ b/src/pair_table.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,9 +16,11 @@
 
 #include "pair.h"
 
+namespace LAMMPS_NS {
+
 class PairTable : public Pair {
  public:
-  PairTable();
+  PairTable(class LAMMPS *);
   ~PairTable();
   void compute(int, int);
   void settings(int, char **);
@@ -30,7 +32,7 @@ class PairTable : public Pair {
   void read_restart_settings(FILE *);
   void single(int, int, int, int, double, double, double, int, One &);
 
-  double cut_coul();
+  void extract_long(double *);
 
  private:
   int tabstyle,n,nm1;
@@ -60,4 +62,6 @@ class PairTable : public Pair {
   double splint(double *, double *, double *, int, double);
 };
 
+}
+
 #endif
diff --git a/src/pair_yukawa.cpp b/src/pair_yukawa.cpp
index 55345e9e742f42e14df139cd4757e95266a4ffdc..beeaf87b9e7393212980bcc02bd0c4f0fcb0691e 100644
--- a/src/pair_yukawa.cpp
+++ b/src/pair_yukawa.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -22,12 +22,16 @@
 #include "memory.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define MIN(a,b) ((a) < (b) ? (a) : (b))
 #define MAX(a,b) ((a) > (b) ? (a) : (b))
 
-/* ----------------------------------------------------------------------
-   free all arrays
-------------------------------------------------------------------------- */
+/* ---------------------------------------------------------------------- */
+
+PairYukawa::PairYukawa(LAMMPS *lmp) : Pair(lmp) {}
+
+/* ---------------------------------------------------------------------- */
 
 PairYukawa::~PairYukawa()
 {
diff --git a/src/pair_yukawa.h b/src/pair_yukawa.h
index 9380f7c8266024aa80fa58987a428d950aeab440..0f0effbd4fd168bf9196edfcaed0020b7dcc39ab 100644
--- a/src/pair_yukawa.h
+++ b/src/pair_yukawa.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,9 +16,11 @@
 
 #include "pair.h"
 
+namespace LAMMPS_NS {
+
 class PairYukawa : public Pair {
  public:
-  PairYukawa() {}
+  PairYukawa(class LAMMPS *);
   ~PairYukawa();
   void compute(int, int);
   void settings(int, char **);
@@ -38,4 +40,6 @@ class PairYukawa : public Pair {
   void allocate();
 };
 
+}
+
 #endif
diff --git a/src/pressure.cpp b/src/pressure.cpp
deleted file mode 100644
index 857510ec9cf5ca7d63232cc4c17f5f4d0562732a..0000000000000000000000000000000000000000
--- a/src/pressure.cpp
+++ /dev/null
@@ -1,169 +0,0 @@
-/* ----------------------------------------------------------------------
-   LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
-
-   Copyright (2003) Sandia Corporation.  Under the terms of Contract
-   DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
-   certain rights in this software.  This software is distributed under 
-   the GNU General Public License.
-
-   See the README file in the top-level LAMMPS directory.
-------------------------------------------------------------------------- */
-
-#include "mpi.h"
-#include "string.h"
-#include "pressure.h"
-#include "output.h"
-#include "thermo.h"
-#include "temperature.h"
-#include "force.h"
-#include "modify.h"
-#include "fix.h"
-#include "fix_npt.h"
-#include "fix_nph.h"
-#include "bond.h"
-#include "angle.h"
-#include "dihedral.h"
-#include "improper.h"
-#include "pair.h"
-#include "kspace.h"
-#include "atom.h"
-#include "domain.h"
-
-/* ---------------------------------------------------------------------- */
-
-void Pressure::init()
-{
-  boltz = force->boltz;
-  nktv2p = force->nktv2p;
-
-  // set tensor flag if p_tensor will ever be used
-  // possibly used by thermo and fix_npt, fix_nph
-
-  tensorflag = 0;
-  if (output->thermo->tensorflag) tensorflag = 1;
-  for (int i = 0; i < modify->nfix; i++) {
-    if (strcmp(modify->fix[i]->style,"npt") == 0)
-      if (((FixNPT *) modify->fix[i])->press_couple > 0) tensorflag = 1;
-    if (strcmp(modify->fix[i]->style,"nph") == 0)
-      if (((FixNPH *) modify->fix[i])->press_couple > 0) tensorflag = 1;
-  }
-    
-  // set flags/ptrs for all contributions to virial
-    
-  pairflag = bondflag = angleflag = dihedralflag = improperflag = 0;
-  kspaceflag = 0;
-  shakeflag = bodyflag = rigidflag = poemsflag = 0;
-
-  if (force->pair) {
-    pairflag = 1;
-    pair_virial = force->pair->virial;
-  }
-  if (atom->molecular) {
-    if (force->bond) {
-      bondflag = 1;
-      bond_virial = force->bond->virial;
-    }
-    if (force->angle) {
-      angleflag = 1;
-      angle_virial = force->angle->virial;
-    }
-    if (force->dihedral) {
-      dihedralflag = 1;
-      dihedral_virial = force->dihedral->virial;
-    }
-    if (force->improper) {
-      improperflag = 1;
-      improper_virial = force->improper->virial;
-    }
-  }
-
-  if (force->kspace) {
-    kspaceflag = 1;
-    kspace_virial = force->kspace->virial;
-  }
-
-  for (int i = 0; i < modify->nfix; i++) {
-    if (strcmp(modify->fix[i]->style,"shake") == 0) {
-      shakeflag = 1;
-      shake_virial = modify->fix[i]->virial;
-    }
-    if (strcmp(modify->fix[i]->style,"rigid") == 0 ||
-	strcmp(modify->fix[i]->style,"poems") == 0) {
-      bodyflag = 1;
-      if (strcmp(modify->fix[i]->style,"rigid") == 0) {
-	rigidflag = 1;
-	rigid_virial = modify->fix[i]->virial;
-      } else {
-	poemsflag = 1;
-	poems_virial = modify->fix[i]->virial;
-      }
-    }
-  }
-}
-
-/* ---------------------------------------------------------------------- */
-
-void Pressure::compute(Temperature *temperature)
-{
-  int i,n;
-  double v[6];
-
-  if (tensorflag) n = 6;
-  else n = 3;
-  for (i = 0; i < n; i++) v[i] = 0.0;
-
-  // sum contributions to virial from various forces and fixes
-
-  if (pairflag)
-    for (i = 0; i < n; i++) v[i] += pair_virial[i];
-
-  if (atom->molecular) {
-    if (bondflag)
-      for (i = 0; i < n; i++) v[i] += bond_virial[i];
-    if (angleflag)
-      for (i = 0; i < n; i++) v[i] += angle_virial[i];
-    if (dihedralflag)
-      for (i = 0; i < n; i++) v[i] += dihedral_virial[i];
-    if (improperflag)
-      for (i = 0; i < n; i++) v[i] += improper_virial[i];
-    if (shakeflag)
-      for (i = 0; i < n; i++) v[i] += shake_virial[i];
-  }
-
-  if (bodyflag) {
-    if (rigidflag) for (i = 0; i < n; i++) v[i] += rigid_virial[i];
-    if (poemsflag) for (i = 0; i < n; i++) v[i] += poems_virial[i];
-  }
-
-  // sum virial across procs
-
-  MPI_Allreduce(v,virial,n,MPI_DOUBLE,MPI_SUM,world);
-
-  // KSpace virial contribution is already summed across procs
-
-  if (force->kspace)
-    for (i = 0; i < n; i++) virial[i] += kspace_virial[i];
-
-  // LJ long-range tail correction
-
-  double inv_volume = 1.0 / (domain->xprd * domain->yprd * domain->zprd);
-
-  if (force->pair && force->pair->tail_flag)
-    for (i = 0; i < n; i++) virial[i] += force->pair->ptail * inv_volume;
-
-  // compute just total average pressure or entire pressure tensor
-  // p_total = total pressure = average of trace of tensor
-  // for tensor, must first compute 6 components of kinetic energy tensor
-
-  if (tensorflag) {
-    temperature->tensor();
-    double *ke_tensor = temperature->ke_tensor;
-    for (i = 0; i < n; i++)
-      p_tensor[i] = (ke_tensor[i] + virial[i]) * inv_volume * nktv2p;
-    p_total = (p_tensor[0] + p_tensor[1] + p_tensor[2]) / 3.0;
-  } else
-    p_total = (temperature->dof * boltz * temperature->t_total + 
-	       virial[0] + virial[1] + virial[2]) / 3.0 * inv_volume * nktv2p;
-}
diff --git a/src/pressure.h b/src/pressure.h
deleted file mode 100644
index 9fc0dfd7560371100c7c8a9a8817bb1589942ec3..0000000000000000000000000000000000000000
--- a/src/pressure.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/* ----------------------------------------------------------------------
-   LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
-
-   Copyright (2003) Sandia Corporation.  Under the terms of Contract
-   DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
-   certain rights in this software.  This software is distributed under 
-   the GNU General Public License.
-
-   See the README file in the top-level LAMMPS directory.
-------------------------------------------------------------------------- */
-
-#ifndef PRESSURE_H
-#define PRESSURE_H
-
-#include "lammps.h"
-
-class Temperature;
-
-class Pressure : public LAMMPS {
- public:
-  double p_total;
-  double p_tensor[6],virial[6];
-
-  Pressure() {}
-  ~Pressure() {}
-  void init();
-  void compute(Temperature *);
-
- private:
-  double boltz,nktv2p;
-  double *pair_virial,*bond_virial,*angle_virial;
-  double *dihedral_virial,*improper_virial,*kspace_virial;
-  double *shake_virial,*rigid_virial,*poems_virial;
-  int tensorflag;
-  int pairflag,bondflag,angleflag,dihedralflag,improperflag,kspaceflag;
-  int shakeflag,bodyflag,rigidflag,poemsflag;
-};
-
-#endif
diff --git a/src/random_mars.cpp b/src/random_mars.cpp
index 1fc41a3813e9a9e708f311510ba6172ae92bc77b..06dd95b2a4351792060a1e26e1b904560dc50d31 100644
--- a/src/random_mars.cpp
+++ b/src/random_mars.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -17,9 +17,11 @@
 #include "random_mars.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 /* ---------------------------------------------------------------------- */
 
-RanMars::RanMars(int seed)
+RanMars::RanMars(LAMMPS *lmp, int seed) : Pointers(lmp)
 {
   int ij,kl,i,j,k,l,ii,jj,m;
   double s,t;
diff --git a/src/random_mars.h b/src/random_mars.h
index 6940b384e8a526576e709d55cdc3d1c64e71f55f..fd93ad6aba698c8d3a0bfe1a7dffc08876b28c82 100644
--- a/src/random_mars.h
+++ b/src/random_mars.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -14,11 +14,13 @@
 #ifndef RANMARS_H
 #define RANMARS_H
 
-#include "lammps.h"
+#include "pointers.h"
 
-class RanMars : public LAMMPS {
+namespace LAMMPS_NS {
+
+class RanMars : protected Pointers {
  public:
-  RanMars(int);
+  RanMars(class LAMMPS *, int);
   ~RanMars();
   double uniform();
   double gaussian();
@@ -31,4 +33,6 @@ class RanMars : public LAMMPS {
   double c,cd,cm;
 };
 
+}
+
 #endif
diff --git a/src/random_park.cpp b/src/random_park.cpp
index a61eef880b859f5c0a3cd5ff5aac14e3b9f74219..71fcb7a90a72f804135d5627b1c8dcc2b0ec9265 100644
--- a/src/random_park.cpp
+++ b/src/random_park.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,6 +16,8 @@
 #include "math.h"
 #include "random_park.h"
 
+using namespace LAMMPS_NS;
+
 #define IA 16807
 #define IM 2147483647
 #define AM (1.0/IM)
@@ -24,7 +26,7 @@
 
 /* ---------------------------------------------------------------------- */
 
-RanPark::RanPark(int seed_init)
+RanPark::RanPark(LAMMPS *lmp, int seed_init) : Pointers(lmp)
 {
   seed = seed_init;
   save = 0;
diff --git a/src/random_park.h b/src/random_park.h
index 71b5c29a8f31e9827fde177d293a8742b0b1b14d..a9132c7954790ef60cac2dccec10b1c63bb23fff 100644
--- a/src/random_park.h
+++ b/src/random_park.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -14,10 +14,13 @@
 #ifndef RANPARK_H
 #define RANPARK_H
 
-class RanPark {
+#include "pointers.h"
+
+namespace LAMMPS_NS {
+
+class RanPark : protected Pointers {
  public:
-  RanPark(int);
-  ~RanPark() {}
+  RanPark(class LAMMPS *, int);
   double uniform();
   double gaussian();
   void reset(double);
@@ -27,4 +30,6 @@ class RanPark {
   double second;
 };
 
+}
+
 #endif
diff --git a/src/read_data.cpp b/src/read_data.cpp
index 6f15431ee2e9e9790dc82098c5a97d5d7f8a6552..a614a012116c8b8bb17764e1ad52be458f5c2517 100644
--- a/src/read_data.cpp
+++ b/src/read_data.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,6 +16,8 @@
 #include "stdlib.h"
 #include "read_data.h"
 #include "atom.h"
+#include "atom_vec.h"
+#include "atom_vec_hybrid.h"
 #include "comm.h"
 #include "update.h"
 #include "force.h"
@@ -26,10 +28,11 @@
 #include "dihedral.h"
 #include "improper.h"
 #include "error.h"
-#include "atom_atomic.h"
 #include "memory.h"
 #include "special.h"
 
+using namespace LAMMPS_NS;
+
 #define MAXLINE 256
 #define LB_FACTOR 1.1
 #define CHUNK 1024
@@ -40,7 +43,7 @@
 
 /* ---------------------------------------------------------------------- */
 
-ReadData::ReadData()
+ReadData::ReadData(LAMMPS *lmp) : Pointers(lmp)
 {
   MPI_Comm_rank(world,&me);
   line = new char[MAXLINE];
@@ -66,11 +69,8 @@ void ReadData::command(int narg, char **arg)
 {
   if (narg != 1) error->all("Illegal read_data command");
 
-  if (atom == NULL)
-    error->all("Cannot read_data until atom_style is defined");
   if (domain->box_exist) 
     error->all("Cannot read_data after simulation box is defined");
-
   if (force->dimension == 2 && domain->zperiodic == 0)
     error->all("Cannot run 2d simulation with nonperiodic Z dimension");
 
@@ -112,7 +112,7 @@ void ReadData::command(int narg, char **arg)
   else n = static_cast<int> (LB_FACTOR * atom->natoms / comm->nprocs);
 
   atom->allocate_type_arrays();
-  atom->grow(n);
+  atom->avec->grow(n);
 
   domain->set_initial_box();
   domain->set_global_box();
@@ -120,35 +120,59 @@ void ReadData::command(int narg, char **arg)
   domain->set_local_box();
 
   // read rest of file in free format
+  // Atoms and Velocities keywords can have trailing hybrid sub-style
 
   int atomflag = 0;
+  int hybridflag = 0;
+  if (strcmp(atom->atom_style,"hybrid") == 0) hybridflag = 1;
+
   parse_keyword(1,1);
 
   while (strlen(keyword)) {
-
     if (strcmp(keyword,"Atoms") == 0) {
-      atoms();
+      atoms(0);
+      atomflag = 1;
+    } else if (hybridflag && strstr(keyword,"Atoms") == keyword) {
+      strtok(keyword," \t");
+      char *substyle = strtok(NULL," \t");
+      AtomVecHybrid *avec_hybrid = (AtomVecHybrid *) atom->avec;
+      if (substyle == NULL) error->all("Invalid data file section: Atoms");
+      int ihybrid;
+      for (ihybrid = 0; ihybrid < avec_hybrid->nstyles; ihybrid++)
+	if (strcmp(avec_hybrid->keywords[ihybrid],substyle) == 0) break;
+      atoms(ihybrid);
       atomflag = 1;
     } else if (strcmp(keyword,"Velocities") == 0) {
       if (atomflag == 0) error->all("Must read Atoms before Velocities");
-      velocities();
+      velocities(0);
+    } else if (hybridflag && strstr(keyword,"Velocities") == keyword) {
+      if (atomflag == 0) error->all("Must read Atoms before Velocities");
+      strtok(keyword," \t");
+      char *substyle = strtok(NULL," \t");
+      AtomVecHybrid *avec_hybrid = (AtomVecHybrid *) atom->avec;
+      if (substyle == NULL)
+	error->all("Invalid data file section: Velocities");
+      int ihybrid;
+      for (ihybrid = 0; ihybrid < avec_hybrid->nstyles; ihybrid++)
+	if (strcmp(avec_hybrid->keywords[ihybrid],substyle) == 0) break;
+      velocities(ihybrid);
     } else if (strcmp(keyword,"Bonds") == 0) {
-      if (atom->bonds_allow == 0) 
+      if (atom->avec->bonds_allow == 0) 
 	error->all("Invalid data file section: Bonds");
       if (atomflag == 0) error->all("Must read Atoms before Bonds");
       bonds();
     } else if (strcmp(keyword,"Angles") == 0) {
-      if (atom->angles_allow == 0)
+      if (atom->avec->angles_allow == 0)
 	error->all("Invalid data file section: Angles");
       if (atomflag == 0) error->all("Must read Atoms before Angles");
       angles();
     } else if (strcmp(keyword,"Dihedrals") == 0) {
-      if (atom->dihedrals_allow == 0)
+      if (atom->avec->dihedrals_allow == 0)
 	error->all("Invalid data file section: Dihedrals");
       if (atomflag == 0) error->all("Must read Atoms before Dihedrals");
       dihedrals();
     } else if (strcmp(keyword,"Impropers") == 0) {
-      if (atom->impropers_allow == 0) 
+      if (atom->avec->impropers_allow == 0) 
 	error->all("Invalid data file section: Impropers");
       if (atomflag == 0) error->all("Must read Atoms before Impropers");
       impropers();
@@ -162,76 +186,76 @@ void ReadData::command(int narg, char **arg)
 	error->all("Must define pair_style before Pair Coeffs");
       paircoeffs();
     } else if (strcmp(keyword,"Bond Coeffs") == 0) {
-      if (atom->bonds_allow == 0) 
+      if (atom->avec->bonds_allow == 0) 
 	error->all("Invalid data file section: Bond Coeffs");
       if (force->bond == NULL) 
 	error->all("Must define bond_style before Bond Coeffs");
       bondcoeffs();
     } else if (strcmp(keyword,"Angle Coeffs") == 0) {
-      if (atom->angles_allow == 0) 
+      if (atom->avec->angles_allow == 0) 
 	error->all("Invalid data file section: Angle Coeffs");
       if (force->angle == NULL) 
 	error->all("Must define angle_style before Angle Coeffs");
       anglecoeffs(0);
     } else if (strcmp(keyword,"Dihedral Coeffs") == 0) {
-      if (atom->dihedrals_allow == 0) 
+      if (atom->avec->dihedrals_allow == 0) 
 	error->all("Invalid data file section: Dihedral Coeffs");
       if (force->dihedral == NULL) 
 	error->all("Must define dihedral_style before Dihedral Coeffs");
       dihedralcoeffs(0);
     } else if (strcmp(keyword,"Improper Coeffs") == 0) {
-      if (atom->impropers_allow == 0) 
+      if (atom->avec->impropers_allow == 0) 
 	error->all("Invalid data file section: Improper Coeffs");
       if (force->improper == NULL) 
 	error->all("Must define improper_style before Improper Coeffs");
       impropercoeffs(0);
 
     } else if (strcmp(keyword,"BondBond Coeffs") == 0) {
-      if (atom->angles_allow == 0) 
+      if (atom->avec->angles_allow == 0) 
 	error->all("Invalid data file section: BondBond Coeffs");
       if (force->angle == NULL) 
 	error->all("Must define angle_style before BondBond Coeffs");
       anglecoeffs(1);
     } else if (strcmp(keyword,"BondAngle Coeffs") == 0) {
-      if (atom->angles_allow == 0) 
+      if (atom->avec->angles_allow == 0) 
 	error->all("Invalid data file section: BondAngle Coeffs");
       if (force->angle == NULL) 
 	error->all("Must define angle_style before BondAngle Coeffs");
       anglecoeffs(2);
 
     } else if (strcmp(keyword,"MiddleBondTorsion Coeffs") == 0) {
-      if (atom->dihedrals_allow == 0) 
+      if (atom->avec->dihedrals_allow == 0) 
 	error->all("Invalid data file section: MiddleBondTorsion Coeffs");
       if (force->dihedral == NULL) 
 	error->all("Must define dihedral_style before MiddleBondTorsion Coeffs");
       dihedralcoeffs(1);
     } else if (strcmp(keyword,"EndBondTorsion Coeffs") == 0) {
-      if (atom->dihedrals_allow == 0) 
+      if (atom->avec->dihedrals_allow == 0) 
 	error->all("Invalid data file section: EndBondTorsion Coeffs");
       if (force->dihedral == NULL) 
 	error->all("Must define dihedral_style before EndBondTorsion Coeffs");
       dihedralcoeffs(2);
     } else if (strcmp(keyword,"AngleTorsion Coeffs") == 0) {
-      if (atom->dihedrals_allow == 0) 
+      if (atom->avec->dihedrals_allow == 0) 
 	error->all("Invalid data file section: AngleTorsion Coeffs");
       if (force->dihedral == NULL) 
 	error->all("Must define dihedral_style before AngleTorsion Coeffs");
       dihedralcoeffs(3);
     } else if (strcmp(keyword,"AngleAngleTorsion Coeffs") == 0) {
-      if (atom->dihedrals_allow == 0) 
+      if (atom->avec->dihedrals_allow == 0) 
 	error->all("Invalid data file section: AngleAngleTorsion Coeffs");
       if (force->dihedral == NULL) 
 	error->all("Must define dihedral_style before AngleAngleTorsion Coeffs");
       dihedralcoeffs(4);
     } else if (strcmp(keyword,"BondBond13 Coeffs") == 0) {
-      if (atom->dihedrals_allow == 0) 
+      if (atom->avec->dihedrals_allow == 0) 
 	error->all("Invalid data file section: BondBond13 Coeffs");
       if (force->dihedral == NULL) 
 	error->all("Must define dihedral_style before BondBond13 Coeffs");
       dihedralcoeffs(5);
 
     } else if (strcmp(keyword,"AngleAngle Coeffs") == 0) {
-      if (atom->impropers_allow == 0) 
+      if (atom->avec->impropers_allow == 0) 
 	error->all("Invalid data file section: AngleAngle Coeffs");
       if (force->improper == NULL) 
 	error->all("Must define improper_style before AngleAngle Coeffs");
@@ -257,7 +281,7 @@ void ReadData::command(int narg, char **arg)
   // create bond topology now that system is defined
 
   if (atom->molecular) {
-    Special special;
+    Special special(lmp);
     special.build();
   }
 }
@@ -337,13 +361,17 @@ void ReadData::header(int flag)
 
   // error check on consistency of header values
 
-  if ((atom->nbonds || atom->nbondtypes) && atom->bonds_allow == 0)
+  if ((atom->nbonds || atom->nbondtypes) && 
+      atom->avec->bonds_allow == 0)
     error->one("No bonds allowed with this atom style");
-  if ((atom->nangles || atom->nangletypes) && atom->angles_allow == 0)
+  if ((atom->nangles || atom->nangletypes) && 
+      atom->avec->angles_allow == 0)
     error->one("No angles allowed with this atom style");
-  if ((atom->ndihedrals || atom->ndihedraltypes) && atom->dihedrals_allow == 0)
+  if ((atom->ndihedrals || atom->ndihedraltypes) && 
+      atom->avec->dihedrals_allow == 0)
     error->one("No dihedrals allowed with this atom style");
-  if ((atom->nimpropers || atom->nimpropertypes) && atom->impropers_allow == 0)
+  if ((atom->nimpropers || atom->nimpropertypes) && 
+      atom->avec->impropers_allow == 0)
     error->one("No impropers allowed with this atom style");
 
   if (atom->nbonds > 0 && atom->nbondtypes <= 0)
@@ -361,27 +389,16 @@ void ReadData::header(int flag)
 }
 
 /* ----------------------------------------------------------------------
-   read all atoms
+   read all atoms of a sub-style ihybrid (0 if not atom style hybrid)
    to find atoms, must build atom map if not a molecular system 
    accumulate nread in double precision to allow natoms > 2^31
 ------------------------------------------------------------------------- */
 
-void ReadData::atoms()
+void ReadData::atoms(int ihybrid)
 {
   int i,m,nchunk;
   
-  if (me == 0) {
-    char *eof = fgets(buffer,MAXLINE,fp);
-    if (eof == NULL) error->one("Unexpected end of data file");
-    m = strlen(buffer) + 1;
-  }
-  MPI_Bcast(&m,1,MPI_INT,0,world);
-  MPI_Bcast(buffer,m,MPI_CHAR,0,world);
-  if (atom->parse_data(buffer))
-    error->all("Incorrect atom format in data file");
-
-  atom->unpack_data(1,buffer);
-  double nread = 1.0;
+  double nread = 0.0;
   double natoms = atom->natoms;
 
   while (nread < natoms) {
@@ -400,7 +417,7 @@ void ReadData::atoms()
     MPI_Bcast(&m,1,MPI_INT,0,world);
     MPI_Bcast(buffer,m,MPI_CHAR,0,world);
 
-    atom->unpack_data(nchunk,buffer);
+    atom->data_atoms(nchunk,buffer,ihybrid);
     nread += nchunk;
   }
 
@@ -453,12 +470,12 @@ void ReadData::atoms()
 }
 
 /* ----------------------------------------------------------------------
-   read all velocities
+   read all velocities of a sub-style ihybrid (0 if not atom style hybrid)
    to find atoms, must build atom map if not a molecular system 
    accumulate nread in double precision to allow natoms > 2^31
 ------------------------------------------------------------------------- */
 
-void ReadData::velocities()
+void ReadData::velocities(int ihybrid)
 {
   int i,m,nchunk;
 
@@ -471,7 +488,7 @@ void ReadData::velocities()
   }
 
   double nread = 0.0;
-  double natoms = static_cast<int> (atom->natoms);
+  double natoms = atom->natoms;
 
   while (nread < natoms) {
     if (natoms-nread > CHUNK) nchunk = CHUNK;
@@ -489,7 +506,7 @@ void ReadData::velocities()
     MPI_Bcast(&m,1,MPI_INT,0,world);
     MPI_Bcast(buffer,m,MPI_CHAR,0,world);
 
-    atom->unpack_vels(nchunk,buffer);
+    atom->data_vels(nchunk,buffer,ihybrid);
     nread += nchunk;
   }
 
@@ -526,7 +543,7 @@ void ReadData::bonds()
     MPI_Bcast(&m,1,MPI_INT,0,world);
     MPI_Bcast(buffer,m,MPI_CHAR,0,world);
 
-    atom->unpack_bonds(nchunk,buffer);
+    atom->data_bonds(nchunk,buffer);
     nread += nchunk;
   }
 
@@ -568,7 +585,7 @@ void ReadData::angles()
     MPI_Bcast(&m,1,MPI_INT,0,world);
     MPI_Bcast(buffer,m,MPI_CHAR,0,world);
 
-    atom->unpack_angles(nchunk,buffer);
+    atom->data_angles(nchunk,buffer);
     nread += nchunk;
   }
 
@@ -610,7 +627,7 @@ void ReadData::dihedrals()
     MPI_Bcast(&m,1,MPI_INT,0,world);
     MPI_Bcast(buffer,m,MPI_CHAR,0,world);
 
-    atom->unpack_dihedrals(nchunk,buffer);
+    atom->data_dihedrals(nchunk,buffer);
     nread += nchunk;
   }
 
@@ -653,7 +670,7 @@ void ReadData::impropers()
     MPI_Bcast(&m,1,MPI_INT,0,world);
     MPI_Bcast(buffer,m,MPI_CHAR,0,world);
 
-    atom->unpack_impropers(nchunk,buffer);
+    atom->data_impropers(nchunk,buffer);
     nread += nchunk;
   }
 
diff --git a/src/read_data.h b/src/read_data.h
index b4c3a7176220ee100db542c5b2bfa49ae6e4ff08..03d27e718b45f669952d5fbe07cc33f10375f3ef 100644
--- a/src/read_data.h
+++ b/src/read_data.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -15,11 +15,13 @@
 #define READ_DATA_H
 
 #include "stdio.h"
-#include "lammps.h"
+#include "pointers.h"
 
-class ReadData : public LAMMPS {
+namespace LAMMPS_NS {
+
+class ReadData : protected Pointers {
  public:
-  ReadData();
+  ReadData(class LAMMPS *);
   ~ReadData();
   void command(int, char **);
 
@@ -38,8 +40,8 @@ class ReadData : public LAMMPS {
   void skip_lines(int);
   void parse_coeffs(int, char *);
 
-  void atoms();
-  void velocities();
+  void atoms(int);
+  void velocities(int);
   void bonds();
   void angles();
   void dihedrals();
@@ -55,4 +57,6 @@ class ReadData : public LAMMPS {
   void impropercoeffs(int);
 };
 
+}
+
 #endif
diff --git a/src/read_restart.cpp b/src/read_restart.cpp
index fec777d1837cfbf29e30d1b999dfb54777da790a..9ce8a89b98b6be44df669e92b44c21bcf45fb9f3 100644
--- a/src/read_restart.cpp
+++ b/src/read_restart.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -18,6 +18,7 @@
 #include "dirent.h"
 #include "read_restart.h"
 #include "atom.h"
+#include "atom_vec.h"
 #include "domain.h"
 #include "comm.h"
 #include "update.h"
@@ -34,21 +35,23 @@
 #include "memory.h"
 #include "error.h"
 
-#define AtomInclude
-#include "style.h"
-#undef AtomInclude
+using namespace LAMMPS_NS;
 
 #define LB_FACTOR 1.1
 
 /* ---------------------------------------------------------------------- */
 
+ReadRestart::ReadRestart(LAMMPS *lmp) : Pointers(lmp) {}
+
+/* ---------------------------------------------------------------------- */
+
 void ReadRestart::command(int narg, char **arg)
 {
+  if (narg != 1) error->all("Illegal read_restart command");
+
   if (domain->box_exist) 
     error->all("Cannot read_restart after simulation box is defined");
 
-  if (narg != 1) error->all("Illegal read_restart command");
-
   MPI_Comm_rank(world,&me);
 
   // if filename contains "*", search dir for latest restart file
@@ -96,7 +99,7 @@ void ReadRestart::command(int narg, char **arg)
   else n = static_cast<int> (LB_FACTOR * atom->natoms / comm->nprocs);
 
   atom->allocate_type_arrays();
-  atom->grow(n);
+  atom->avec->grow(n);
 
   domain->set_initial_box();
   domain->set_global_box();
@@ -107,8 +110,8 @@ void ReadRestart::command(int narg, char **arg)
   // nextra = max # of extra quantities stored with each atom
 
   group->read_restart(fp);
-  if (atom->mass_require) mass();
-  if (atom->dipole_require) dipole();
+  if (atom->mass) mass();
+  if (atom->dipole) dipole();
   force_fields();
 
   int nextra = modify->read_restart(fp);
@@ -122,6 +125,8 @@ void ReadRestart::command(int narg, char **arg)
   // proc 0 bcasts each chunk to other procs
   // each proc unpacks the atoms, saving ones in it's sub-domain
 
+  AtomVec *avec = atom->avec;
+
   int maxbuf = 0;
   double *buf = NULL;
 
@@ -172,7 +177,7 @@ void ReadRestart::command(int narg, char **arg)
       if (xtmp >= subxlo && xtmp < subxhi &&
 	  ytmp >= subylo && ytmp < subyhi &&
 	  ztmp >= subzlo && ztmp < subzhi)
-	m += atom->unpack_restart(&buf[m]);
+	m += avec->unpack_restart(&buf[m]);
       else m += static_cast<int> (buf[m]);
     }
   }
@@ -231,7 +236,7 @@ void ReadRestart::command(int narg, char **arg)
     atom->map_set();
   }
   if (atom->molecular) {
-    Special special;
+    Special special(lmp);
     special.build();
   }
 }
@@ -246,19 +251,14 @@ void ReadRestart::file_search(char *infile, char *outfile)
 {
   // if filename contains "%" replace "%" with "base"
 
-  int multiproc;
   char *pattern = new char[strlen(infile) + 16];
   char *ptr;
 
   if (ptr = strchr(infile,'%')) {
-    multiproc = 1;
     *ptr = '\0';
     sprintf(pattern,"%s%s%s",infile,"base",ptr+1);
     *ptr = '%';
-  } else {
-    multiproc = 0;
-    strcpy(pattern,infile);
-  }
+  } else strcpy(pattern,infile);
 
   // scan all files in directory, searching for files that match pattern
   // maxnum = largest int that matches "*"
@@ -444,53 +444,25 @@ void ReadRestart::header()
 	  domain->nonperiodic = 2;
       }
 
-      // create atom class
+      // create new AtomVec class
       // if style = hybrid, read additional sub-class arguments
 
     } else if (flag == 19) {
       char *style = read_char();
 
-      int nwords,n;
-      char **words;
+      int nwords = 0;
+      char **words = NULL;
 
-      if (strcmp(style,"hybrid") != 0) {
-	nwords = 1;
-	words = new char*[nwords];
-	words[0] = style;
-      } else {
-	if (me == 0) fread(&nwords,sizeof(int),1,fp);
-	MPI_Bcast(&nwords,1,MPI_INT,0,world);
-	nwords++;
+      if (strcmp(style,"hybrid") == 0) {
+	nwords = read_int();
 	words = new char*[nwords];
-	words[0] = style;
-	for (int i = 1; i < nwords; i++) {
-	  if (me == 0) fread(&n,sizeof(int),1,fp);
-	  MPI_Bcast(&n,1,MPI_INT,0,world);
-	  words[i] = new char[n];
-	  if (me == 0) fread(words[i],sizeof(char),n,fp);
-	  MPI_Bcast(words[i],n,MPI_CHAR,0,world);
-	}
-      }
-
-      Atom *old = atom;
-	
-      if (0) return;         // dummy line to enable else-if macro expansion
-
-#define AtomClass
-#define AtomStyle(key,Class) \
-      else if (strcmp(style,#key) == 0) atom = new Class(nwords,words);
-#include "style.h"
-#undef AtomClass
-
-      else error->all("Unknown atom style in restart file");
-
-      if (old) {
-	atom->settings(old);
-	delete old;
+	for (int i = 0; i < nwords; i++) words[i] = read_char();
       }
 
+      atom->create_avec(style,nwords,words);
       for (int i = 0; i < nwords; i++) delete [] words[i];
       delete [] words;
+      delete [] style;
 
     } else if (flag == 20) {
       atom->natoms = read_double();
@@ -602,7 +574,7 @@ void ReadRestart::force_fields()
     force->pair->read_restart(fp);
   } else force->create_pair("none");
 
-  if (atom->bonds_allow) {
+  if (atom->avec->bonds_allow) {
     if (me == 0) fread(&n,sizeof(int),1,fp);
     MPI_Bcast(&n,1,MPI_INT,0,world);
     if (n) {
@@ -624,7 +596,7 @@ void ReadRestart::force_fields()
     } else force->create_bond("none");
   }
 
-  if (atom->angles_allow) {
+  if (atom->avec->angles_allow) {
     if (me == 0) fread(&n,sizeof(int),1,fp);
     MPI_Bcast(&n,1,MPI_INT,0,world);
     if (n) {
@@ -646,7 +618,7 @@ void ReadRestart::force_fields()
     } else force->create_angle("none");
   }
 
-  if (atom->dihedrals_allow) {
+  if (atom->avec->dihedrals_allow) {
     if (me == 0) fread(&n,sizeof(int),1,fp);
     MPI_Bcast(&n,1,MPI_INT,0,world);
     if (n) {
@@ -668,7 +640,7 @@ void ReadRestart::force_fields()
     } else force->create_dihedral("none");
   }
 
-  if (atom->impropers_allow) {
+  if (atom->avec->impropers_allow) {
     if (me == 0) fread(&n,sizeof(int),1,fp);
     MPI_Bcast(&n,1,MPI_INT,0,world);
     if (n) {
@@ -692,7 +664,7 @@ void ReadRestart::force_fields()
 }
 
 /* ----------------------------------------------------------------------
-   read an int from restart file 
+   read an int from restart file and bcast it
 ------------------------------------------------------------------------- */
 
 int ReadRestart::read_int()
@@ -704,7 +676,7 @@ int ReadRestart::read_int()
 }
 
 /* ----------------------------------------------------------------------
-   read a double from restart file 
+   read a double from restart file and bcast it
 ------------------------------------------------------------------------- */
 
 double ReadRestart::read_double()
@@ -716,7 +688,8 @@ double ReadRestart::read_double()
 }
 
 /* ----------------------------------------------------------------------
-   read a char str from restart file 
+   read a char str from restart file and bcast it
+   str is allocated here, ptr is returned, caller must deallocate
 ------------------------------------------------------------------------- */
 
 char *ReadRestart::read_char()
diff --git a/src/read_restart.h b/src/read_restart.h
index 69d5162b4bd92da6679307ef7fe92719e660de18..af10ce9123f4d57277628a960830b1dd1efc1ed3 100644
--- a/src/read_restart.h
+++ b/src/read_restart.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -15,12 +15,13 @@
 #define READ_RESTART_H
 
 #include "stdio.h"
-#include "lammps.h"
+#include "pointers.h"
 
-class ReadRestart : public LAMMPS {
+namespace LAMMPS_NS {
+
+class ReadRestart : protected Pointers {
  public:
-  ReadRestart() {}
-  ~ReadRestart() {}
+  ReadRestart(class LAMMPS *);
   void command(int, char **);
 
  private:
@@ -39,4 +40,6 @@ class ReadRestart : public LAMMPS {
   char *read_char();
 };
 
+}
+
 #endif
diff --git a/src/region.cpp b/src/region.cpp
index 5aeb6b8ac2392161e81aed5c08e72a3dc658ba2d..5a20cc10a9e48af9ec14140173a6bcca61031f95 100644
--- a/src/region.cpp
+++ b/src/region.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -18,9 +18,11 @@
 #include "lattice.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 /* ---------------------------------------------------------------------- */
 
-Region::Region(int narg, char **arg)
+Region::Region(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp)
 {
   int n = strlen(arg[0]) + 1;
   id = new char[n];
diff --git a/src/region.h b/src/region.h
index d491b7088dce6f9551b644592eccf216ca3c5281..804c39797e4c2fd2c94d7e2ebe5c0afc3401f7c3 100644
--- a/src/region.h
+++ b/src/region.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -14,9 +14,11 @@
 #ifndef REGION_H
 #define REGION_H
 
-#include "lammps.h"
+#include "pointers.h"
 
-class Region : public LAMMPS {
+namespace LAMMPS_NS {
+
+class Region : protected Pointers {
  public:
   char *id,*style;
   int interior;                     // 1 for interior, 0 for exterior
@@ -26,7 +28,7 @@ class Region : public LAMMPS {
   double extent_ylo,extent_yhi;
   double extent_zlo,extent_zhi;
   
-  Region(int, char **);
+  Region(class LAMMPS *, int, char **);
   virtual ~Region();
   virtual int match(double, double, double) = 0;
 
@@ -34,4 +36,6 @@ class Region : public LAMMPS {
   void options(int, char **);
 };
 
+}
+
 #endif
diff --git a/src/region_block.cpp b/src/region_block.cpp
index 8138aacfb43f1530bc39929ddcd67257dcbdb87e..fa4284981b33481b8e067f56cfd4dd98b8a9184c 100644
--- a/src/region_block.cpp
+++ b/src/region_block.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -17,9 +17,11 @@
 #include "domain.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 /* ---------------------------------------------------------------------- */
 
-RegBlock::RegBlock(int narg, char **arg) : Region(narg, arg)
+RegBlock::RegBlock(LAMMPS *lmp, int narg, char **arg) : Region(lmp, narg, arg)
 {
   options(narg-8,&arg[8]);
 
diff --git a/src/region_block.h b/src/region_block.h
index 5feae6267f3d4e34a9d571ed77a00161c6feae06..5c7de84769a56ad338990626ddc93753fac28250 100644
--- a/src/region_block.h
+++ b/src/region_block.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,16 +16,19 @@
 
 #include "region.h"
 
+namespace LAMMPS_NS {
+
 class RegBlock : public Region {
   friend class FixPour;
 
  public:
-  RegBlock(int, char **);
-  ~RegBlock() {}
+  RegBlock(class LAMMPS *, int, char **);
   int match(double, double, double);
 
  private:
   double xlo,xhi,ylo,yhi,zlo,zhi;
 };
 
+}
+
 #endif
diff --git a/src/region_cylinder.cpp b/src/region_cylinder.cpp
index 76f98e0c58d707998bb41d02c31c0ffb0b8b630d..3bac413c893852cdf34e5c82807009de4bd65377 100644
--- a/src/region_cylinder.cpp
+++ b/src/region_cylinder.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -18,9 +18,12 @@
 #include "domain.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 /* ---------------------------------------------------------------------- */
 
-RegCylinder::RegCylinder(int narg, char **arg) : Region(narg, arg)
+RegCylinder::RegCylinder(LAMMPS *lmp, int narg, char **arg) :
+  Region(lmp, narg, arg)
 {
   options(narg-8,&arg[8]);
 
diff --git a/src/region_cylinder.h b/src/region_cylinder.h
index 2ae2220e84488a8ffc9db5965a04066f9c342809..782710599a8faae241c9866f45da323be10b0483 100644
--- a/src/region_cylinder.h
+++ b/src/region_cylinder.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,12 +16,13 @@
 
 #include "region.h"
 
+namespace LAMMPS_NS {
+
 class RegCylinder : public Region {
   friend class FixPour;
 
  public:
-  RegCylinder(int, char **);
-  ~RegCylinder() {}
+  RegCylinder(class LAMMPS *, int, char **);
   int match(double, double, double);
 
  private:
@@ -31,4 +32,6 @@ class RegCylinder : public Region {
   double lo,hi;
 };
 
+}
+
 #endif
diff --git a/src/region_intersect.cpp b/src/region_intersect.cpp
index 6bf355d1768f7b78a075d02611cbd731bd203d59..8100439d051047f67655f01f56c73c3911488b7b 100644
--- a/src/region_intersect.cpp
+++ b/src/region_intersect.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -17,12 +17,15 @@
 #include "domain.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define MIN(A,B) ((A) < (B)) ? (A) : (B)
 #define MAX(A,B) ((A) > (B)) ? (A) : (B)
 
 /* ---------------------------------------------------------------------- */
 
-RegIntersect::RegIntersect(int narg, char **arg) : Region(narg, arg)
+RegIntersect::RegIntersect(LAMMPS *lmp, int narg, char **arg) :
+  Region(lmp, narg, arg)
 {
   if (narg < 5) error->all("Illegal region command");
   int n = atoi(arg[2]);
diff --git a/src/region_intersect.h b/src/region_intersect.h
index df775bca2993384431ba507733aa2e37f6a7e199..01ec72648d238c06e38fb559878e6ff21ca10cba 100644
--- a/src/region_intersect.h
+++ b/src/region_intersect.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,9 +16,11 @@
 
 #include "region.h"
 
+namespace LAMMPS_NS {
+
 class RegIntersect : public Region {
  public:
-  RegIntersect(int, char **);
+  RegIntersect(class LAMMPS *, int, char **);
   ~RegIntersect();
   int match(double, double, double);
 
@@ -27,4 +29,6 @@ class RegIntersect : public Region {
   int *list;
 };
 
+}
+
 #endif
diff --git a/src/region_prism.cpp b/src/region_prism.cpp
index f9650d83ae1675c98891faf56fa500fd62df4e06..33a56a4d4833d3dda4824434935f4b774dd89563 100644
--- a/src/region_prism.cpp
+++ b/src/region_prism.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -22,12 +22,14 @@
 #include "force.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define MIN(A,B) ((A) < (B)) ? (A) : (B)
 #define MAX(A,B) ((A) > (B)) ? (A) : (B)
 
 /* ---------------------------------------------------------------------- */
 
-RegPrism::RegPrism(int narg, char **arg) : Region(narg, arg)
+RegPrism::RegPrism(LAMMPS *lmp, int narg, char **arg) : Region(lmp, narg, arg)
 {
   options(narg-11,&arg[11]);
 
diff --git a/src/region_prism.h b/src/region_prism.h
index e7582959465f2223089b94c4f6a0ed28543403e9..98af0d96ba58a7fd2f80aef52d8c881fb0034144 100644
--- a/src/region_prism.h
+++ b/src/region_prism.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,10 +16,11 @@
 
 #include "region.h"
 
+namespace LAMMPS_NS {
+
 class RegPrism : public Region {
  public:
-  RegPrism(int, char **);
-  ~RegPrism() {}
+  RegPrism(class LAMMPS *, int, char **);
   int match(double, double, double);
 
  private:
@@ -28,4 +29,6 @@ class RegPrism : public Region {
   double h[3][3],hinv[3][3];
 };
 
+}
+
 #endif
diff --git a/src/region_sphere.cpp b/src/region_sphere.cpp
index c1a7eceacdc3d5647bb6c1c44d660de7a2bbcd71..8248fc1d4822ba17f9bacfa5cf542fdda15003bf 100644
--- a/src/region_sphere.cpp
+++ b/src/region_sphere.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -17,9 +17,12 @@
 #include "region_sphere.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 /* ---------------------------------------------------------------------- */
 
-RegSphere::RegSphere(int narg, char **arg) : Region(narg, arg)
+RegSphere::RegSphere(LAMMPS *lmp, int narg, char **arg) :
+  Region(lmp, narg, arg)
 {
   options(narg-6,&arg[6]);
 
diff --git a/src/region_sphere.h b/src/region_sphere.h
index 90ac095b2221e7f505f6442a05aef6ff0b750953..0055378258202b713868e6c6c786a55cdf2e325b 100644
--- a/src/region_sphere.h
+++ b/src/region_sphere.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,10 +16,11 @@
 
 #include "region.h"
 
+namespace LAMMPS_NS {
+
 class RegSphere : public Region {
  public:
-  RegSphere(int, char **);
-  ~RegSphere() {}
+  RegSphere(class LAMMPS *, int, char **);
   int match(double, double, double);
 
  private:
@@ -27,4 +28,6 @@ class RegSphere : public Region {
   double radius;
 };
 
+}
+
 #endif
diff --git a/src/region_union.cpp b/src/region_union.cpp
index aac4be08bb6f39067ce456ce88a03c4edbdbd074..834a72d0996ab1f7d1d62ca6ec7435b5f16846f3 100644
--- a/src/region_union.cpp
+++ b/src/region_union.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -17,6 +17,8 @@
 #include "domain.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define MIN(A,B) ((A) < (B)) ? (A) : (B)
 #define MAX(A,B) ((A) > (B)) ? (A) : (B)
 
@@ -24,7 +26,7 @@
 
 /* ---------------------------------------------------------------------- */
 
-RegUnion::RegUnion(int narg, char **arg) : Region(narg, arg)
+RegUnion::RegUnion(LAMMPS *lmp, int narg, char **arg) : Region(lmp, narg, arg)
 {
   if (narg < 5) error->all("Illegal region command");
   int n = atoi(arg[2]);
diff --git a/src/region_union.h b/src/region_union.h
index 0a2dbe8631ea918b572a2c2c1b911d6f4806090f..9be04ab1937c2dd16d99171d7cc873004badc740 100644
--- a/src/region_union.h
+++ b/src/region_union.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,9 +16,11 @@
 
 #include "region.h"
 
+namespace LAMMPS_NS {
+
 class RegUnion : public Region {
  public:
-  RegUnion(int, char **);
+  RegUnion(class LAMMPS *, int, char **);
   ~RegUnion();
   int match(double, double, double);
 
@@ -27,4 +29,6 @@ class RegUnion : public Region {
   int *list;
 };
 
+}
+
 #endif
diff --git a/src/replicate.cpp b/src/replicate.cpp
index a9232adf6e01f2ffdc298a1253d3387db3258627..290f2866854cd7d812f8b70ac9491dcae1e27827 100644
--- a/src/replicate.cpp
+++ b/src/replicate.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -15,7 +15,8 @@
 #include "string.h"
 #include "replicate.h"
 #include "atom.h"
-#include "atom_atomic.h"
+#include "atom_vec.h"
+#include "atom_vec_hybrid.h"
 #include "force.h"
 #include "domain.h"
 #include "comm.h"
@@ -23,9 +24,7 @@
 #include "memory.h"
 #include "error.h"
 
-#define AtomInclude
-#include "style.h"
-#undef AtomInclude
+using namespace LAMMPS_NS;
 
 #define LB_FACTOR 1.1
 #define MAXATOMS 0x7FFFFFFF
@@ -35,6 +34,10 @@
 
 /* ---------------------------------------------------------------------- */
 
+Replicate::Replicate(LAMMPS *lmp) : Pointers(lmp) {}
+
+/* ---------------------------------------------------------------------- */
+
 void Replicate::command(int narg, char **arg)
 {
   int i,j,m,n;
@@ -90,28 +93,34 @@ void Replicate::command(int narg, char **arg)
 
   for (i = 0; i < atom->nlocal; i++)
     domain->unmap(atom->x[i][0],atom->x[i][1],atom->x[i][2],atom->image[i]);
-  
-  // nwords, words = list of atom style keywords
-  // old = original atom class
-  // atom = new replicated atom class
 
-  char **words;
-  int nwords = atom->style2arg(words);
+  // communication buffer for all my atom's info
+  // max_size = largest buffer needed by any proc
+  // must do before new Atom class created,
+  //   since size_restart() uses atom->nlocal
 
-  Atom *old = atom;
-  
-  if (0) return;         // dummy line to enable else-if macro expansion
+  int max_size;
+  int send_size = atom->avec->size_restart();
+  MPI_Allreduce(&send_size,&max_size,1,MPI_INT,MPI_MAX,world);
 
-#define AtomClass
-#define AtomStyle(key,Class) \
-  else if (strcmp(old->style,#key) == 0) atom = new Class(nwords,words);
-#include "style.h"
-#undef AtomClass
+  double *buf = 
+    (double *) memory->smalloc(max_size*sizeof(double),"replicate:buf");
 
-  atom->settings(old);
+  // old = original atom class
+  // atom = new replicated atom class
+  // if old atom style was hybrid, pass sub-style names to create_avec
 
-  for (i = 0; i < nwords; i++) delete [] words[i];
-  delete [] words;
+  Atom *old = atom;
+  atom = new Atom(lmp);
+
+  int nstyles = 0;
+  char **keywords = NULL;
+  if (strcmp(old->atom_style,"hybrid") == 0) {
+    AtomVecHybrid *avec_hybrid = (AtomVecHybrid *) old->avec;
+    nstyles = avec_hybrid->nstyles;
+    keywords = avec_hybrid->keywords;
+  }
+  atom->create_avec(old->atom_style,nstyles,keywords);
 
   // check that new problem size will not be too large
   // if N > 2^31, turn off tags
@@ -148,15 +157,15 @@ void Replicate::command(int narg, char **arg)
 
   // store old simulation box
 
-  double oldxprd = domain->xprd;
-  double oldyprd = domain->yprd;
-  double oldzprd = domain->zprd;
+  double old_xprd = domain->xprd;
+  double old_yprd = domain->yprd;
+  double old_zprd = domain->zprd;
 
   // setup new simulation box
 
-  domain->boxxhi = domain->boxxlo + nx*oldxprd;
-  domain->boxyhi = domain->boxylo + ny*oldyprd;
-  domain->boxzhi = domain->boxzlo + nz*oldzprd;
+  domain->boxxhi = domain->boxxlo + nx*old_xprd;
+  domain->boxyhi = domain->boxylo + ny*old_yprd;
+  domain->boxzhi = domain->boxzlo + nz*old_zprd;
 
   // new problem setup using new box boundaries
 
@@ -164,7 +173,7 @@ void Replicate::command(int narg, char **arg)
   else n = static_cast<int> (LB_FACTOR * atom->natoms / nprocs);
 
   atom->allocate_type_arrays();
-  atom->grow(n);
+  atom->avec->grow(n);
 
   domain->set_initial_box();
   domain->set_global_box();
@@ -182,14 +191,14 @@ void Replicate::command(int narg, char **arg)
 
   // copy type arrays to new atom class
 
-  if (atom->mass_require) {
+  if (atom->mass) {
     for (int itype = 1; itype <= atom->ntypes; itype++) {
       atom->mass_setflag[itype] = old->mass_setflag[itype];
       if (atom->mass_setflag[itype]) atom->mass[itype] = old->mass[itype];
     }
   }
 
-  if (atom->dipole_require) {
+  if (atom->dipole) {
     for (int itype = 1; itype <= atom->ntypes; itype++) {
       atom->dipole_setflag[itype] = old->dipole_setflag[itype];
       if (atom->dipole_setflag[itype]) 
@@ -197,16 +206,6 @@ void Replicate::command(int narg, char **arg)
     }
   }
 
-  // communication buffer for all my atom's info
-  // max_size = largest buffer needed by any proc
-
-  int max_size;
-  int send_size = old->size_restart();
-  MPI_Allreduce(&send_size,&max_size,1,MPI_INT,MPI_MAX,world);
-
-  double *buf;
-  buf = (double *) memory->smalloc(max_size*sizeof(double),"replicate:buf");
-
   // loop over all procs
   // if this iteration of loop is me:
   //   pack my unmapped atom data into buf
@@ -216,6 +215,9 @@ void Replicate::command(int narg, char **arg)
   //   unpack atom into new atom class from buf if I own it
   //   adjust tag, mol #, coord, topology info as needed
 
+  AtomVec *old_avec = old->avec;
+  AtomVec *avec = atom->avec;
+
   int ix,iy,iz,image,atom_offset,mol_offset;
   double xnew,ynew,znew;
   int tag_enable = atom->tag_enable;
@@ -223,7 +225,7 @@ void Replicate::command(int narg, char **arg)
   for (int iproc = 0; iproc < nprocs; iproc++) {
     if (me == iproc) {
       n = 0;
-      for (i = 0; i < old->nlocal; i++) n += old->pack_restart(i,&buf[n]);
+      for (i = 0; i < old->nlocal; i++) n += old_avec->pack_restart(i,&buf[n]);
     }
     MPI_Bcast(&n,1,MPI_INT,iproc,world);
     MPI_Bcast(buf,n,MPI_DOUBLE,iproc,world);
@@ -234,9 +236,9 @@ void Replicate::command(int narg, char **arg)
 
 	  m = 0;
 	  while (m < n) {
-	    xnew = buf[m+1] + ix*oldxprd;
-	    ynew = buf[m+2] + iy*oldyprd;
-	    znew = buf[m+3] + iz*oldzprd;
+	    xnew = buf[m+1] + ix*old_xprd;
+	    ynew = buf[m+2] + iy*old_yprd;
+	    znew = buf[m+3] + iz*old_zprd;
 	    image = (512 << 20) | (512 << 10) | 512;
 	    domain->remap(xnew,ynew,znew,image);
 
@@ -244,7 +246,7 @@ void Replicate::command(int narg, char **arg)
 		ynew >= subylo && ynew < subyhi &&
 		znew >= subzlo && znew < subzhi) {
 
-	      m += atom->unpack_restart(&buf[m]);
+	      m += avec->unpack_restart(&buf[m]);
 
 	      i = atom->nlocal - 1;
 	      if (tag_enable)
@@ -262,23 +264,23 @@ void Replicate::command(int narg, char **arg)
 	      if (atom->molecular) {
 		if (atom->molecule[i] > 0)
 		  atom->molecule[i] += mol_offset;
-		if (atom->bonds_allow)
+		if (atom->avec->bonds_allow)
 		  for (j = 0; j < atom->num_bond[i]; j++)
 		    atom->bond_atom[i][j] += atom_offset;
-		if (atom->angles_allow)
+		if (atom->avec->angles_allow)
 		  for (j = 0; j < atom->num_angle[i]; j++) {
 		    atom->angle_atom1[i][j] += atom_offset;
 		    atom->angle_atom2[i][j] += atom_offset;
 		    atom->angle_atom3[i][j] += atom_offset;
 		  }
-		if (atom->dihedrals_allow)
+		if (atom->avec->dihedrals_allow)
 		  for (j = 0; j < atom->num_dihedral[i]; j++) {
 		    atom->dihedral_atom1[i][j] += atom_offset;
 		    atom->dihedral_atom2[i][j] += atom_offset;
 		    atom->dihedral_atom3[i][j] += atom_offset;
 		    atom->dihedral_atom4[i][j] += atom_offset;
 		  }
-		if (atom->impropers_allow)
+		if (atom->avec->impropers_allow)
 		  for (j = 0; j < atom->num_improper[i]; j++) {
 		    atom->improper_atom1[i][j] += atom_offset;
 		    atom->improper_atom2[i][j] += atom_offset;
@@ -339,7 +341,7 @@ void Replicate::command(int narg, char **arg)
     atom->map_set();
   }
   if (atom->molecular) {
-    Special special;
+    Special special(lmp);
     special.build();
   }
 }
diff --git a/src/replicate.h b/src/replicate.h
index 7ef68e3a778ecb3f07d9beda71ab05dbe6141b4a..ced23ef514f1960eeafaa599ff23e5b0e74dd278 100644
--- a/src/replicate.h
+++ b/src/replicate.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -14,13 +14,16 @@
 #ifndef REPLICATE_H
 #define REPLICATE_H
 
-#include "lammps.h"
+#include "pointers.h"
 
-class Replicate : public LAMMPS {
+namespace LAMMPS_NS {
+
+class Replicate : protected Pointers {
  public:
-  Replicate() {}
-  ~Replicate() {}
+  Replicate(class LAMMPS *);
   void command(int, char **);
 };
 
+}
+
 #endif
diff --git a/src/respa.cpp b/src/respa.cpp
index 380e9de384ef09867673b104afd6be0451e26d32..995a0f8a130dcc7d0d0995b85af2b85ab0c33bf9 100644
--- a/src/respa.cpp
+++ b/src/respa.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -32,15 +32,17 @@
 #include "kspace.h"
 #include "output.h"
 #include "update.h"
-#include "fix_respa.h"
 #include "modify.h"
+#include "fix_respa.h"
 #include "memory.h"
 #include "timer.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 /* ---------------------------------------------------------------------- */
 
-Respa::Respa(int narg, char **arg) : Integrate(narg, arg)
+Respa::Respa(LAMMPS *lmp, int narg, char **arg) : Integrate(lmp, narg, arg)
 {
   if (narg < 1) error->all("Illegal run_style respa command");
 
@@ -263,9 +265,7 @@ void Respa::init()
   modify->add_fix(4,fixarg);
   delete [] fixarg[3];
   delete [] fixarg;
-
-  for (int i = 0; i < modify->nfix; i++)
-    if (strcmp(modify->fix[i]->style,"RESPA") == 0) ifix_respa = i;
+  fix_respa = (FixRespa *) modify->fix[modify->nfix-1];
 
   // insure respa inner/middle/outer is using Pair class that supports it
 
@@ -534,7 +534,7 @@ void Respa::force_clear(int newtonflag)
 
 void Respa::copy_f_flevel(int ilevel)
 {
-  double ***f_level = ((FixRespa *) modify->fix[ifix_respa])->f_level;
+  double ***f_level = fix_respa->f_level;
   double **f = atom->f;
   int n = atom->nlocal;
 
@@ -551,7 +551,7 @@ void Respa::copy_f_flevel(int ilevel)
 
 void Respa::copy_flevel_f(int ilevel)
 {
-  double ***f_level = ((FixRespa *) modify->fix[ifix_respa])->f_level;
+  double ***f_level = fix_respa->f_level;
   double **f = atom->f;
   int n = atom->nlocal;
 
@@ -570,7 +570,7 @@ void Respa::sum_flevel_f()
 {
   copy_flevel_f(0);
 
-  double ***f_level = ((FixRespa *) modify->fix[ifix_respa])->f_level;
+  double ***f_level = fix_respa->f_level;
   double **f = atom->f;
   int n = atom->nlocal;
 
diff --git a/src/respa.h b/src/respa.h
index a1d5e920e48397a35b36500c93539a9a5dc3a844..d11a16ab4bed69163322efb8c930d16bb1f800d7 100644
--- a/src/respa.h
+++ b/src/respa.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,6 +16,8 @@
 
 #include "integrate.h"
 
+namespace LAMMPS_NS {
+
 class Respa : public Integrate {
  public:
                           // public so Fixes, Pairs, Neighbor can see them
@@ -31,7 +33,7 @@ class Respa : public Integrate {
   int level_improper,level_pair,level_kspace;
   int level_inner,level_middle,level_outer;
 
-  Respa(int, char **);
+  Respa(class LAMMPS *, int, char **);
   ~Respa();
   void init();
   void setup();
@@ -45,13 +47,15 @@ class Respa : public Integrate {
   int virial_every;       // what vflag should be on every timestep (0,1)
   int virial_thermo;      // what vflag should be on thermo steps (1)
 
-  int *newton;            // newton flag at each level
-  int eflag,vflag;        // flags for energy/virial computation
-  int ifix_respa;         // which Fix stores the force level array
+  int *newton;                  // newton flag at each level
+  int eflag,vflag;              // flags for energy/virial computation
+  class FixRespa *fix_respa;    // Fix to store the force level array
 
   void recurse(int);
   void force_clear(int);
   void sum_flevel_f();
 };
 
+}
+
 #endif
diff --git a/src/run.cpp b/src/run.cpp
index 89fa044ead8c1401dbed1b4bd867f7205127f8a8..d9d803457968f7a9bb05f57c0ce9df8822df0357 100644
--- a/src/run.cpp
+++ b/src/run.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -14,7 +14,6 @@
 #include "stdlib.h"
 #include "string.h"
 #include "run.h"
-#include "system.h"
 #include "domain.h"
 #include "update.h"
 #include "integrate.h"
@@ -24,11 +23,17 @@
 #include "timer.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define MIN(a,b) ((a) < (b) ? (a) : (b))
 #define MAX(a,b) ((a) > (b) ? (a) : (b))
 
 /* ---------------------------------------------------------------------- */
 
+Run::Run(LAMMPS *lmp) : Pointers(lmp) {}
+
+/* ---------------------------------------------------------------------- */
+
 void Run::command(int narg, char **arg)
 {
   if (narg < 1) error->all("Illegal run command");
@@ -123,7 +128,7 @@ void Run::command(int narg, char **arg)
     else update->endstep = update->laststep;
 
     if (preflag || update->first_update == 0) {
-      sys->init();
+      lmp->init();
       update->integrate->setup();
     } else {
       timer->init();
@@ -136,7 +141,7 @@ void Run::command(int narg, char **arg)
 
     update->integrate->cleanup();
 
-    Finish finish;
+    Finish finish(lmp);
     finish.end(postflag);
 
   // perform multiple runs interleaved with invocation of a command
@@ -161,7 +166,7 @@ void Run::command(int narg, char **arg)
       else update->endstep = update->laststep;
 
       if (preflag || iter == 0) {
-	sys->init();
+	lmp->init();
 	update->integrate->setup();
       } else {
 	timer->init();
@@ -174,7 +179,7 @@ void Run::command(int narg, char **arg)
 
       update->integrate->cleanup();
 
-      Finish finish;
+      Finish finish(lmp);
       if (postflag || nleft == 0) finish.end(1);
       else finish.end(0);
 
diff --git a/src/run.h b/src/run.h
index 242102f47e4622007f0db6abe88ad26d76c357d2..09816f4fa39ee424279b21a44b59bac4c11da358 100644
--- a/src/run.h
+++ b/src/run.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -14,13 +14,16 @@
 #ifndef RUN_H
 #define RUN_H
 
-#include "lammps.h"
+#include "pointers.h"
 
-class Run : public LAMMPS {
+namespace LAMMPS_NS {
+
+class Run : protected Pointers {
  public:
-  Run() {}
-  ~Run() {}
+  Run(class LAMMPS *);
   void command(int, char **);
 };
 
+}
+
 #endif
diff --git a/src/set.cpp b/src/set.cpp
index 47371505d6f50fe3d42792af4c83e7de39663e7b..8cb475ed62a4dd4f25d58f6eaaca9056a7710d1d 100644
--- a/src/set.cpp
+++ b/src/set.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,8 +16,8 @@
 #include "stdlib.h"
 #include "string.h"
 #include "set.h"
-#include "system.h"
 #include "atom.h"
+#include "atom_vec.h"
 #include "domain.h"
 #include "group.h"
 #include "comm.h"
@@ -27,6 +27,8 @@
 #include "random_park.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define ONEATOM  0
 #define ATOM     1
 #define BOND     2
@@ -40,6 +42,10 @@
 
 /* ---------------------------------------------------------------------- */
 
+Set::Set(LAMMPS *lmp) : Pointers(lmp) {}
+
+/* ---------------------------------------------------------------------- */
+
 void Set::command(int narg, char **arg)
 {
   if (domain->box_exist == 0)
@@ -72,15 +78,15 @@ void Set::command(int narg, char **arg)
   
   // consistency checks
 
-  if ((style == BOND && atom->bonds_allow == 0) ||
-      (style == ANGLE && atom->angles_allow == 0) ||
-      (style == DIHEDRAL && atom->dihedrals_allow == 0) ||
-      (style == IMPROPER && atom->impropers_allow == 0) ||
-      (style == CHARGE && atom->charge_allow == 0) ||
-      (style == DIPOLE && atom->dipole_require == 0))
+  if ((style == BOND && atom->avec->bonds_allow == 0) ||
+      (style == ANGLE && atom->avec->angles_allow == 0) ||
+      (style == DIHEDRAL && atom->avec->dihedrals_allow == 0) ||
+      (style == IMPROPER && atom->avec->impropers_allow == 0) ||
+      (style == CHARGE && atom->q == NULL) ||
+      (style == DIPOLE && atom->dipole == NULL))
     error->all("Cannot set this attribute for this atom style");
 
-  if (style == ONEATOM && strcmp(arg[1],"q") == 0 && atom->charge_allow == 0)
+  if (style == ONEATOM && strcmp(arg[1],"q") == 0 && atom->q == NULL)
     error->all("Cannot set this attribute for this atom style");
 
   if (style == ONEATOM && strcmp(arg[1],"mol") == 0 && atom->molecular == 0)
@@ -95,7 +101,7 @@ void Set::command(int narg, char **arg)
   if (style == BOND || style == ANGLE || 
       style == DIHEDRAL || style == IMPROPER) {
     if (comm->me == 0 && screen) fprintf(screen,"System init for set ...\n");
-    sys->init();
+    lmp->init();
 
     domain->pbc();
     domain->reset_box();
@@ -229,7 +235,7 @@ void Set::command(int narg, char **arg)
     int ivalue = atoi(arg[2]);
     if (ivalue <= 0) error->all("Invalid random number seed in set command");
     double msq,scale;
-    RanPark *random = new RanPark(ivalue + comm->me);
+    RanPark *random = new RanPark(lmp,ivalue + comm->me);
     for (int i = 0; i < WARMUP; i++) random->uniform();
     int *type = atom->type;
     double *dipole = atom->dipole;
diff --git a/src/set.h b/src/set.h
index e8b735af972909152e35d4dd97879f702a34e0a4..055bda48403fc208ed78de6ab76685077f4eefa0 100644
--- a/src/set.h
+++ b/src/set.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -14,13 +14,16 @@
 #ifndef SET_H
 #define SET_H
 
-#include "lammps.h"
+#include "pointers.h"
 
-class Set : public LAMMPS {
+namespace LAMMPS_NS {
+
+class Set : protected Pointers {
  public:
-  Set() {}
-  ~Set() {}
+  Set(class LAMMPS *);
   void command(int, char **);
 };
 
+}
+
 #endif
diff --git a/src/shell.cpp b/src/shell.cpp
index 0e74621e63f2947f1f43a487bb9d1c91103a47b3..9d80dc745eaca425b43048b881c6bce966437fc6 100644
--- a/src/shell.cpp
+++ b/src/shell.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -18,6 +18,12 @@
 #include "comm.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
+/* ---------------------------------------------------------------------- */
+
+Shell::Shell(LAMMPS *lmp) : Pointers(lmp) {}
+
 /* ---------------------------------------------------------------------- */
 
 void Shell::command(int narg, char **arg)
diff --git a/src/shell.h b/src/shell.h
index ddfc35783cdaa92310caa0a624731ec6903ef30e..326657e2a203619edeb4b68ed3ba64cc82740d1b 100644
--- a/src/shell.h
+++ b/src/shell.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -14,13 +14,16 @@
 #ifndef SHELL_H
 #define SHELL_H
 
-#include "lammps.h"
+#include "pointers.h"
 
-class Shell : public LAMMPS {
+namespace LAMMPS_NS {
+
+class Shell : protected Pointers {
  public:
-  Shell() {}
-  ~Shell() {}
+  Shell(class LAMMPS *);
   void command(int, char **);
 };
 
+}
+
 #endif
diff --git a/src/special.cpp b/src/special.cpp
index d2e984d34b55f2ba23dbfeecf69ce6ec6a9796e2..c5212594c268b36c10d85dd3c737ad2860ddfae3 100644
--- a/src/special.cpp
+++ b/src/special.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -15,16 +15,19 @@
 #include "stdio.h"
 #include "special.h"
 #include "atom.h"
+#include "atom_vec.h"
 #include "force.h"
 #include "memory.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define MIN(a,b) ((a) < (b) ? (a) : (b))
 #define MAX(a,b) ((a) > (b) ? (a) : (b))
 
 /* ---------------------------------------------------------------------- */
 
-Special::Special()
+Special::Special(LAMMPS *lmp) : Pointers(lmp)
 {
   MPI_Comm_rank(world,&me);
   MPI_Comm_size(world,&nprocs);
@@ -617,6 +620,7 @@ void Special::combine()
   // compute global maxspecial, must be at least 1
   // allocate correct special array with same nmax, new maxspecial
   // previously allocated one must be destroyed
+  // must force AtomVec class to update its ptr to special
 
   MPI_Allreduce(&maxspecial,&atom->maxspecial,1,MPI_INT,MPI_MAX,world);
   atom->maxspecial = MAX(atom->maxspecial,1);
@@ -632,6 +636,7 @@ void Special::combine()
 
   atom->special = 
     memory->create_2d_int_array(atom->nmax,atom->maxspecial,"atom:special");
+  atom->avec->reset_ptrs();
   int **special = atom->special;
 
   // ----------------------------------------------------
diff --git a/src/special.h b/src/special.h
index 3e495fb5734e06b3c5280e0e78db5aca5b2c7b24..96a03f8aadfee881e360d166eafe542038b5f836 100644
--- a/src/special.h
+++ b/src/special.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -14,11 +14,13 @@
 #ifndef SPECIAL_H
 #define SPECIAL_H
 
-#include "lammps.h"
+#include "pointers.h"
 
-class Special : public LAMMPS {
+namespace LAMMPS_NS {
+
+class Special : protected Pointers {
  public:
-  Special();
+  Special(class LAMMPS *);
   ~Special();
   void build();
 
@@ -29,4 +31,6 @@ class Special : public LAMMPS {
   void combine();
 };
 
+}
+
 #endif
diff --git a/src/style.h b/src/style.h
index 3b4a4ddb1fd31b021478e14ed07fd47a14072315..d97fcf7f0240d6f65e1176f6a1c56ef190dc543a 100644
--- a/src/style.h
+++ b/src/style.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -18,16 +18,16 @@
 #endif
 
 #ifdef AtomInclude
-#include "atom_atomic.h"
-#include "atom_charge.h"
-#include "atom_hybrid.h"
+#include "atom_vec_atomic.h"
+#include "atom_vec_charge.h"
+#include "atom_vec_hybrid.h"
 #endif
 
 #ifdef AtomClass
-AtomStyle(atomic,AtomAtomic)
-AtomStyle(charge,AtomCharge)
-AtomStyle(hybrid,AtomHybrid)
-# endif
+AtomStyle(atomic,AtomVecAtomic)
+AtomStyle(charge,AtomVecCharge)
+AtomStyle(hybrid,AtomVecHybrid)
+#endif
 
 #ifdef BondInclude
 #endif
@@ -71,6 +71,36 @@ CommandStyle(velocity,Velocity)
 CommandStyle(write_restart,WriteRestart)
 #endif
 
+#ifdef ComputeInclude
+#include "compute_centro_atom.h"
+#include "compute_epair_atom.h"
+#include "compute_etotal_atom.h"
+#include "compute_ke_atom.h"
+#include "compute_pressure.h"
+#include "compute_rotate_dipole.h"
+#include "compute_rotate_gran.h"
+#include "compute_stress_atom.h"
+#include "compute_temp.h"
+#include "compute_temp_partial.h"
+#include "compute_temp_ramp.h"
+#include "compute_temp_region.h"
+#endif
+
+#ifdef ComputeClass
+ComputeStyle(centro/atom,ComputeCentroAtom)
+ComputeStyle(epair/atom,ComputeEpairAtom)
+ComputeStyle(etotal/atom,ComputeEtotalAtom)
+ComputeStyle(ke/atom,ComputeKEAtom)
+ComputeStyle(pressure,ComputePressure)
+ComputeStyle(rotate/dipole,ComputeRotateDipole)
+ComputeStyle(rotate/gran,ComputeRotateGran)
+ComputeStyle(stress/atom,ComputeStressAtom)
+ComputeStyle(temp,ComputeTemp)
+ComputeStyle(temp/partial,ComputeTempPartial)
+ComputeStyle(temp/ramp,ComputeTempRamp)
+ComputeStyle(temp/region,ComputeTempRegion)
+#endif
+
 #ifdef DihedralInclude
 #endif
 
@@ -94,12 +124,10 @@ DumpStyle(xyz,DumpXYZ)
 #ifdef FixInclude
 #include "fix_add_force.h"
 #include "fix_ave_force.h"
-#include "fix_centro.h"
 #include "fix_com.h"
 #include "fix_drag.h"
 #include "fix_deposit.h"
 #include "fix_efield.h"
-#include "fix_energy.h"
 #include "fix_enforce2d.h"
 #include "fix_gravity.h"
 #include "fix_gyration.h"
@@ -122,10 +150,10 @@ DumpStyle(xyz,DumpXYZ)
 #include "fix_rigid.h"
 #include "fix_set_force.h"
 #include "fix_shake.h"
+#include "fix_shear_history.h"
 #include "fix_spring.h"
 #include "fix_spring_rg.h"
 #include "fix_spring_self.h"
-#include "fix_stress.h"
 #include "fix_temp_rescale.h"
 #include "fix_tmd.h"
 #include "fix_uniaxial.h"
@@ -140,12 +168,10 @@ DumpStyle(xyz,DumpXYZ)
 #ifdef FixClass
 FixStyle(addforce,FixAddForce)
 FixStyle(aveforce,FixAveForce)
-FixStyle(CENTRO,FixCentro)
 FixStyle(com,FixCOM)
 FixStyle(drag,FixDrag)
 FixStyle(deposit,FixDeposit)
 FixStyle(efield,FixEfield)
-FixStyle(ENERGY,FixEnergy)
 FixStyle(enforce2d,FixEnforce2D)
 FixStyle(gravity,FixGravity)
 FixStyle(gyration,FixGyration)
@@ -168,10 +194,10 @@ FixStyle(RESPA,FixRespa)
 FixStyle(rigid,FixRigid)
 FixStyle(setforce,FixSetForce)
 FixStyle(shake,FixShake)
+FixStyle(SHEAR_HISTORY,FixShearHistory)
 FixStyle(spring,FixSpring)
 FixStyle(spring/rg,FixSpringRG)
 FixStyle(spring/self,FixSpringSelf)
-FixStyle(STRESS,FixStress)
 FixStyle(temp/rescale,FixTempRescale)
 FixStyle(tmd,FixTMD)
 FixStyle(uniaxial,FixUniaxial)
@@ -265,20 +291,6 @@ RegionStyle(sphere,RegSphere)
 RegionStyle(union,RegUnion)
 #endif
 
-#ifdef TempInclude
-#include "temp_full.h"
-#include "temp_partial.h"
-#include "temp_ramp.h"
-#include "temp_region.h"
-#endif
-
-#ifdef TempClass
-TempStyle(full,TempFull)
-TempStyle(partial,TempPartial)
-TempStyle(ramp,TempRamp)
-TempStyle(region,TempRegion)
-#endif
-
 // style files for optional packages
 
 #include "style_class2.h"
@@ -288,6 +300,7 @@ TempStyle(region,TempRegion)
 #include "style_manybody.h"
 #include "style_meam.h"
 #include "style_molecule.h"
+#include "style_opt.h"
 #include "style_poems.h"
 #include "style_xtc.h"
 
diff --git a/src/style_class2.h b/src/style_class2.h
index 517070d25f468e8dda6dbfa60986e7e985eb4350..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644
--- a/src/style_class2.h
+++ b/src/style_class2.h
@@ -1,56 +0,0 @@
-/* ----------------------------------------------------------------------
-   LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
-
-   Copyright (2003) Sandia Corporation.  Under the terms of Contract
-   DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
-   certain rights in this software.  This software is distributed under 
-   the GNU General Public License.
-
-   See the README file in the top-level LAMMPS directory.
-------------------------------------------------------------------------- */
-
-#ifdef AngleInclude
-#include "angle_class2.h"
-#endif
-
-#ifdef AngleClass
-AngleStyle(class2,AngleClass2)
-#endif
-
-#ifdef BondInclude
-#include "bond_class2.h"
-#endif
-
-#ifdef BondClass
-BondStyle(class2,BondClass2)
-#endif
-
-#ifdef DihedralInclude
-#include "dihedral_class2.h"
-#endif
-
-#ifdef DihedralClass
-DihedralStyle(class2,DihedralClass2)
-#endif
-
-#ifdef ImproperInclude
-#include "improper_class2.h"
-#endif
-
-#ifdef ImproperClass
-ImproperStyle(class2,ImproperClass2)
-#endif
-
-#ifdef PairInclude
-#include "pair_lj_class2.h"
-#include "pair_lj_class2_coul_cut.h"
-#include "pair_lj_class2_coul_long.h"
-#endif
-
-#ifdef PairClass
-PairStyle(lj/class2,PairLJClass2)
-PairStyle(lj/class2/coul/cut,PairLJClass2CoulCut)
-PairStyle(lj/class2/coul/long,PairLJClass2CoulLong)
-#endif
diff --git a/src/style_dpd.h b/src/style_dpd.h
index 0b5d131f2f0e63bac92ed16dfad8f01ad8d1dc87..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644
--- a/src/style_dpd.h
+++ b/src/style_dpd.h
@@ -1,28 +0,0 @@
-/* ----------------------------------------------------------------------
-   LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
-
-   Copyright (2003) Sandia Corporation.  Under the terms of Contract
-   DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
-   certain rights in this software.  This software is distributed under 
-   the GNU General Public License.
-
-   See the README file in the top-level LAMMPS directory.
-------------------------------------------------------------------------- */
-
-#ifdef AtomInclude
-#include "atom_dpd.h"
-#endif
-
-#ifdef AtomClass
-AtomStyle(dpd,AtomDPD)
-#endif
-
-#ifdef PairInclude
-#include "pair_dpd.h"
-#endif
-
-#ifdef PairClass
-PairStyle(dpd,PairDPD)
-#endif
diff --git a/src/style_granular.h b/src/style_granular.h
index b221551953836ac26d696e6b63e5310ecf72156d..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644
--- a/src/style_granular.h
+++ b/src/style_granular.h
@@ -1,50 +0,0 @@
-/* ----------------------------------------------------------------------
-   LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
-
-   Copyright (2003) Sandia Corporation.  Under the terms of Contract
-   DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
-   certain rights in this software.  This software is distributed under 
-   the GNU General Public License.
-
-   See the README file in the top-level LAMMPS directory.
-------------------------------------------------------------------------- */
-
-#ifdef AtomInclude
-#include "atom_granular.h"
-#endif
-
-#ifdef AtomClass
-AtomStyle(granular,AtomGranular)
-# endif
-
-#ifdef FixInclude
-#include "fix_freeze.h"
-#include "fix_gran_diag.h"
-#include "fix_nve_gran.h"
-#include "fix_pour.h"
-#include "fix_shear_history.h"
-#include "fix_wall_gran.h"
-#endif
-
-#ifdef FixClass
-FixStyle(freeze,FixFreeze)
-FixStyle(gran/diag,FixGranDiag)
-FixStyle(nve/gran,FixNVEGran)
-FixStyle(pour,FixPour)
-FixStyle(SHEAR_HISTORY,FixShearHistory)
-FixStyle(wall/gran,FixWallGran)
-#endif
-
-#ifdef PairInclude
-#include "pair_gran_hertzian.h"
-#include "pair_gran_history.h"
-#include "pair_gran_no_history.h"
-#endif
-
-#ifdef PairClass
-PairStyle(gran/hertzian,PairGranHertzian)
-PairStyle(gran/history,PairGranHistory)
-PairStyle(gran/no_history,PairGranNoHistory)
-#endif
diff --git a/src/style_kspace.h b/src/style_kspace.h
index c6ea29b73ba6eed64bbff0f68bafbfe53a3682af..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644
--- a/src/style_kspace.h
+++ b/src/style_kspace.h
@@ -1,38 +0,0 @@
-/* ----------------------------------------------------------------------
-   LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
-
-   Copyright (2003) Sandia Corporation.  Under the terms of Contract
-   DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
-   certain rights in this software.  This software is distributed under 
-   the GNU General Public License.
-
-   See the README file in the top-level LAMMPS directory.
-------------------------------------------------------------------------- */
-
-#ifdef KSpaceInclude
-#include "ewald.h"
-#include "pppm.h"
-#include "pppm_tip4p.h"
-#endif
-
-#ifdef KSpaceClass
-KSpaceStyle(ewald,Ewald)
-KSpaceStyle(pppm,PPPM)
-KSpaceStyle(pppm/tip4p,PPPMTIP4P)
-#endif
-
-#ifdef PairInclude
-#include "pair_buck_coul_long.h"
-#include "pair_lj_cut_coul_long.h"
-#include "pair_lj_cut_coul_long_tip4p.h"
-#include "pair_lj_charmm_coul_long.h"
-#endif
-
-#ifdef PairClass
-PairStyle(buck/coul/long,PairBuckCoulLong)
-PairStyle(lj/cut/coul/long,PairLJCutCoulLong)
-PairStyle(lj/cut/coul/long/tip4p,PairLJCutCoulLongTIP4P)
-PairStyle(lj/charmm/coul/long,PairLJCharmmCoulLong)
-#endif
diff --git a/src/style_manybody.h b/src/style_manybody.h
index 2ba8d7cfd1a35345afa80cbde8224d70ad1886f6..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644
--- a/src/style_manybody.h
+++ b/src/style_manybody.h
@@ -1,28 +0,0 @@
-/* ----------------------------------------------------------------------
-   LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
-
-   Copyright (2003) Sandia Corporation.  Under the terms of Contract
-   DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
-   certain rights in this software.  This software is distributed under 
-   the GNU General Public License.
-
-   See the README file in the top-level LAMMPS directory.
-------------------------------------------------------------------------- */
-
-#ifdef PairInclude
-#include "pair_eam.h"
-#include "pair_eam_alloy.h"
-#include "pair_eam_fs.h"
-#include "pair_sw.h"
-#include "pair_tersoff.h"
-#endif
-
-#ifdef PairClass
-PairStyle(eam,PairEAM)
-PairStyle(eam/alloy,PairEAMAlloy)
-PairStyle(eam/fs,PairEAMFS)
-PairStyle(sw,PairSW)
-PairStyle(tersoff,PairTersoff)
-#endif
diff --git a/src/style_molecule.h b/src/style_molecule.h
index 1da512819deb46125711b59dfbab8f93311e48fc..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644
--- a/src/style_molecule.h
+++ b/src/style_molecule.h
@@ -1,116 +0,0 @@
-/* ----------------------------------------------------------------------
-   LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
-
-   Copyright (2003) Sandia Corporation.  Under the terms of Contract
-   DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
-   certain rights in this software.  This software is distributed under 
-   the GNU General Public License.
-
-   See the README file in the top-level LAMMPS directory.
-------------------------------------------------------------------------- */
-
-#ifdef AngleInclude
-#include "angle_charmm.h"
-#include "angle_cosine.h"
-#include "angle_cosine_squared.h"
-#include "angle_harmonic.h"
-#include "angle_hybrid.h"
-#endif
-
-#ifdef AngleClass
-AngleStyle(charmm,AngleCharmm)
-AngleStyle(cosine,AngleCosine)
-AngleStyle(cosine/squared,AngleCosineSquared)
-AngleStyle(harmonic,AngleHarmonic)
-AngleStyle(hybrid,AngleHybrid)
-#endif
-
-#ifdef AtomInclude
-#include "atom_angle.h"
-#include "atom_bond.h"
-#include "atom_full.h"
-#include "atom_molecular.h"
-#endif
-
-#ifdef AtomClass
-AtomStyle(angle,AtomAngle)
-AtomStyle(bond,AtomBond)
-AtomStyle(full,AtomFull)
-AtomStyle(molecular,AtomMolecular)
-#endif
-
-#ifdef BondInclude
-#include "bond_fene.h"
-#include "bond_fene_expand.h"
-#include "bond_harmonic.h"
-#include "bond_hybrid.h"
-#include "bond_morse.h"
-#include "bond_nonlinear.h"
-#include "bond_quartic.h"
-#endif
-
-#ifdef BondClass
-BondStyle(fene,BondFENE)
-BondStyle(fene/expand,BondFENEExpand)
-BondStyle(harmonic,BondHarmonic)
-BondStyle(hybrid,BondHybrid)
-BondStyle(morse,BondMorse)
-BondStyle(nonlinear,BondNonlinear)
-BondStyle(quartic,BondQuartic)
-#endif
-
-#ifdef DihedralInclude
-#include "dihedral_charmm.h"
-#include "dihedral_harmonic.h"
-#include "dihedral_helix.h"
-#include "dihedral_hybrid.h"
-#include "dihedral_multi_harmonic.h"
-#include "dihedral_opls.h"
-#endif
-
-#ifdef DihedralClass
-DihedralStyle(charmm,DihedralCharmm)
-DihedralStyle(harmonic,DihedralHarmonic)
-DihedralStyle(helix,DihedralHelix)
-DihedralStyle(hybrid,DihedralHybrid)
-DihedralStyle(multi/harmonic,DihedralMultiHarmonic)
-DihedralStyle(opls,DihedralOPLS)
-#endif
-
-#ifdef DumpInclude
-#include "dump_bond.h"
-#endif
-
-#ifdef DumpClass
-DumpStyle(bond,DumpBond)
-#endif
-
-#ifdef FixInclude
-#endif
-
-#ifdef FixClass
-#endif
-
-#ifdef ImproperInclude
-#include "improper_cvff.h"
-#include "improper_harmonic.h"
-#include "improper_hybrid.h"
-#endif
-
-#ifdef ImproperClass
-ImproperStyle(cvff,ImproperCvff)
-ImproperStyle(harmonic,ImproperHarmonic)
-ImproperStyle(hybrid,ImproperHybrid)
-#endif
-
-#ifdef PairInclude
-#include "pair_lj_charmm_coul_charmm.h"
-#include "pair_lj_charmm_coul_charmm_implicit.h"
-#endif
-
-#ifdef PairClass
-PairStyle(lj/charmm/coul/charmm,PairLJCharmmCoulCharmm)
-PairStyle(lj/charmm/coul/charmm/implicit,PairLJCharmmCoulCharmmImplicit)
-#endif
diff --git a/src/style_user.h b/src/style_user.h
index 213b114efdf217467659ea26e9b2a0b25b06d1c2..57c6a0d0b2f64d1ca669cda26a73d347288499e5 100644
--- a/src/style_user.h
+++ b/src/style_user.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
diff --git a/src/system.cpp b/src/system.cpp
deleted file mode 100644
index 874a10ef00065c0b073aca7fc0a4133d94b1e3db..0000000000000000000000000000000000000000
--- a/src/system.cpp
+++ /dev/null
@@ -1,324 +0,0 @@
-/* ----------------------------------------------------------------------
-   LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
-
-   Copyright (2003) Sandia Corporation.  Under the terms of Contract
-   DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
-   certain rights in this software.  This software is distributed under 
-   the GNU General Public License.
-
-   See the README file in the top-level LAMMPS directory.
-------------------------------------------------------------------------- */
-
-#include "mpi.h"
-#include "string.h"
-#include "system.h"
-#include "memory.h"
-#include "error.h"
-#include "universe.h"
-#include "input.h"
-#include "atom.h"
-#include "update.h"
-#include "neighbor.h"
-#include "comm.h"
-#include "domain.h"
-#include "force.h"
-#include "modify.h"
-#include "group.h"
-#include "output.h"
-#include "timer.h"
-
-/* ----------------------------------------------------------------------
-   allocate fundamental classes (memory, error, universe, input)
-   parse input switches
-   initialize communicators, screen & logfile output
-   input is allocated at end after MPI info is setup
-------------------------------------------------------------------------- */
-
-void System::open(int narg, char **arg, MPI_Comm communicator)
-{
-  memory = new Memory;
-  error = new Error;
-  universe = new Universe(communicator);
-
-  // parse input switches
-
-  int inflag = 0;
-  int screenflag = 0;
-  int logflag = 0;
-  int iarg = 1;
-
-  while (iarg < narg) {
-    if (strcmp(arg[iarg],"-partition") == 0) {
-      if (iarg+1 > narg) 
-	error->universe_all("Invalid command-line argument");
-      iarg++;
-      while (iarg < narg && arg[iarg][0] != '-') {
-	universe->add_world(arg[iarg]);
-	iarg++;
-      }
-    } else if (strcmp(arg[iarg],"-in") == 0) {
-      if (iarg+2 > narg) 
-	error->universe_all("Invalid command-line argument");
-      inflag = iarg + 1;
-      iarg += 2;
-    } else if (strcmp(arg[iarg],"-screen") == 0) {
-      if (iarg+2 > narg) 
-	error->universe_all("Invalid command-line argument");
-      screenflag = iarg + 1;
-      iarg += 2;
-    } else if (strcmp(arg[iarg],"-log") == 0) {
-      if (iarg+2 > narg) 
-	error->universe_all("Invalid command-line argument");
-      logflag = iarg + 1;
-      iarg += 2;
-    } else if (strcmp(arg[iarg],"-var") == 0) {
-      if (iarg+3 > narg) 
-	error->universe_all("Invalid command-line argument");
-      iarg += 3;
-    } else if (strcmp(arg[iarg],"-echo") == 0) {
-      if (iarg+2 > narg) 
-	error->universe_all("Invalid command-line argument");
-      iarg += 2;
-    } else error->universe_all("Invalid command-line argument");
-  }
-
-  // if procs was not a command-line switch, universe is one world w/ all procs
-
-  if (universe->nworlds == 0) universe->add_world(NULL);
-
-  // sum of procs in all worlds must equal total # of procs
-
-  if (!universe->consistent())
-    error->universe_all("Processor partitions are inconsistent");
-
-  // multiple-world universe must define input file
-
-  if (universe->nworlds > 1 && inflag == 0)
-    error->universe_all("Must use -in switch with multiple partitions");
-
-  // set universe screen and logfile
-
-  if (universe->me == 0) {
-    if (screenflag == 0)
-      universe->uscreen = stdout;
-    else if (strcmp(arg[screenflag],"none") == 0)
-      universe->uscreen = NULL;
-    else {
-      universe->uscreen = fopen(arg[screenflag],"w");
-      if (universe->uscreen == NULL) 
-	error->universe_one("Cannot open universe screen file");
-    }
-    if (logflag == 0) {
-      universe->ulogfile = fopen("log.lammps","w");
-      if (universe->ulogfile == NULL) 
-	error->universe_one("Cannot open log.lammps");
-    } else if (strcmp(arg[logflag],"none") == 0)
-      universe->ulogfile = NULL;
-    else {
-      universe->ulogfile = fopen(arg[logflag],"w");
-      if (universe->ulogfile == NULL) 
-	error->universe_one("Cannot open universe log file");
-    }
-  }
-
-  if (universe->me > 0) {
-    if (screenflag == 0) universe->uscreen = stdout;
-    else universe->uscreen = NULL;
-    universe->ulogfile = NULL;
-  }
-
-  // universe is single world
-  // inherit settings from universe
-  // set world screen, logfile, communicator, infile
-  // open input script if from file
-
-  if (universe->nworlds == 1) {
-    screen = universe->uscreen;
-    logfile = universe->ulogfile;
-    world = universe->uworld;
-    infile = NULL;
-
-    if (universe->me == 0) {
-      if (inflag == 0) infile = stdin;
-      else infile = fopen(arg[inflag],"r");
-      if (infile == NULL) {
-	char str[128];
-	sprintf(str,"Cannot open input script %s",arg[inflag]);
-	error->one(str);
-      }
-    }
-
-    if (universe->me == 0) {
-      if (screen) fprintf(screen,"LAMMPS (%s)\n",universe->version);
-      if (logfile) fprintf(logfile,"LAMMPS (%s)\n",universe->version);
-    }
-
-  // universe is multiple worlds
-  // split into separate communicators
-  // set world screen, logfile, communicator, infile
-  // open input script
-
-  } else {
-    int me;
-    MPI_Comm_split(universe->uworld,universe->iworld,0,&world);
-    MPI_Comm_rank(world,&me);
-
-    if (me == 0) {
-      if (screenflag == 0) {
-	char str[32];
-	sprintf(str,"screen.%d",universe->iworld);
-	screen = fopen(str,"w");
-	if (screen == NULL) error->one("Cannot open screen file");
-      } else if (strcmp(arg[screenflag],"none") == 0)
-	screen = NULL;
-      else {
-	char str[128];
-	sprintf(str,"%s.%d",arg[screenflag],universe->iworld);
-	screen = fopen(str,"w");
-	if (screen == NULL) error->one("Cannot open screen file");
-      }
-    } else screen = NULL;
-    
-    if (me == 0) {
-      if (logflag == 0) {
-	char str[32];
-	sprintf(str,"log.lammps.%d",universe->iworld);
-	logfile = fopen(str,"w");
-	if (logfile == NULL) error->one("Cannot open logfile");
-      } else if (strcmp(arg[logflag],"none") == 0)
-	logfile = NULL;
-      else {
-	char str[128];
-	sprintf(str,"%s.%d",arg[logflag],universe->iworld);
-	logfile = fopen(str,"w");
-	if (logfile == NULL) error->one("Cannot open logfile");
-      }
-    } else logfile = NULL;
-    
-    if (me == 0) {
-      infile = fopen(arg[inflag],"r");
-      if (infile == NULL) {
-	char str[128];
-	sprintf(str,"Cannot open input script %s",arg[inflag]);
-	error->one(str);
-      }
-    } else infile = NULL;
-    
-    // screen and logfile messages for universe and world
-    
-    if (universe->me == 0) {
-      if (universe->uscreen) {
-	fprintf(universe->uscreen,"LAMMPS (%s)\n",universe->version);
-	fprintf(universe->uscreen,"Running on %d partitions of processors\n",
-		universe->nworlds);
-      }
-      if (universe->ulogfile) {
-	fprintf(universe->ulogfile,"LAMMPS (%s)\n",universe->version);
-	fprintf(universe->ulogfile,"Running on %d partitions of processors\n",
-		universe->nworlds);
-      }
-    }
-    
-    if (me == 0) {
-      if (screen) {
-	fprintf(screen,"LAMMPS (%s)\n",universe->version);
-	fprintf(screen,"Processor partition = %d\n",universe->iworld);
-      }
-      if (logfile) {
-	fprintf(logfile,"LAMMPS (%s)\n",universe->version);
-	fprintf(logfile,"Processor partition = %d\n",universe->iworld);
-      }
-    }
-  }
-
-  // allocate input class now that MPI is fully setup
-
-  input = new Input(narg,arg);
-}
-
-/* ----------------------------------------------------------------------
-   allocate single instance of top-level classes
-   fundamental classes are allocated in open()
-   atom is allocated via input script
-------------------------------------------------------------------------- */
-
-void System::create()
-{
-  neighbor = new Neighbor;
-  comm = new Comm;
-  domain = new Domain;
-  group = new Group;
-  force = new Force;             // must be after group, to create temperature
-  modify = new Modify;
-  output = new Output;           // must be after group, so "all" exists
-  update = new Update;           // must be after output, force, neighbor
-  timer = new Timer;
-}
-
-/* ----------------------------------------------------------------------
-   init top-level classes
-------------------------------------------------------------------------- */
-
-void System::init()
-{
-  update->init();
-  force->init();
-  domain->init();
-  atom->init();          // atom must come after force:
-                         //   atom deletes extra array
-                         //   used by fix shear_history::unpack_restart()
-                         //   when force->pair->gran_history creates fix ??
-  modify->init();        // modify must come after update, force, atom
-  neighbor->init();      // neighbor must come after force, modify (due to min)
-  output->init();        // output must come after domain, force, modify
-  comm->init();          // comm must come after force, modify
-  timer->init();
-}
-
-/* ----------------------------------------------------------------------
-   delete single instance of top-level classes
-   fundamental classes are deleted in close()
-------------------------------------------------------------------------- */
-
-void System::destroy()
-{
-  if (atom) delete atom;
-  atom = NULL;
-
-  delete update;
-  delete neighbor;
-  delete comm;
-  delete domain;
-  delete force;
-  delete group;
-  delete output;
-  delete modify;          // modify must come after output, force, update
-  delete timer;
-}
-
-/* ----------------------------------------------------------------------
-   shutdown system
-   close screen and log files in world and universe
-   output files were already closed in system::destroy()
-   delete fundamental classes
-------------------------------------------------------------------------- */
-
-void System::close()
-{
-  if (universe->nworlds == 1) {
-    if (logfile) fclose(logfile);
-  } else {
-    if (screen && screen != stdout) fclose(screen);
-    if (logfile) fclose(logfile);
-    if (universe->ulogfile) fclose(universe->ulogfile);
-  }
-
-  if (world != universe->uworld) MPI_Comm_free(&world);
-
-  delete input;
-  delete universe;
-  delete error;
-  delete memory;
-}
diff --git a/src/system.h b/src/system.h
deleted file mode 100644
index 7d2735444d2ef2863715629dc00fc0e4b6d9f0f0..0000000000000000000000000000000000000000
--- a/src/system.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/* ----------------------------------------------------------------------
-   LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
-
-   Copyright (2003) Sandia Corporation.  Under the terms of Contract
-   DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
-   certain rights in this software.  This software is distributed under 
-   the GNU General Public License.
-
-   See the README file in the top-level LAMMPS directory.
-------------------------------------------------------------------------- */
-
-#ifndef SYSTEM_H
-#define SYSTEM_H
-
-#include "mpi.h"
-#include "lammps.h"
-
-class System : public LAMMPS {
- public:
-  void open(int, char **, MPI_Comm);
-  void create();
-  void init();
-  void destroy();
-  void close();
-};
-
-#endif
diff --git a/src/temp_full.cpp b/src/temp_full.cpp
deleted file mode 100644
index 10b6516149cbe14796e68616d8d2d7741fc5392e..0000000000000000000000000000000000000000
--- a/src/temp_full.cpp
+++ /dev/null
@@ -1,108 +0,0 @@
-/* ----------------------------------------------------------------------
-   LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
-
-   Copyright (2003) Sandia Corporation.  Under the terms of Contract
-   DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
-   certain rights in this software.  This software is distributed under 
-   the GNU General Public License.
-
-   See the README file in the top-level LAMMPS directory.
-------------------------------------------------------------------------- */
-
-#include "mpi.h"
-#include "temp_full.h"
-#include "atom.h"
-#include "force.h"
-#include "group.h"
-#include "error.h"
-
-/* ---------------------------------------------------------------------- */
-
-TempFull::TempFull(int narg, char **arg) : Temperature(narg, arg)
-{
-  options(narg-3,&arg[3]);
-}
-
-/* ---------------------------------------------------------------------- */
-
-void TempFull::init()
-{
-  count_fix();
-  recount();
-}
-
-/* ---------------------------------------------------------------------- */
-
-void TempFull::recount()
-{
-  double natoms = group->count(igroup);
-  dof = force->dimension * natoms;
-  dof -= extra_dof + fix_dof;
-  if (dof > 0) tfactor = force->mvv2e / (dof * force->boltz);
-  else tfactor = 0.0;
-}
-
-/* ---------------------------------------------------------------------- */
-
-double TempFull::compute()
-{
-  double **v = atom->v;
-  double *mass = atom->mass;
-  double *rmass = atom->rmass;
-  int *type = atom->type;
-  int *mask = atom->mask;
-  int nlocal = atom->nlocal;
-
-  double t = 0.0;
-
-  if (atom->mass_require) {
-    for (int i = 0; i < nlocal; i++)
-      if (mask[i] & groupbit)
-	t += (v[i][0]*v[i][0] + v[i][1]*v[i][1] + v[i][2]*v[i][2]) * 
-	  mass[type[i]];
-  } else {
-    for (int i = 0; i < nlocal; i++)
-      if (mask[i] & groupbit)
-	t += (v[i][0]*v[i][0] + v[i][1]*v[i][1] + v[i][2]*v[i][2]) * rmass[i];
-  }
-
-  MPI_Allreduce(&t,&t_total,1,MPI_DOUBLE,MPI_SUM,world);
-  if (dynamic) recount();
-  t_total *= tfactor;
-  return t_total;
-}
-
-/* ---------------------------------------------------------------------- */
-
-void TempFull::tensor()
-{
-  int i;
-
-  double **v = atom->v;
-  double *mass = atom->mass;
-  double *rmass = atom->rmass;
-  int *type = atom->type;
-  int *mask = atom->mask;
-  int nlocal = atom->nlocal;
-  int mass_require = atom->mass_require;
-
-  double massone,t[6];
-  for (i = 0; i < 6; i++) t[i] = 0.0;
-
-  for (i = 0; i < nlocal; i++)
-    if (mask[i] & groupbit) {
-      if (mass_require) massone = mass[type[i]];
-      else massone = rmass[i];
-      t[0] += massone * v[i][0]*v[i][0];
-      t[1] += massone * v[i][1]*v[i][1];
-      t[2] += massone * v[i][2]*v[i][2];
-      t[3] += massone * v[i][0]*v[i][1];
-      t[4] += massone * v[i][0]*v[i][2];
-      t[5] += massone * v[i][1]*v[i][2];
-    }
-
-  MPI_Allreduce(&t,&ke_tensor,6,MPI_DOUBLE,MPI_SUM,world);
-  for (i = 0; i < 6; i++) ke_tensor[i] *= force->mvv2e;
-}
diff --git a/src/temp_full.h b/src/temp_full.h
deleted file mode 100644
index d413f1ec8c47296190c39e1dc7420c900ef80cfb..0000000000000000000000000000000000000000
--- a/src/temp_full.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/* ----------------------------------------------------------------------
-   LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
-
-   Copyright (2003) Sandia Corporation.  Under the terms of Contract
-   DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
-   certain rights in this software.  This software is distributed under 
-   the GNU General Public License.
-
-   See the README file in the top-level LAMMPS directory.
-------------------------------------------------------------------------- */
-
-#ifndef TEMP_FULL_H
-#define TEMP_FULL_H
-
-#include "temperature.h"
-
-class TempFull : public Temperature {
- public:
-  TempFull(int, char **);
-  ~TempFull() {}
-  void init();
-  double compute();
-  void tensor();
-
- private:
-  void recount();
-};
-
-#endif
diff --git a/src/temp_partial.cpp b/src/temp_partial.cpp
deleted file mode 100644
index 219880642c5259ba2a02ff31364b5e8640d9d319..0000000000000000000000000000000000000000
--- a/src/temp_partial.cpp
+++ /dev/null
@@ -1,114 +0,0 @@
-/* ----------------------------------------------------------------------
-   LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
-
-   Copyright (2003) Sandia Corporation.  Under the terms of Contract
-   DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
-   certain rights in this software.  This software is distributed under 
-   the GNU General Public License.
-
-   See the README file in the top-level LAMMPS directory.
-------------------------------------------------------------------------- */
-
-#include "mpi.h"
-#include "stdlib.h"
-#include "temp_partial.h"
-#include "atom.h"
-#include "force.h"
-#include "group.h"
-#include "error.h"
-
-/* ---------------------------------------------------------------------- */
-
-TempPartial::TempPartial(int narg, char **arg) : Temperature(narg, arg)
-{
-  options(narg-6,&arg[6]);
-
-  xflag = atoi(arg[3]);
-  yflag = atoi(arg[4]);
-  zflag = atoi(arg[5]);
-}
-
-/* ---------------------------------------------------------------------- */
-
-void TempPartial::init()
-{
-  count_fix();
-  recount();
-}
-
-/* ---------------------------------------------------------------------- */
-
-void TempPartial::recount()
-{
-  double natoms = group->count(igroup);
-  dof = (xflag+yflag+zflag) * natoms;
-  dof -= extra_dof + fix_dof;
-  if (dof > 0) tfactor = force->mvv2e / (dof * force->boltz);
-  else tfactor = 0.0;
-}
-
-/* ---------------------------------------------------------------------- */
-
-double TempPartial::compute()
-{
-  double **v = atom->v;
-  double *mass = atom->mass;
-  double *rmass = atom->rmass;
-  int *type = atom->type;
-  int *mask = atom->mask;
-  int nlocal = atom->nlocal;
-
-  double t = 0.0;
-
-  if (atom->mass_require) {
-    for (int i = 0; i < nlocal; i++)
-      if (mask[i] & groupbit)
-	t += (xflag*v[i][0]*v[i][0] + yflag*v[i][1]*v[i][1] + 
-	      zflag*v[i][2]*v[i][2]) * mass[type[i]];
-  } else {
-    for (int i = 0; i < nlocal; i++)
-      if (mask[i] & groupbit)
-	t += (xflag*v[i][0]*v[i][0] + yflag*v[i][1]*v[i][1] + 
-	      zflag*v[i][2]*v[i][2]) * rmass[i];
-  }
-    
-  MPI_Allreduce(&t,&t_total,1,MPI_DOUBLE,MPI_SUM,world);
-  if (dynamic) recount();
-  t_total *= tfactor;
-  return t_total;
-}
-
-/* ---------------------------------------------------------------------- */
-
-void TempPartial::tensor()
-{
-  int i;
-
-  double **v = atom->v;
-  double *mass = atom->mass;
-  double *rmass = atom->rmass;
-  int *type = atom->type;
-  int *mask = atom->mask;
-  int nlocal = atom->nlocal;
-  int mass_require = atom->mass_require;
-
-  double massone,t[6];
-  for (i = 0; i < 6; i++) t[i] = 0.0;
-
-  for (i = 0; i < nlocal; i++)
-    if (mask[i] & groupbit) {
-      if (mass_require) massone = mass[type[i]];
-      else massone = rmass[i];
-      t[0] += massone * xflag*v[i][0]*v[i][0];
-      t[1] += massone * yflag*v[i][1]*v[i][1];
-      t[2] += massone * zflag*v[i][2]*v[i][2];
-      t[3] += massone * xflag*yflag*v[i][0]*v[i][1];
-      t[4] += massone * xflag*zflag*v[i][0]*v[i][2];
-      t[5] += massone * yflag*zflag*v[i][1]*v[i][2];
-    }
-
-  MPI_Allreduce(&t,&ke_tensor,6,MPI_DOUBLE,MPI_SUM,world);
-  for (i = 0; i < 6; i++) ke_tensor[i] *= force->mvv2e;
-}
diff --git a/src/temp_partial.h b/src/temp_partial.h
deleted file mode 100644
index 3d834f4bfe3f7e55bf09e79447c317c9e5f23a3e..0000000000000000000000000000000000000000
--- a/src/temp_partial.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/* ----------------------------------------------------------------------
-   LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
-
-   Copyright (2003) Sandia Corporation.  Under the terms of Contract
-   DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
-   certain rights in this software.  This software is distributed under 
-   the GNU General Public License.
-
-   See the README file in the top-level LAMMPS directory.
-------------------------------------------------------------------------- */
-
-#ifndef TEMP_PARTIAL_H
-#define TEMP_PARTIAL_H
-
-#include "temperature.h"
-
-class TempPartial : public Temperature {
- public:
-  TempPartial(int, char **);
-  ~TempPartial() {}
-  void init();
-  double compute();
-  void tensor();
-
- private:
-  int xflag,yflag,zflag;
-
-  void recount();
-};
-
-#endif
diff --git a/src/temp_ramp.cpp b/src/temp_ramp.cpp
deleted file mode 100644
index d544bb3d587828493925ee547f24b80b1a6d5155..0000000000000000000000000000000000000000
--- a/src/temp_ramp.cpp
+++ /dev/null
@@ -1,165 +0,0 @@
-/* ----------------------------------------------------------------------
-   LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
-
-   Copyright (2003) Sandia Corporation.  Under the terms of Contract
-   DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
-   certain rights in this software.  This software is distributed under 
-   the GNU General Public License.
-
-   See the README file in the top-level LAMMPS directory.
-------------------------------------------------------------------------- */
-
-#include "mpi.h"
-#include "stdlib.h"
-#include "string.h"
-#include "temp_ramp.h"
-#include "atom.h"
-#include "force.h"
-#include "group.h"
-#include "error.h"
-
-#define MIN(A,B) ((A) < (B)) ? (A) : (B)
-#define MAX(A,B) ((A) > (B)) ? (A) : (B)
-
-/* ---------------------------------------------------------------------- */
-
-TempRamp::TempRamp(int narg, char **arg) : Temperature(narg, arg)
-{
-  options(narg-9,&arg[9]);
-
-  if (strcmp(arg[3],"vx") == 0) v_dim = 0;
-  else if (strcmp(arg[3],"vy") == 0) v_dim = 1;
-  else if (strcmp(arg[3],"vz") == 0) v_dim = 2;
-  else error->all("Illegal temperature ramp command");
-
-  if (v_dim == 0) {
-    v_lo = xscale*atof(arg[4]);
-    v_hi = xscale*atof(arg[5]);
-  } else if (v_dim == 1) {
-    v_lo = yscale*atof(arg[4]);
-    v_hi = yscale*atof(arg[5]);
-  } else if (v_dim == 0) {
-    v_lo = zscale*atof(arg[4]);
-    v_hi = zscale*atof(arg[5]);
-  }
-
-  if (strcmp(arg[6],"x") == 0) coord_dim = 0;
-  else if (strcmp(arg[6],"y") == 0) coord_dim = 1;
-  else if (strcmp(arg[6],"z") == 0) coord_dim = 2;
-  else error->all("Illegal temperature ramp command");
-
-  if (coord_dim == 0) {
-    coord_lo = xscale*atof(arg[7]);
-    coord_hi = xscale*atof(arg[8]);
-  } else if (coord_dim == 1) {
-    coord_lo = yscale*atof(arg[7]);
-    coord_hi = yscale*atof(arg[8]);
-  } else if (coord_dim == 2) {
-    coord_lo = zscale*atof(arg[7]);
-    coord_hi = zscale*atof(arg[8]);
-  }
-}
-
-/* ---------------------------------------------------------------------- */
-
-void TempRamp::init()
-{
-  count_fix();
-  recount();
-}
-
-/* ---------------------------------------------------------------------- */
-
-void TempRamp::recount()
-{
-  double natoms = group->count(igroup);
-  dof = force->dimension * natoms;
-  dof -= extra_dof + fix_dof;
-  if (dof > 0) tfactor = force->mvv2e / (dof * force->boltz);
-  else tfactor = 0.0;
-}
-
-/* ---------------------------------------------------------------------- */
-
-double TempRamp::compute()
-{
-  double fraction,vramp,vtmp[3];
-
-  double **x = atom->x;
-  double **v = atom->v;
-  double *mass = atom->mass;
-  double *rmass = atom->rmass;
-  int *type = atom->type;
-  int *mask = atom->mask;
-  int nlocal = atom->nlocal;
-  int mass_require = atom->mass_require;
-
-  double t = 0.0;
-  for (int i = 0; i < nlocal; i++)
-    if (mask[i] & groupbit) {
-      fraction = (x[i][coord_dim] - coord_lo) / (coord_hi - coord_lo);
-      fraction = MAX(fraction,0.0);
-      fraction = MIN(fraction,1.0);
-      vramp = v_lo + fraction*(v_hi - v_lo);
-      vtmp[0] = v[i][0];
-      vtmp[1] = v[i][1];
-      vtmp[2] = v[i][2];
-      vtmp[v_dim] -= vramp;
-      if (mass_require)
-	t += (vtmp[0]*vtmp[0] + vtmp[1]*vtmp[1] + vtmp[2]*vtmp[2]) * 
-	  mass[type[i]];
-      else
-	t += (vtmp[0]*vtmp[0] + vtmp[1]*vtmp[1] + vtmp[2]*vtmp[2]) * rmass[i];
-    }
-
-  MPI_Allreduce(&t,&t_total,1,MPI_DOUBLE,MPI_SUM,world);
-  if (dynamic) recount();
-  t_total *= tfactor;
-  return t_total;
-}
-
-/* ---------------------------------------------------------------------- */
-
-void TempRamp::tensor()
-{
-  int i;
-  double fraction,vramp,vtmp[3];
-
-  double **x = atom->x;
-  double **v = atom->v;
-  double *mass = atom->mass;
-  double *rmass = atom->rmass;
-  int *type = atom->type;
-  int *mask = atom->mask;
-  int nlocal = atom->nlocal;
-  int mass_require = atom->mass_require;
-
-  double massone,t[6];
-  for (i = 0; i < 6; i++) t[i] = 0.0;
-
-  for (i = 0; i < nlocal; i++)
-    if (mask[i] & groupbit) {
-      fraction = (x[i][coord_dim] - coord_lo) / (coord_hi - coord_lo);
-      fraction = MAX(fraction,0.0);
-      fraction = MIN(fraction,1.0);
-      vramp = v_lo + fraction*(v_hi - v_lo);
-      vtmp[0] = v[i][0];
-      vtmp[1] = v[i][1];
-      vtmp[2] = v[i][2];
-      vtmp[v_dim] -= vramp;
-
-      if (mass_require) massone = mass[type[i]];
-      else massone = rmass[i];
-      t[0] += massone * vtmp[0]*vtmp[0];
-      t[1] += massone * vtmp[1]*vtmp[1];
-      t[2] += massone * vtmp[2]*vtmp[2];
-      t[3] += massone * vtmp[0]*vtmp[1];
-      t[4] += massone * vtmp[0]*vtmp[2];
-      t[5] += massone * vtmp[1]*vtmp[2];
-    }
-
-  MPI_Allreduce(&t,&ke_tensor,6,MPI_DOUBLE,MPI_SUM,world);
-  for (i = 0; i < 6; i++) ke_tensor[i] *= force->mvv2e;
-}
diff --git a/src/temp_ramp.h b/src/temp_ramp.h
deleted file mode 100644
index ab8674d20deb906087dde04e25fa9002678c6f20..0000000000000000000000000000000000000000
--- a/src/temp_ramp.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/* ----------------------------------------------------------------------
-   LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
-
-   Copyright (2003) Sandia Corporation.  Under the terms of Contract
-   DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
-   certain rights in this software.  This software is distributed under 
-   the GNU General Public License.
-
-   See the README file in the top-level LAMMPS directory.
-------------------------------------------------------------------------- */
-
-#ifndef TEMP_RAMP_H
-#define TEMP_RAMP_H
-
-#include "temperature.h"
-
-class TempRamp : public Temperature {
- public:
-  TempRamp(int, char **);
-  ~TempRamp() {}
-  void init();
-  double compute();
-  void tensor();
-
- private:
-  int coord_dim;
-  double coord_lo,coord_hi;
-  int v_dim;
-  double v_lo,v_hi;
-
-  void recount();
-};
-
-#endif
diff --git a/src/temp_region.cpp b/src/temp_region.cpp
deleted file mode 100644
index 15766e45f3a9c95d94e4c293c13a554507194a63..0000000000000000000000000000000000000000
--- a/src/temp_region.cpp
+++ /dev/null
@@ -1,117 +0,0 @@
-/* ----------------------------------------------------------------------
-   LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
-
-   Copyright (2003) Sandia Corporation.  Under the terms of Contract
-   DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
-   certain rights in this software.  This software is distributed under 
-   the GNU General Public License.
-
-   See the README file in the top-level LAMMPS directory.
-------------------------------------------------------------------------- */
-
-#include "mpi.h"
-#include "string.h"
-#include "temp_region.h"
-#include "atom.h"
-#include "force.h"
-#include "domain.h"
-#include "region.h"
-#include "error.h"
-
-/* ---------------------------------------------------------------------- */
-
-TempRegion::TempRegion(int narg, char **arg) : Temperature(narg, arg)
-{
-  options(narg-4,&arg[4]);
-
-  for (iregion = 0; iregion < domain->nregion; iregion++)
-    if (strcmp(arg[3],domain->regions[iregion]->id) == 0) break;
-  if (iregion == domain->nregion)
-    error->all("Temperature region ID does not exist");
-}
-
-/* ---------------------------------------------------------------------- */
-
-void TempRegion::init()
-{
-  dof = 0;
-}
-
-/* ---------------------------------------------------------------------- */
-
-double TempRegion::compute()
-{
-  double **x = atom->x;
-  double **v = atom->v;
-  double *mass = atom->mass;
-  double *rmass = atom->rmass;
-  int *type = atom->type;
-  int *mask = atom->mask;
-  int nlocal = atom->nlocal;
-
-  int count = 0;
-  double t = 0.0;
-
-  if (atom->mass_require) {
-    for (int i = 0; i < nlocal; i++)
-      if (mask[i] & groupbit &&
-	  domain->regions[iregion]->match(x[i][0],x[i][1],x[i][2])) {
-	count++;
-	t += (v[i][0]*v[i][0] + v[i][1]*v[i][1] + v[i][2]*v[i][2]) * 
-	  mass[type[i]];
-      }
-  } else {
-    for (int i = 0; i < nlocal; i++)
-      if (mask[i] & groupbit &&
-	  domain->regions[iregion]->match(x[i][0],x[i][1],x[i][2])) {
-	count++;
-	t += (v[i][0]*v[i][0] + v[i][1]*v[i][1] + v[i][2]*v[i][2]) * rmass[i];
-      }
-  }
-  
-  double tarray[2],tarray_all[2];
-  tarray[0] = count;
-  tarray[1] = t;
-  MPI_Allreduce(tarray,tarray_all,2,MPI_DOUBLE,MPI_SUM,world);
-  dof = force->dimension * tarray_all[0] - extra_dof;
-  if (dof > 0) t_total = force->mvv2e * tarray_all[1] / (dof * force->boltz);
-  else t_total = 0.0;
-  return t_total;
-}
-
-/* ---------------------------------------------------------------------- */
-
-void TempRegion::tensor()
-{
-  int i;
-
-  double **x = atom->x;
-  double **v = atom->v;
-  double *mass = atom->mass;
-  double *rmass = atom->rmass;
-  int *type = atom->type;
-  int *mask = atom->mask;
-  int nlocal = atom->nlocal;
-  int mass_require = atom->mass_require;
-
-  double massone,t[6];
-  for (i = 0; i < 6; i++) t[i] = 0.0;
-
-  for (i = 0; i < nlocal; i++)
-    if (mask[i] & groupbit && 
-	domain->regions[iregion]->match(x[i][0],x[i][1],x[i][2])) {
-      if (mass_require) massone = mass[type[i]];
-      else massone = rmass[i];
-      t[0] += massone * v[i][0]*v[i][0];
-      t[1] += massone * v[i][1]*v[i][1];
-      t[2] += massone * v[i][2]*v[i][2];
-      t[3] += massone * v[i][0]*v[i][1];
-      t[4] += massone * v[i][0]*v[i][2];
-      t[5] += massone * v[i][1]*v[i][2];
-    }
-
-  MPI_Allreduce(&t,&ke_tensor,6,MPI_DOUBLE,MPI_SUM,world);
-  for (i = 0; i < 6; i++) ke_tensor[i] *= force->mvv2e;
-}
diff --git a/src/temp_region.h b/src/temp_region.h
deleted file mode 100644
index 387618db27bf6fdf8cfd6dce41d310c90101c327..0000000000000000000000000000000000000000
--- a/src/temp_region.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/* ----------------------------------------------------------------------
-   LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
-
-   Copyright (2003) Sandia Corporation.  Under the terms of Contract
-   DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
-   certain rights in this software.  This software is distributed under 
-   the GNU General Public License.
-
-   See the README file in the top-level LAMMPS directory.
-------------------------------------------------------------------------- */
-
-#ifndef TEMP_REGION_H
-#define TEMP_REGION_H
-
-#include "temperature.h"
-
-class TempRegion : public Temperature {
- public:
-  TempRegion(int, char **);
-  ~TempRegion() {}
-  void init();
-  double compute();
-  void tensor();
-
- private:
-  int iregion;
-};
-
-#endif
diff --git a/src/temper.cpp b/src/temper.cpp
index 889e13c5eeae2342e60c62450b5e512235072007..9115a86927a18a764e948c14a5ff81edf97e612a 100644
--- a/src/temper.cpp
+++ b/src/temper.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -19,7 +19,6 @@
 #include "stdlib.h"
 #include "string.h"
 #include "temper.h"
-#include "system.h"
 #include "universe.h"
 #include "domain.h"
 #include "update.h"
@@ -37,13 +36,16 @@
 #include "memory.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define NVT      1
 #define LANGEVIN 2
 // #define TEMPER_DEBUG 1
+/* ---------------------------------------------------------------------- */
 
-/* ----------------------------------------------------------------------
-   free all tempering memory
-------------------------------------------------------------------------- */
+Temper::Temper(LAMMPS *lmp) : Pointers(lmp) {}
+
+/* ---------------------------------------------------------------------- */
 
 Temper::~Temper()
 {
@@ -71,13 +73,11 @@ void Temper::command(int narg, char **arg)
     error->all("Temper command before simulation box is defined");
 
   update->nsteps = atoi(arg[0]);
-
   update->beginstep = update->firststep = update->ntimestep;
   update->endstep = update->laststep = update->firststep + update->nsteps;
-
   update->whichflag = 0;
 
-  sys->init();
+  lmp->init();
   
   // grab temper command args
 
@@ -136,9 +136,9 @@ void Temper::command(int narg, char **arg)
   // RNGs for swaps and Boltzmann test
   // warm up Boltzmann RNG
 
-  if (seed_swap) ranswap = new RanPark(seed_swap);
+  if (seed_swap) ranswap = new RanPark(lmp,seed_swap);
   else ranswap = NULL;
-  ranboltz = new RanPark(seed_boltz + me_universe);
+  ranboltz = new RanPark(lmp,seed_boltz + me_universe);
   for (int i = 0; i < 100; i++) ranboltz->uniform();
 
   // world2root[i] = global proc that is root proc of world i
@@ -296,7 +296,7 @@ void Temper::command(int narg, char **arg)
 
   timer->barrier_stop(TIME_LOOP);
 
-  Finish finish;
+  Finish finish(lmp);
   finish.end(1);
   update->whichflag = -1;
 }
diff --git a/src/temper.h b/src/temper.h
index 025b143091980ecc5a1685c6b0c1418b1c481ff0..bf717e13d425778398590c912506616371219781 100644
--- a/src/temper.h
+++ b/src/temper.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -14,13 +14,13 @@
 #ifndef TEMPER_H
 #define TEMPER_H
 
-#include "lammps.h"
+#include "pointers.h"
 
-class RanPark;
+namespace LAMMPS_NS {
 
-class Temper : public LAMMPS {
+class Temper : protected Pointers {
  public:
-  Temper() {}
+  Temper(class LAMMPS *);
   ~Temper();
   void command(int, char **);
 
@@ -29,7 +29,7 @@ class Temper : public LAMMPS {
   int iworld,nworlds;          // world info
   double boltz;                // copy from output->boltz
   MPI_Comm roots;              // Comm with 1 root proc from each world
-  RanPark *ranswap,*ranboltz;  // RNGs for swapping and Boltz factor
+  class RanPark *ranswap,*ranboltz;  // RNGs for swapping and Boltz factor
   int nevery;                  // # of timesteps between swaps
   int nswaps;                  // # of tempering swaps to perform
   int seed_swap;               // 0 = toggle swaps, n = RNG for swap direction
@@ -46,4 +46,6 @@ class Temper : public LAMMPS {
   void print_status();
 };
 
+}
+
 #endif
diff --git a/src/temperature.cpp b/src/temperature.cpp
deleted file mode 100644
index 8af6a24d64cd4858ad20b9cb4a8df5899c350dee..0000000000000000000000000000000000000000
--- a/src/temperature.cpp
+++ /dev/null
@@ -1,129 +0,0 @@
-/* ----------------------------------------------------------------------
-   LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
-
-   Copyright (2003) Sandia Corporation.  Under the terms of Contract
-   DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
-   certain rights in this software.  This software is distributed under 
-   the GNU General Public License.
-
-   See the README file in the top-level LAMMPS directory.
-------------------------------------------------------------------------- */
-
-#include "mpi.h"
-#include "stdlib.h"
-#include "string.h"
-#include "temperature.h"
-#include "atom.h"
-#include "group.h"
-#include "modify.h"
-#include "domain.h"
-#include "lattice.h"
-#include "fix.h"
-#include "error.h"
-
-/* ---------------------------------------------------------------------- */
-
-Temperature::Temperature(int narg, char **arg)
-{
-  if (narg < 3) error->all("Illegal temperature command");
-
-  // temperature ID, group, and style
-
-  int n = strlen(arg[0]) + 1;
-  id = new char[n];
-  strcpy(id,arg[0]);
-
-  igroup = group->find(arg[1]);
-  groupbit = group->bitmask[igroup];
-
-  n = strlen(arg[2]) + 1;
-  style = new char[n];
-  strcpy(style,arg[2]);
-
-  // set modify defaults
-
-  extra_dof = 3;
-  dynamic = 0;
-}
-
-/* ---------------------------------------------------------------------- */
-
-Temperature::~Temperature()
-{
-  delete [] id;
-  delete [] style;
-}
-
-/* ---------------------------------------------------------------------- */
-
-void Temperature::modify_params(int narg, char **arg)
-{
-  if (narg == 0) error->all("Illegal temp_modify command");
-
-  int iarg = 0;
-  while (iarg < narg) {
-    if (strcmp(arg[iarg],"extra") == 0) {
-      if (iarg+2 > narg) error->all("Illegal temp_modify command");
-      extra_dof = atoi(arg[iarg+1]);
-      iarg += 2;
-    } else if (strcmp(arg[iarg],"dynamic") == 0) {
-      if (iarg+2 > narg) error->all("Illegal temp_modify command");
-      if (strcmp(arg[iarg+1],"no") == 0) dynamic = 0;
-      else if (strcmp(arg[iarg+1],"yes") == 0) dynamic = 1;
-      else error->all("Illegal temp_modify command");
-      iarg += 2;
-    } else error->all("Illegal temp_modify command");
-  }
-}
-
-/* ----------------------------------------------------------------------
-   count degrees of freedom subtracted by fixes
-------------------------------------------------------------------------- */
-
-void Temperature::count_fix()
-{
-  fix_dof = 0;
-  for (int i = 0; i < modify->nfix; i++)
-    fix_dof += modify->fix[i]->dof(igroup);
-}
-
-/* ----------------------------------------------------------------------
-   parse optional parameters at end of temperature input line 
-------------------------------------------------------------------------- */
-
-void Temperature::options(int narg, char **arg)
-{
-  if (narg < 0) error->all("Illegal temperature command");
-
-  // option defaults
-
-  scaleflag = 1;
-
-  int iarg = 0;
-  while (iarg < narg) {
-    if (strcmp(arg[iarg],"units") == 0) {
-      if (iarg+2 > narg) error->all("Illegal temperature command");
-      if (strcmp(arg[iarg+1],"box") == 0) scaleflag = 0;
-      else if (strcmp(arg[iarg+1],"lattice") == 0) scaleflag = 1;
-      else error->all("Illegal temperature command");
-      iarg += 2;
-    } else error->all("Illegal temperature command");
-  }
-
-  // set scaling for RAMP style
-
-  if (strcmp(style,"ramp") == 0) {
-
-    if (scaleflag && domain->lattice == NULL)
-      error->all("Use of temperature ramp with undefined lattice");
-
-    if (scaleflag) {
-      xscale = domain->lattice->xlattice;
-      yscale = domain->lattice->ylattice;
-      zscale = domain->lattice->zlattice;
-    }
-    else xscale = yscale = zscale = 1.0;
-  }
-}
diff --git a/src/temperature.h b/src/temperature.h
deleted file mode 100644
index 396ee40cc45f51b54900f2ab9688dc3f79798a70..0000000000000000000000000000000000000000
--- a/src/temperature.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/* ----------------------------------------------------------------------
-   LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
-
-   Copyright (2003) Sandia Corporation.  Under the terms of Contract
-   DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
-   certain rights in this software.  This software is distributed under 
-   the GNU General Public License.
-
-   See the README file in the top-level LAMMPS directory.
-------------------------------------------------------------------------- */
-
-#ifndef TEMPERATURE_H
-#define TEMPERATURE_H
-
-#include "lammps.h"
-
-class Temperature : public LAMMPS {
- public:
-  char *id,*style;
-  int igroup,groupbit;
-  double t_total,dof;
-  double ke_tensor[6];
-
-  Temperature(int, char **);
-  virtual ~Temperature();
-  void modify_params(int, char **);
-  void count_fix();
-  virtual void init() = 0;
-  virtual double compute() = 0;
-  virtual void tensor() = 0;
-
- protected:
-  double tfactor;
-  int extra_dof,fix_dof;
-  int scaleflag,dynamic;
-  double xscale,yscale,zscale;
-
-  void options(int, char **);
-};
-
-#endif
diff --git a/src/thermo.cpp b/src/thermo.cpp
index 2791b30da2a26c42598751fef9027810d137cf92..ca502c79e8bb71e8cec5a38aca6f96918617f266 100644
--- a/src/thermo.cpp
+++ b/src/thermo.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -15,56 +15,53 @@
 #include "stdlib.h"
 #include "string.h"
 #include "thermo.h"
-#include "force.h"
-#include "temperature.h"
-#include "pressure.h"
+#include "atom.h"
+#include "comm.h"
+#include "domain.h"
 #include "update.h"
 #include "modify.h"
+#include "fix.h"
+#include "compute.h"
+#include "input.h"
+#include "variable.h"
 #include "force.h"
 #include "pair.h"
-//#include "pair_dipole_cut.h"
-//#include "pair_dipole_long.h"
 #include "bond.h"
 #include "angle.h"
 #include "dihedral.h"
 #include "improper.h"
 #include "kspace.h"
-#include "fix.h"
-#include "comm.h"
-#include "atom.h"
-#include "domain.h"
 #include "timer.h"
 #include "memory.h"
 #include "error.h"
 
-// customize by adding a keyword to this list:
+using namespace LAMMPS_NS;
+
+// customize a new keyword by adding to this list:
 
 // step, atoms, cpu, temp, press, pe, ke, etotal, enthalpy
-// evdwl, ecoul, epair, ebond, eangle, edihed, eimp, emol, elong, etail, erot
+// evdwl, ecoul, epair, ebond, eangle, edihed, eimp, emol, elong, etail
 // vol, lx, ly, lz, pxx, pyy, pzz, pxy, pxz, pyz
-// gke, grot (granular trans-ke and rotational-ke)
+// drot, grot (rotational KE for dipole and granular particles)
 // tave, pave, eave, peave (time-averaged quantities)
-// t_ID (user-defined temperatures)
 
-// customize by adding a DEFINE to this list
+// customize a new thermo style by adding a DEFINE to this list
 
 #define ONE "step temp epair emol etotal press"
 #define MULTI "etotal ke temp pe ebond eangle edihed eimp evdwl ecoul elong press"
-#define GRANULAR "step atoms gke grot"
-#define DIPOLE "step temp epair erot etotal press"
+#define GRANULAR "step atoms ke grot"
+#define DIPOLE "step temp epair drot etotal press"
 
-enum {IGNORE,WARN,ERROR};           // same as write_restart.cpp
-enum {ONELINE,MULTILINE};
-enum {INT,FLOAT};
-enum {NEITHER,PRINT,ENERGY,BOTH};   // same as modify.cpp
+enum{IGNORE,WARN,ERROR};           // same as write_restart.cpp
+enum{ONELINE,MULTILINE};
+enum{INT,FLOAT};
 
 #define MAXLINE 1024
-#define INERTIA3D 0.4               // moments of inertia for sphere and disk
-#define INERTIA2D 0.5
+#define DELTA   8
 
 /* ---------------------------------------------------------------------- */
 
-Thermo::Thermo(int narg, char **arg)
+Thermo::Thermo(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp)
 {
   MPI_Comm_rank(world,&me);
 
@@ -72,6 +69,8 @@ Thermo::Thermo(int narg, char **arg)
   style = new char[n];
   strcpy(style,arg[0]);
 
+  thermoflag = 1;
+
   // set thermo_modify defaults
 
   normuserflag = 0;
@@ -83,11 +82,9 @@ Thermo::Thermo(int narg, char **arg)
   ncurrent_t = ncurrent_p = ncurrent_e = ncurrent_pe = -1;
   npartial_t = npartial_p = npartial_e = npartial_pe = 0;
 
-  // initialize ptrs
-
   // set style and corresponding lineflag
   // custom style builds its own line of keywords
-  // customize a new DEFINE style by adding to if statement
+  // customize a new thermo style by adding to if statement
 
   line = new char[MAXLINE];
 
@@ -100,6 +97,7 @@ Thermo::Thermo(int narg, char **arg)
     strcpy(line,GRANULAR);
   } else if (strcmp(style,"dipole") == 0) {
     strcpy(line,DIPOLE);
+
   } else if (strcmp(style,"custom") == 0) {
     if (narg == 1) error->all("Illegal thermo style custom command");
     line[0] = '\0';
@@ -108,53 +106,61 @@ Thermo::Thermo(int narg, char **arg)
       strcat(line," ");
     }
     line[strlen(line)-1] = '\0';
-  } else error->all("Illegal thermo style command");
 
-  // process line of keywords
+  } else error->all("Illegal thermo style command");
 
-  nfield = ntemp = nfix = 0;
-  tempindices = NULL;
-  parse_fields(line);
-  nfield_initial = nfield;
+  // ptrs, flags, IDs for compute objects thermo may create
 
-  // format strings
+  temperature = NULL;
+  pressure = NULL;
+  rotate_dipole = NULL;
+  rotate_gran = NULL;
 
-  char *str = "%8d";
-  n = strlen(str) + 1;
-  format_int_def = new char[n];
-  strcpy(format_int_def,str);
+  index_temp = index_press = index_drot = index_grot = -1;
+  internal_temp = internal_press = internal_drot = internal_grot = 0;
 
-  str = "%12.8g";
-  n = strlen(str) + 1;
-  format_g_def = new char[n];
-  strcpy(format_g_def,str);
+  id_temp = "thermo_temp";
+  id_press = "thermo_press";
+  id_drot = "thermo_rotate_dipole";
+  id_grot = "thermo_rotate_gran";
 
-  str = "%14.4f";
-  n = strlen(str) + 1;
-  format_f_def = new char[n];
-  strcpy(format_f_def,str);
-
-  str = "---------------- Step %8d ----- CPU = %11.4f (sec) ----------------";
-  n = strlen(str) + 1;
-  format_multi = new char[n];
-  strcpy(format_multi,str);
+  // count fields in line
+  // allocate per-field memory
+  // process line of keywords
 
-  format_iflag = 0;
-  format_fflag = 0;
-  format_int_user = NULL;
-  format_float_user = NULL;
+  nfield_initial = atom->count_words(line);
+  allocate();
+  parse_fields(line);
 
-  nformat = 0;
-  format_user = NULL;
-  format_index = NULL;
+  // create the requested compute styles
 
-  format = NULL;
+  if (index_temp >= 0) {
+    create_compute(id_temp,"temp",NULL);
+    internal_temp = 1;
+  }
+  if (index_press >= 0) {
+    create_compute(id_press,"pressure",id_temp);
+    internal_press = 1;
+  }
+  if (index_drot >= 0) {
+    create_compute(id_drot,"rotate/dipole",NULL);
+    internal_drot = 1;
+  }
+  if (index_grot >= 0) {
+    create_compute(id_grot,"rotate/gran",NULL);
+    internal_grot = 1;
+  }
 
-  // ptrs for T,P computation
-  // temperature is default in force->templist
+  // format strings
 
-  temperature = force->templist[0];
-  pressure = force->pressure;
+  format_multi = "---------------- Step %8d ----- "
+                 "CPU = %11.4f (sec) ----------------";
+  format_int_one_def = "%8d";
+  format_int_multi_def = "%14d";
+  format_g_def = "%12.8g";
+  format_f_def = "%14.4f";
+  format_int_user = NULL;
+  format_float_user = NULL;
 
   // average quantities
 
@@ -163,8 +169,6 @@ Thermo::Thermo(int narg, char **arg)
   ppast = new double[nwindow];
   epast = new double[nwindow];
   pepast = new double[nwindow];
-
-  inertia = NULL;
 }
 
 /* ---------------------------------------------------------------------- */
@@ -174,64 +178,37 @@ Thermo::~Thermo()
   delete [] style;
   delete [] line;
 
-  if (keyword) {
-    for (int i = 0; i < nfield; i++) delete [] keyword[i];
-    memory->sfree(keyword);
-    memory->sfree(vfunc);
-    memory->sfree(vtype);
-  }
+  // delete Compute classes if thermo created them
 
-  delete [] format_int_def;
-  delete [] format_g_def;
-  delete [] format_f_def;
-  delete [] format_multi;
-  if (format_iflag) delete [] format_int_user;
-  if (format_fflag) delete [] format_float_user;
-
-  if (nformat) {
-    for (int i = 0; i < nformat; i++) delete [] format_user[i];
-    memory->sfree(format_user);
-    memory->sfree(format_index);
-  }
+  if (index_temp >= 0 && internal_temp)
+    modify->delete_compute(id_compute[index_temp]);
+  if (index_press >= 0 && internal_press)
+    modify->delete_compute(id_compute[index_press]);
+  if (index_drot >= 0 && internal_drot)
+    modify->delete_compute(id_compute[index_drot]);
+  if (index_grot >= 0 && internal_grot)
+    modify->delete_compute(id_compute[index_grot]);
 
-  if (format) {
-    for (int i = 0; i < nfield; i++) delete [] format[i];
-    delete [] format;
-  }
+  deallocate();
+
+  // format strings
 
-  if (tempindices) memory->sfree(tempindices);
+  delete [] format_int_user;
+  delete [] format_float_user;
 
-  if (nfix) {
-    delete [] fixflags;
-    delete [] fixprint;
-    delete [] fixenergy;
-    delete [] fixvalues;
-  }
+  // average arrays
 
   delete [] tpast;
   delete [] ppast;
   delete [] epast;
   delete [] pepast;
-
-  delete [] inertia;
 }
 
 /* ---------------------------------------------------------------------- */
 
 void Thermo::init()
 {
-  int i,j,n;
-
-  // error checks
-  // mass/rmass for granular and non-granular styles
-  // dipole/omega for erot
-
-  if (granflag && atom->check_style("granular") == 0)
-    error->all("Must use atom style granular with chosen thermo settings");
-  if ((tempflag || pressflag) && atom->check_style("granular"))
-    error->all("Cannot use atom style granular with chosen thermo settings");
-  if (dipoleflag && atom->check_style("dipole") == 0)
-    error->all("Must use atom style dipole with chosen thermo settings");
+  int i,n;
 
   // set normvalue to default setting unless user has specified it
 
@@ -240,115 +217,30 @@ void Thermo::init()
   else if (strcmp(update->unit_style,"lj") == 0) normvalue = 1;
   else normvalue = 0;
 
-  // check for granular freeze Fix and set freeze_group_bit
-
-  for (i = 0; i < modify->nfix; i++)
-    if (strcmp(modify->fix[i]->style,"freeze") == 0) break;
-  if (i < modify->nfix) freeze_group_bit = modify->fix[i]->groupbit;
-  else freeze_group_bit = 0;
-
-  // setup moments of inertia if dipoleflag is set
-  // extract sigma as particle size to compute moment of inertia
-
-  if (dipoleflag) {
-    delete [] inertia;
-    inertia = new double[atom->ntypes+1];
-    double *mass = atom->mass;
-
-    Pair *anypair;
-    double **sigma;
-    /*
-    if (anypair = force->pair_match("dipole/cut"))
-      sigma = ((PairDipoleCut *) anypair)->sigma;
-    else if (anypair = force->pair_match("dipole/long"))
-      sigma = ((PairDipoleLong *) anypair)->sigma;
-    else error->all("Pair style is incompatible with thermo_style erot");
-    */
-
-    if (force->dimension == 3)
-      for (int i = 1; i <= atom->ntypes; i++)
-	inertia[i] = INERTIA3D * mass[i] * 0.25*sigma[i][i]*sigma[i][i];
-    else
-      for (int i = 1; i <= atom->ntypes; i++)
-	inertia[i] = INERTIA2D * mass[i] * 0.25*sigma[i][i]*sigma[i][i];
-  }
-
-  // clear all format strings
-  // clear extra keyword strings beyond nfield_initial
-
-  if (format) {
-    for (i = 0; i < nfield; i++) delete [] format[i];
-    delete [] format;
-  }
-  for (i = nfield_initial; i < nfield; i++) delete [] keyword[i];
-  nfield = nfield_initial;
-
-  // add a field if volume changes and not style = custom
+  // add Volume field if volume changes and not style = custom
   // this check must come after domain init, so box_change is set
 
+  nfield = nfield_initial;
   if (domain->box_change && strcmp(style,"custom") != 0)
     addfield("Volume",&Thermo::compute_vol,FLOAT);
-  
-  // add fields due to fixes
-  
-  if (nfix) {
-    delete [] fixflags;
-    delete [] fixprint;
-    delete [] fixenergy;
-    delete [] fixvalues;
-  }
-
-  nfix = nfix_energy = nfix_print = 0;
-  if (modify->n_thermo) nfix = modify->thermo_fields(0,NULL,NULL);
-  if (nfix) {
-    fixflags = new int[nfix];
-    fixprint = new int[nfix];
-    fixenergy = new int[nfix];
-    fixvalues = new double[nfix];
-    char **strings = new char*[nfix];
-    for (i = 0; i < nfix; i++) strings[i] = new char[9];
-
-    nfix = modify->thermo_fields(nfix,fixflags,strings);
-
-    for (i = 0; i < nfix; i++) {
-      if (fixflags[i] == PRINT || fixflags[i] == BOTH) {
-	fixprint[nfix_print++] = i;
-	addfield(strings[i],&Thermo::compute_fix,FLOAT);
-      }
-      if (fixflags[i] == ENERGY || fixflags[i] == BOTH)
-	fixenergy[nfix_energy++] = i;
-    }
-
-    for (i = 0; i < nfix; i++) delete [] strings[i];
-    delete [] strings;
-  }
 
-  // nextra = 1 if printing extra temperature or fix values
-
-  nextra = 0;
-  if (ntemp || nfix) nextra = 1;
-
-  // set format string for each printed value
+  // set format string for each field
   // include keyword if lineflag = MULTILINE
   // add '/n' every 3 values if lineflag = MULTILINE
   // add trailing '/n' to last value
 
-  format = new char*[nfield];
-  for (int i = 0; i < nfield; i++) format[i] = new char[32];
   char *ptr;
-
   for (i = 0; i < nfield; i++) {
     format[i][0] = '\0';
     if (lineflag == MULTILINE && i % 3 == 0) strcat(format[i],"\n");
 
-    for (j = nformat-1; j >= 0; j--)
-      if (format_index[j] == i+1) break;
-    if (j >= 0) ptr = format_user[j];
-    else if (vtype[i] == INT && format_iflag) ptr = format_int_user;
-    else if (vtype[i] == INT) ptr = format_int_def;
-    else if (vtype[i] == FLOAT && format_fflag) ptr = format_float_user;
+    if (format_user[i]) ptr = format_user[i];
+    else if (vtype[i] == INT && format_int_user) ptr = format_int_user;
+    else if (vtype[i] == INT && lineflag == ONELINE) ptr = format_int_one_def;
+    else if (vtype[i] == INT && lineflag == MULTILINE) ptr = format_int_multi_def;
+    else if (vtype[i] == FLOAT && format_float_user) ptr = format_float_user;
+    else if (lineflag == ONELINE) ptr = format_g_def;
     else if (lineflag == MULTILINE) ptr = format_f_def;
-    else ptr = format_g_def;
 
     n = strlen(format[i]);
     if (lineflag == ONELINE) sprintf(&format[i][n],"%s ",ptr);
@@ -356,6 +248,31 @@ void Thermo::init()
 
     if (i == nfield-1) strcat(format[i],"\n");
   }
+
+  // find current ptr for each Compute ID
+
+  int icompute;
+  for (i = 0; i < ncompute; i++) {
+    icompute = modify->find_compute(id_compute[i]);
+    if (icompute < 0) error->all("Could not find thermo custom compute ID");
+    computes[i] = modify->compute[icompute];
+  }
+
+  // find current ptr for each Fix ID
+
+  int ifix;
+  for (i = 0; i < nfix; i++) {
+    ifix = modify->find_fix(id_fix[i]);
+    if (ifix < 0) error->all("Could not find thermo custom fix ID");
+    fixes[i] = modify->fix[ifix];
+  }
+
+  // set ptrs to keyword-specific Compute objects
+
+  if (index_temp >= 0) temperature = computes[index_temp];
+  if (index_press >= 0) pressure = computes[index_press];
+  if (index_drot >= 0) rotate_dipole = computes[index_drot];
+  if (index_grot >= 0) rotate_gran = computes[index_grot];
 }
 
 /* ---------------------------------------------------------------------- */
@@ -379,21 +296,24 @@ void Thermo::header()
 
 void Thermo::compute(int flag)
 {
+  int i;
+  double tmp;
+
   firststep = flag;
 
   // check for lost atoms
   // turn off normflag if natoms = 0 to avoid divide by 0
-  // compute requested thermo quantities
 
   natoms = lost_check();
   if (natoms == 0) normflag = 0;
   else normflag = normvalue;
 
-  if (tempflag) tempvalue = temperature->compute();
-  if (pressflag) pressure->compute(temperature);
-  if (nextra) {
-    itemp_print = ifix_print = 0;
-    if (nfix) modify->thermo_compute(fixvalues);
+  // invoke Compute methods needed for thermo keywords
+  // call compute_scalar() if which = 0, else compute_vector()
+
+  for (i = 0; i < ncompute; i++) {
+    if (compute_which[i] % 2 == 0) tmp = computes[i]->compute_scalar();
+    if (compute_which[i] > 0) computes[i]->compute_vector();
   }
 
   // if lineflag = MULTILINE, prepend step/cpu header line
@@ -408,10 +328,10 @@ void Thermo::compute(int flag)
 
   // add each thermo value to line with its specific format
 
-  for (int i = 0; i < nfield; i++) {
-    (this->*vfunc[i])();
-    if (vtype[i] == INT) loc += sprintf(&line[loc],format[i],ivalue);
-    else loc += sprintf(&line[loc],format[i],dvalue);
+  for (ifield = 0; ifield < nfield; ifield++) {
+    (this->*vfunc[ifield])();
+    if (vtype[ifield] == INT) loc += sprintf(&line[loc],format[ifield],ivalue);
+    else loc += sprintf(&line[loc],format[ifield],dvalue);
   }
 
   // print line to screen and logfile
@@ -431,34 +351,34 @@ void Thermo::compute(int flag)
 
 double Thermo::lost_check()
 {
-  // natoms = current # of atoms
+  // ntotal = current # of atoms
 
-  double natoms;
+  double ntotal;
   double rlocal = atom->nlocal;
-  MPI_Allreduce(&rlocal,&natoms,1,MPI_DOUBLE,MPI_SUM,world);
-  if (natoms == atom->natoms) return natoms;
+  MPI_Allreduce(&rlocal,&ntotal,1,MPI_DOUBLE,MPI_SUM,world);
+  if (ntotal == atom->natoms) return ntotal;
 
   // if not checking or already warned, just return
 
-  if (lostflag == IGNORE) return natoms;
-  if (lostflag == WARN && lostbefore == 1) return natoms;
+  if (lostflag == IGNORE) return ntotal;
+  if (lostflag == WARN && lostbefore == 1) return ntotal;
 
   // error message
 
   if (lostflag == ERROR) {
     char str[128];
     sprintf(str,"Lost atoms: original %.15g current %.15g",
-	    atom->natoms,natoms);
+	    atom->natoms,ntotal);
     error->all(str);
   }
 
   // warning message
 
   char str[128];
-  sprintf(str,"Lost atoms: original %.15g current %.15g",atom->natoms,natoms);
+  sprintf(str,"Lost atoms: original %.15g current %.15g",atom->natoms,ntotal);
   if (me == 0) error->warning(str);
   lostbefore = 1;
-  return natoms;
+  return ntotal;
 }
 
 /* ----------------------------------------------------------------------
@@ -473,18 +393,108 @@ void Thermo::modify_params(int narg, char **arg)
   while (iarg < narg) {
     if (strcmp(arg[iarg],"temp") == 0) {
       if (iarg+2 > narg) error->all("Illegal thermo_modify command");
-      int tempwhich;
-      for (tempwhich = 0; tempwhich < force->ntemp; tempwhich++)
-	if (strcmp(arg[iarg+1],force->templist[tempwhich]->id) == 0) break;
-      if (tempwhich == force->ntemp) 
-	error->all("Could not find thermo_modify temperature ID");
-      if (force->templist[tempwhich]->igroup != 0 && comm->me == 0)
+      if (index_temp < 0) error->all("Thermo style does not use temp");
+      if (internal_temp) {
+	modify->delete_compute(id_compute[index_temp]);
+	internal_temp = 0;
+      }
+      delete [] id_compute[index_temp];
+      int n = strlen(arg[1]) + 1;
+      id_compute[index_temp] = new char[n];
+      strcpy(id_compute[index_temp],arg[1]);
+
+      int icompute = modify->find_compute(id_compute[index_temp]);
+      if (icompute < 0) error->all("Could not find thermo_modify temp ID");
+      temperature = modify->compute[icompute];
+
+      if (temperature->tempflag == 0)
+	error->all("Thermo_modify temp ID does not compute temperature");
+      if (temperature->igroup != 0 && comm->me == 0)
 	error->warning("Temperature for thermo pressure is not for group all");
-      if (strcmp(force->templist[tempwhich]->style,"region") == 0 && 
-	  comm->me == 0)
-	error->warning("Temperature for thermo pressure is style region");
-      temperature = force->templist[tempwhich];
+
+      // if pressure being computed by thermo:
+      // reset id_pre of pressure to new temp ID
+
+      if (index_press >= 0) {
+	icompute = modify->find_compute(id_compute[index_press]);
+	if (icompute < 0) error->all("Press ID for thermo does not exist");
+	delete [] modify->compute[icompute]->id_pre;
+	modify->compute[icompute]->id_pre = new char[n];
+	strcpy(modify->compute[icompute]->id_pre,arg[1]);
+      }
+
+      iarg += 2;
+
+    } else if (strcmp(arg[0],"press") == 0) {
+      if (iarg+2 > narg) error->all("Illegal thermo_modify command");
+      if (index_press < 0) error->all("Thermo style does not use press");
+      if (internal_press) {
+	modify->delete_compute(id_compute[index_press]);
+	internal_press = 0;
+      }
+      delete [] id_compute[index_press];
+      int n = strlen(arg[1]) + 1;
+      id_compute[index_press] = new char[n];
+      strcpy(id_compute[index_press],arg[1]);
+
+      int icompute = modify->find_compute(id_compute[index_press]);
+      if (icompute < 0) error->all("Could not find thermo_modify press ID");
+      pressure = modify->compute[icompute];
+
+      if (pressure->pressflag == 0)
+	error->all("Thermo_modify press ID does not compute pressure");
+
+      // if id_pre of new pressure is not being computed, add to compute list
+      // swap it with pressure in list so id_pre will be computed first
+      // OK to call add_compute with "which" acting as index
+
+      int which = compute_which[index_press];
+      int ncompute_current = ncompute;
+      icompute = add_compute(pressure->id_pre,which);
+      if (icompute == ncompute_current) {
+	int iswap = compute_which[index_press];
+	compute_which[index_press] = compute_which[icompute];
+	compute_which[icompute] = iswap;
+	char *cswap = id_compute[index_press];
+	id_compute[index_press] = id_compute[icompute];
+	id_compute[icompute] = cswap;
+	index_press = icompute;
+      }
+
+      iarg += 2;
+
+    } else if (strcmp(arg[0],"drot") == 0) {
+      if (iarg+2 > narg) error->all("Illegal thermo_modify command");
+      if (index_drot < 0) error->all("Thermo style does not use drot");
+      if (internal_drot) {
+	modify->delete_compute(id_compute[index_drot]);
+	internal_drot = 0;
+      }
+      delete [] id_compute[index_drot];
+      int n = strlen(arg[1]) + 1;
+      id_compute[index_drot] = new char[n];
+      strcpy(id_compute[index_drot],arg[1]);
+
+      int icompute = modify->find_compute(id_compute[index_drot]);
+      if (icompute < 0) error->all("Could not find thermo_modify drot ID");
+      iarg += 2;
+
+    } else if (strcmp(arg[0],"grot") == 0) {
+      if (iarg+2 > narg) error->all("Illegal thermo_modify command");
+      if (index_grot < 0) error->all("Thermo style does not use grot");
+      if (internal_grot) {
+	modify->delete_compute(id_compute[index_grot]);
+	internal_grot = 0;
+      }
+      delete [] id_compute[index_grot];
+      int n = strlen(arg[1]) + 1;
+      id_compute[index_grot] = new char[n];
+      strcpy(id_compute[index_grot],arg[1]);
+
+      int icompute = modify->find_compute(id_compute[index_grot]);
+      if (icompute < 0) error->all("Could not find thermo_modify grot ID");
       iarg += 2;
+
     } else if (strcmp(arg[iarg],"lost") == 0) {
       if (iarg+2 > narg) error->all("Illegal thermo_modify command");
       if (strcmp(arg[iarg+1],"ignore") == 0) lostflag = IGNORE;
@@ -492,6 +502,7 @@ void Thermo::modify_params(int narg, char **arg)
       else if (strcmp(arg[iarg+1],"error") == 0) lostflag = ERROR;
       else error->all("Illegal thermo_modify command");
       iarg += 2;
+
     } else if (strcmp(arg[iarg],"norm") == 0) {
       if (iarg+2 > narg) error->all("Illegal thermo_modify command");
       normuserflag = 1;
@@ -499,48 +510,44 @@ void Thermo::modify_params(int narg, char **arg)
       else if (strcmp(arg[iarg+1],"yes") == 0) normuser = 1;
       else error->all("Illegal thermo_modify command");
       iarg += 2;
+
     } else if (strcmp(arg[iarg],"flush") == 0) {
       if (iarg+2 > narg) error->all("Illegal thermo_modify command");
       if (strcmp(arg[iarg+1],"no") == 0) flushflag = 0;
       else if (strcmp(arg[iarg+1],"yes") == 0) flushflag = 1;
       else error->all("Illegal thermo_modify command");
       iarg += 2;
+
     } else if (strcmp(arg[iarg],"line") == 0) {
       if (iarg+2 > narg) error->all("Illegal thermo_modify command");
       if (strcmp(arg[iarg+1],"one") == 0) lineflag = ONELINE;
       else if (strcmp(arg[iarg+1],"multi") == 0) lineflag = MULTILINE;
       else error->all("Illegal thermo_modify command");
       iarg += 2;
+
     } else if (strcmp(arg[iarg],"format") == 0) {
       if (iarg+3 > narg) error->all("Illegal thermo_modify command");
       if (strcmp(arg[iarg+1],"int") == 0) {
-	if (format_iflag) delete [] format_int_user;
-	format_iflag = 1;
+	if (format_int_user) delete [] format_int_user;
 	int n = strlen(arg[iarg+2]) + 1;
 	format_int_user = new char[n];
 	strcpy(format_int_user,arg[iarg+2]);
       } else if (strcmp(arg[iarg+1],"float") == 0) {
-	if (format_fflag) delete [] format_float_user;
-	format_fflag = 1;
+	if (format_float_user) delete [] format_float_user;
 	int n = strlen(arg[iarg+2]) + 1;
 	format_float_user = new char[n];
 	strcpy(format_float_user,arg[iarg+2]);
       } else {
 	int i = atoi(arg[iarg+1]);
-	if (i < 1) error->all("Illegal thermo_modify command");
-	format_user =
-	  (char **) memory->srealloc(format_user,(nformat+1)*sizeof(char *),
-				     "thermo:format_user");
-	format_index =
-	  (int *) memory->srealloc(format_index,(nformat+1)*sizeof(int),
-				   "thermo:format_index");
+	if (i < 1 || i > nfield_initial)
+	  error->all("Illegal thermo_modify command");
+	if (format_user[i]) delete [] format_user[i];
 	int n = strlen(arg[iarg+2]) + 1;
-	format_user[nformat] = new char[n];
-	strcpy(format_user[nformat],arg[iarg+2]);
-	format_index[nformat] = i;
-	nformat++;
+	format_user[i] = new char[n];
+	strcpy(format_user[i],arg[iarg+2]);
       }
       iarg += 3;
+
     } else if (strcmp(arg[iarg],"window") == 0) {
       if (iarg+2 > narg) error->all("Illegal thermo_modify command");
       nwindow = atoi(arg[iarg+1]);
@@ -557,10 +564,81 @@ void Thermo::modify_params(int narg, char **arg)
       epast = new double[nwindow];
       pepast = new double[nwindow];
       iarg += 2;
+
     } else error->all("Illegal thermo_modify command");
   }
 }
 
+/* ----------------------------------------------------------------------
+   allocate all per-field memory
+   allow for addition of Volume field at run time
+   allow each c_ID to imply 2 Compute objects (if it has id_pre)
+------------------------------------------------------------------------- */
+
+void Thermo::allocate()
+{
+  int n = nfield_initial + 1;
+
+  keyword = new char*[n];
+  for (int i = 0; i < n; i++) keyword[i] = new char[32];
+  vfunc = new FnPtr[n];
+  vtype = new int[n];
+
+  format = new char*[n];
+  for (int i = 0; i < n; i++) format[i] = new char[32];
+  format_user = new char*[n];
+  for (int i = 0; i < n; i++) format_user[i] = NULL;
+
+  field2object = new int[n];
+  arg_object = new int[n];
+
+  ncompute = 0;
+  id_compute = new char*[2*n];
+  compute_which = new int[2*n];
+  computes = new Compute*[2*n];
+
+  nfix = 0;
+  id_fix = new char*[n];
+  fixes = new Fix*[n];
+
+  nvariable = 0;
+  id_variable = new char*[n];
+}
+
+/* ----------------------------------------------------------------------
+   deallocate all per-field memory
+------------------------------------------------------------------------- */
+
+void Thermo::deallocate()
+{
+  int n = nfield_initial + 1;
+
+  for (int i = 0; i < n; i++) delete [] keyword[i];
+  delete [] keyword;
+  delete [] vfunc;
+  delete [] vtype;
+
+  for (int i = 0; i < n; i++) delete [] format[i];
+  delete [] format;
+  for (int i = 0; i < n; i++) delete [] format_user[i];
+  delete [] format_user;
+
+  delete [] field2object;
+  delete [] arg_object;
+
+  for (int i = 0; i < ncompute; i++) delete [] id_compute[i];
+  delete [] id_compute;
+  delete [] compute_which;
+  delete [] computes;
+
+  for (int i = 0; i < nfix; i++) delete [] id_fix[i];
+  delete [] id_fix;
+  delete [] fixes;
+
+  for (int i = 0; i < nvariable; i++) delete [] id_variable[i];
+  delete [] id_variable;
+}
+
 /* ----------------------------------------------------------------------
    parse list of thermo keywords from str
    set compute flags (temp, press, etc)
@@ -568,16 +646,14 @@ void Thermo::modify_params(int narg, char **arg)
 
 void Thermo::parse_fields(char *str)
 {
-  keyword = NULL;
-  vfunc = NULL;
-  vtype = NULL;
+  nfield = 0;
+  peflag = 0;
 
-  tempflag = pressflag = tensorflag = granflag = peflag = dipoleflag = 0;
-
-  // customize by adding to if statement
+  // customize a new keyword by adding to if statement
 
   char *word = strtok(str," \0");
   while (word) {
+
     if (strcmp(word,"step") == 0) {
       addfield("Step",&Thermo::compute_step,INT);
     } else if (strcmp(word,"atoms") == 0) {
@@ -586,22 +662,25 @@ void Thermo::parse_fields(char *str)
       addfield("CPU",&Thermo::compute_cpu,FLOAT);
     } else if (strcmp(word,"temp") == 0) {
       addfield("Temp",&Thermo::compute_temp,FLOAT);
-      tempflag = 1;
+      index_temp = add_compute(id_temp,0);
     } else if (strcmp(word,"press") == 0) {
       addfield("Press",&Thermo::compute_press,FLOAT);
-      tempflag = pressflag = 1;
+      index_temp = add_compute(id_temp,0);
+      index_press = add_compute(id_press,0);
     } else if (strcmp(word,"pe") == 0) {
-      peflag = 1;
       addfield("PotEng",&Thermo::compute_pe,FLOAT);
+      peflag = 1;
     } else if (strcmp(word,"ke") == 0) {
       addfield("KinEng",&Thermo::compute_ke,FLOAT);
-      tempflag = 1;
+      index_temp = add_compute(id_temp,0);
     } else if (strcmp(word,"etotal") == 0) {
       addfield("TotEng",&Thermo::compute_etotal,FLOAT);
-      tempflag = 1;
+      peflag = 1;
+      index_temp = add_compute(id_temp,0);
     } else if (strcmp(word,"enthalpy") == 0) {
-      addfield("Enthal",&Thermo::compute_enthalpy,FLOAT);
-      tempflag = pressflag = 1;
+      addfield("Enthalpy",&Thermo::compute_enthalpy,FLOAT);
+      index_temp = add_compute(id_temp,0);
+      index_press = add_compute(id_press,0);
     } else if (strcmp(word,"evdwl") == 0) {
       addfield("E_vdwl",&Thermo::compute_evdwl,FLOAT);
     } else if (strcmp(word,"ecoul") == 0) {
@@ -622,9 +701,6 @@ void Thermo::parse_fields(char *str)
       addfield("E_long",&Thermo::compute_elong,FLOAT);
     } else if (strcmp(word,"etail") == 0) {
       addfield("E_tail",&Thermo::compute_etail,FLOAT);
-    } else if (strcmp(word,"erot") == 0) {
-      addfield("E_rot",&Thermo::compute_erot,FLOAT);
-      dipoleflag = 1;
     } else if (strcmp(word,"vol") == 0) {
       addfield("Volume",&Thermo::compute_vol,FLOAT);
     } else if (strcmp(word,"lx") == 0) {
@@ -635,116 +711,235 @@ void Thermo::parse_fields(char *str)
       addfield("Lz",&Thermo::compute_lz,FLOAT);
     } else if (strcmp(word,"pxx") == 0) {
       addfield("Pxx",&Thermo::compute_pxx,FLOAT);
-      tempflag = pressflag = tensorflag = 1;
+      index_temp = add_compute(id_temp,1);
+      index_press = add_compute(id_press,1);
     } else if (strcmp(word,"pyy") == 0) {
       addfield("Pyy",&Thermo::compute_pyy,FLOAT);
-      tempflag = pressflag = tensorflag = 1;
+      index_temp = add_compute(id_temp,1);
+      index_press = add_compute(id_press,1);
     } else if (strcmp(word,"pzz") == 0) {
       addfield("Pzz",&Thermo::compute_pzz,FLOAT);
-      tempflag = pressflag = tensorflag = 1;
+      index_temp = add_compute(id_temp,1);
+      index_press = add_compute(id_press,1);
     } else if (strcmp(word,"pxy") == 0) {
       addfield("Pxy",&Thermo::compute_pxy,FLOAT);
-      tempflag = pressflag = tensorflag = 1;
+      index_temp = add_compute(id_temp,1);
+      index_press = add_compute(id_press,1);
     } else if (strcmp(word,"pxz") == 0) {
       addfield("Pxz",&Thermo::compute_pxz,FLOAT);
-      tempflag = pressflag = tensorflag = 1;
+      index_temp = add_compute(id_temp,1);
+      index_press = add_compute(id_press,1);
     } else if (strcmp(word,"pyz") == 0) {
       addfield("Pyz",&Thermo::compute_pyz,FLOAT);
-      tempflag = pressflag = tensorflag = 1;
-    } else if (strcmp(word,"gke") == 0) {
-      addfield("Trans-KE",&Thermo::compute_gke,FLOAT);
-      granflag = 1;
+      index_temp = add_compute(id_temp,1);
+      index_press = add_compute(id_press,1);
+    } else if (strcmp(word,"drot") == 0) {
+      addfield("RotKEdip",&Thermo::compute_drot,FLOAT);
+      index_drot = add_compute(id_drot,0);
     } else if (strcmp(word,"grot") == 0) {
-      addfield("Rot-KE",&Thermo::compute_grot,FLOAT);
-      granflag = 1;
+      addfield("RotKEgrn",&Thermo::compute_grot,FLOAT);
+      index_grot = add_compute(id_grot,0);
     } else if (strcmp(word,"tave") == 0) {
       addfield("T_ave",&Thermo::compute_tave,FLOAT);
-      tempflag = 1;
+      index_temp = add_compute(id_temp,0);
     } else if (strcmp(word,"pave") == 0) {
       addfield("P_ave",&Thermo::compute_pave,FLOAT);
-      pressflag = 1;
+      index_temp = add_compute(id_temp,0);
+      index_press = add_compute(id_press,0);
     } else if (strcmp(word,"eave") == 0) {
       addfield("E_ave",&Thermo::compute_eave,FLOAT);
+      peflag = 1;
+      index_temp = add_compute(id_temp,0);
     } else if (strcmp(word,"peave") == 0) {
       addfield("PE_ave",&Thermo::compute_peave,FLOAT);
+      peflag = 1;
 
-    // user-defined temperature (t_ID)
-    // only 1st 8 chars of ID are passed to addfield
-    // extend tempindices and store index of ID into force::templist
+    // compute value = c_ID, fix value = f_ID, variable value = v_ID
+    // if no trailing [], then arg is set to 0, else arg is between []
+    // copy = at most 8 chars of ID to pass to addfield
+    // for compute, if has pre-compute object, first add it to list
 
-    } else if (strncmp(word,"t_",2) == 0) {
+    } else if ((strncmp(word,"c_",2) == 0) || (strncmp(word,"f_",2) == 0) ||
+	       (strncmp(word,"v_",2) == 0)) {
+
+      int n = strlen(word);
+      char *id = new char[n];
+      strcpy(id,&word[2]);
       char copy[9];
-      strncpy(copy,word,8);
-      copy[0] = 'T';
+      strncpy(copy,id,8);
       copy[8] = '\0';
-      addfield(copy,&Thermo::compute_t_id,FLOAT);
-      int tempwhich;
-      for (tempwhich = 0; tempwhich < force->ntemp; tempwhich++)
-	if (strcmp(&word[2],force->templist[tempwhich]->id) == 0) break;
-      if (tempwhich == force->ntemp) 
-	error->all("Could not find thermo temperature ID");
-      tempindices = (int *) memory->srealloc(tempindices,
-					     (ntemp+1)*sizeof(int),
-					     "thermo:tempindices");
-      tempindices[ntemp++] = tempwhich;
-    } else error->all("Invalid keyword in thermo_style command");
+
+      char *ptr = strchr(id,'[');
+      if (ptr) {
+	if (id[strlen(id)-1] != ']')
+	  error->all("Invalid keyword in thermo_style custom command");
+	arg_object[nfield] = atoi(ptr+1);
+	*ptr = '\0';
+      } else arg_object[nfield] = 0;
+
+      if (word[0] == 'c') {
+	n = modify->find_compute(id);
+	if (n < 0) error->all("Could not find thermo custom compute ID");
+	if (arg_object[nfield] == 0 && modify->compute[n]->scalar_flag == 0)
+	  error->all("Thermo compute ID does not compute scalar info");
+	if (arg_object[nfield] > 0 && modify->compute[n]->vector_flag == 0)
+	  error->all("Thermo compute ID does not compute vector info");
+	if (arg_object[nfield] > 0 && 
+	    arg_object[nfield] > modify->compute[n]->size_vector)
+	  error->all("Thermo compute ID vector is not large enough");
+	if (modify->compute[n]->id_pre)
+	  int tmp = add_compute(modify->compute[n]->id_pre,arg_object[nfield]);
+	field2object[nfield] = add_compute(id,arg_object[nfield]);
+	addfield(copy,&Thermo::compute_compute,FLOAT);
+
+      } else if (word[0] == 'f') {
+	n = modify->find_fix(id);
+	if (n < 0) error->all("Could not find thermo custom fix ID");
+	field2object[nfield] = add_fix(id);
+	addfield(copy,&Thermo::compute_fix,FLOAT);
+
+      } else {
+	n = input->variable->find(id);
+	if (n < 0) error->all("Could not find thermo custom variable ID");
+	field2object[nfield] = add_variable(id);
+	addfield(copy,&Thermo::compute_variable,FLOAT);
+      }
+
+      delete [] id;
+
+    } else error->all("Invalid keyword in thermo_style custom command");
 
     word = strtok(NULL," \0");
   }
 }
 
 /* ----------------------------------------------------------------------
-   add one field to list of quantities to print
-   extend keyword,vfunc,vtype arrays
+   add field to list of quantities to print
 ------------------------------------------------------------------------- */
 
 void Thermo::addfield(char *key, FnPtr func, int typeflag)
 {
-  keyword = (char **)
-    memory->srealloc(keyword,(nfield+1)*sizeof(char *),"thermo:keyword");
-  vfunc = (FnPtr *)
-    memory->srealloc(vfunc,(nfield+1)*sizeof(FnPtr),"thermo:vfunc");
-  vtype = (int *)
-    memory->srealloc(vtype,(nfield+1)*sizeof(int),"thermo:vtype");
-
-  int n = strlen(key) + 1;
-  keyword[nfield] = new char[n];
   strcpy(keyword[nfield],key);
   vfunc[nfield] = func;
   vtype[nfield] = typeflag;
   nfield++;
 }
 
+/* ----------------------------------------------------------------------
+   add compute ID to list of Compute objects to call
+   if already in list, do not add, just return location, else add to list
+   convert index into which param
+     index = 0 -> scalar, index >= 1 -> vector
+     which = 1 -> scalar only, which = 2 -> vector only, which = 3 -> both
+------------------------------------------------------------------------- */
+
+int Thermo::add_compute(char *id, int index)
+{
+  int icompute;
+  for (icompute = 0; icompute < ncompute; icompute++)
+    if (strcmp(id,id_compute[icompute]) == 0) {
+      if (index == 0 && compute_which[icompute] == 1)
+	compute_which[icompute] = 2;
+      if (index > 0 && compute_which[icompute] == 0)
+	compute_which[icompute] = 2;
+      break;
+    }
+  if (icompute < ncompute) return icompute;
+
+  int n = strlen(id) + 1;
+  id_compute[ncompute] = new char[n];
+  strcpy(id_compute[ncompute],id);
+  if (index == 0) compute_which[ncompute] = 0;
+  else compute_which[ncompute] = 1;
+  ncompute++;
+  return ncompute-1;
+}
+
+/* ----------------------------------------------------------------------
+   add fix ID to list of Fix objects to call
+------------------------------------------------------------------------- */
+
+int Thermo::add_fix(char *id)
+{
+  int n = strlen(id) + 1;
+  id_fix[nfix] = new char[n];
+  strcpy(id_fix[nfix],id);
+  nfix++;
+  return nfix-1;
+}
+
+/* ----------------------------------------------------------------------
+   add variable ID to list of Variables to evaluate
+------------------------------------------------------------------------- */
+
+int Thermo::add_variable(char *id)
+{
+  int n = strlen(id) + 1;
+  id_variable[nvariable] = new char[n];
+  strcpy(id_variable[nvariable],id);
+  nvariable++;
+  return nvariable-1;
+}
+
+/* ----------------------------------------------------------------------
+   create a Compute object for group all
+------------------------------------------------------------------------- */
+
+void Thermo::create_compute(char *id, char *cstyle, char *extra)
+{
+  char **newarg = new char*[4];
+  newarg[0] = id;
+  newarg[1] = "all";
+  newarg[2] = cstyle;
+  if (extra) newarg[3] = extra;
+  if (extra) modify->add_compute(4,newarg);
+  else modify->add_compute(3,newarg);
+  delete [] newarg;
+}
+
 /* ----------------------------------------------------------------------
    compute a single thermodyanmic value matching word to custom list
-   called by variable evaulation function from input script
-   return it as double in answer
+   called when a variable is evaluated in input script
+   return value as double in answer
    return 0 if OK, 1 if str is invalid
-   customize by adding to if statement
-     not all keywords are supported
-     only add keyword if it makes sense in input script variable
+   customize a new keyword by adding to if statement
 ------------------------------------------------------------------------- */
 
-int Thermo::compute_value(char *word, double *answer)
+int Thermo::evaluate_keyword(char *word, double *answer)
 {
-  if (strcmp(word,"temp") == 0) {
-    tempvalue = temperature->compute();
-    compute_temp();
-  } else if (strcmp(word,"press") == 0) {
-    tempvalue = temperature->compute();
-    pressure->compute(temperature);
-    compute_press();
-  } else if (strcmp(word,"pe") == 0) {
-    fix_compute_pe();
-    compute_pe();
-  } else if (strcmp(word,"ke") == 0) {
-    tempvalue = temperature->compute();
-    compute_ke();
-  } else if (strcmp(word,"etotal") == 0) {
-    tempvalue = temperature->compute();
-    fix_compute_pe();
-    compute_etotal();
-  } else if (strcmp(word,"enthalpy") == 0) compute_enthalpy();
+  // could do tests to insure user does not invoke variable at wrong time
+
+  // all keywords:
+  //   if (domain->box_exist == 0)
+  //   error->all("Variable equal keyword used before simulation box defined");
+  // keywords except step,atoms,vol,ly,ly,lz
+  //   if (update->first_update == 0)
+  //     error->all("Variable equal keyword used before initial run");
+  //   if (update->ntimestep != output->next_thermo && me == 0)
+  //     error->warning("Variable equal keyword used with non-current thermo");
+  // keywords that require Compute objects like T,P
+  //   ptrs like temperature will not be set if init() hasn't been called
+  //   Compute objects will not exist if thermo style isn't using them
+
+  // toggle thermoflag off/on so inidividual compute routines don't assume
+  //   they are being called from compute() which pre-calls Compute objects
+
+  thermoflag = 0;
+
+  if (strcmp(word,"step") == 0) {
+    compute_step();
+    dvalue = ivalue;
+  } else if (strcmp(word,"atoms") == 0) {
+    compute_atoms();
+    dvalue = ivalue;
+  }
+  else if (strcmp(word,"cpu") == 0) compute_cpu();
+  else if (strcmp(word,"temp") == 0) compute_temp();
+  else if (strcmp(word,"press") == 0) compute_press();
+  else if (strcmp(word,"pe") == 0) compute_pe();
+  else if (strcmp(word,"ke") == 0) compute_ke();
+  else if (strcmp(word,"etotal") == 0) compute_etotal();
+  else if (strcmp(word,"enthalpy") == 0) compute_enthalpy();
   else if (strcmp(word,"evdwl") == 0) compute_evdwl();
   else if (strcmp(word,"ecoul") == 0) compute_ecoul();
   else if (strcmp(word,"epair") == 0) compute_epair();
@@ -755,36 +950,72 @@ int Thermo::compute_value(char *word, double *answer)
   else if (strcmp(word,"emol") == 0) compute_emol();
   else if (strcmp(word,"elong") == 0) compute_elong();
   else if (strcmp(word,"etail") == 0) compute_etail();
-  else if (strcmp(word,"erot") == 0) compute_erot();
-  else if (strcmp(word,"gke") == 0) compute_gke();
+  else if (strcmp(word,"vol") == 0) compute_vol();
+  else if (strcmp(word,"lx") == 0) compute_lx();
+  else if (strcmp(word,"ly") == 0) compute_ly();
+  else if (strcmp(word,"lz") == 0) compute_lz();
+  else if (strcmp(word,"pxx") == 0) compute_pxx();
+  else if (strcmp(word,"pyy") == 0) compute_pyy();
+  else if (strcmp(word,"pzz") == 0) compute_pzz();
+  else if (strcmp(word,"pxy") == 0) compute_pxy();
+  else if (strcmp(word,"pxz") == 0) compute_pxz();
+  else if (strcmp(word,"pyz") == 0) compute_pyz();
+  else if (strcmp(word,"drot") == 0) compute_drot();
   else if (strcmp(word,"grot") == 0) compute_grot();
-  else if (strncmp(word,"t_",2) == 0) {
-    int tempwhich;
-    for (tempwhich = 0; tempwhich < force->ntemp; tempwhich++)
-      if (strcmp(&word[2],force->templist[tempwhich]->id) == 0) break;
-    if (tempwhich == force->ntemp) return 1;
-    dvalue = force->templist[tempwhich]->compute();
-  } else return 1;
-  
+  else if (strcmp(word,"tave") == 0) compute_tave();
+  else if (strcmp(word,"pave") == 0) compute_pave();
+  else if (strcmp(word,"eave") == 0) compute_eave();
+  else if (strcmp(word,"peave") == 0) compute_peave();
+  else return 1;
+
+  thermoflag = 1;
+
   *answer = dvalue;
   return 0;
 }
 
 /* ----------------------------------------------------------------------
-   compute potential energy from any fixes
-   called when compute_pe() is called directly and not via Thermo::compute()
-   e.g. from minimize or Thermo::compute_value()
+   extraction of Compute, Fix, Variable results
+   ignore thermoflag, since these 3 routines only called by Thermo::compute(),
+     not by variable evaluation
+   compute value is normalized by atoms if returning extensive quantities
+   fix value is normalized (so should return extensive quantity)
+   variable value is not normalized (so formula should normalize if desired)
 ------------------------------------------------------------------------- */
 
-void Thermo::fix_compute_pe()
+/* ---------------------------------------------------------------------- */
+
+void Thermo::compute_compute()
+{
+  int index = field2object[ifield];
+  if (arg_object[ifield] == 0) dvalue = computes[index]->scalar;
+  else dvalue = computes[index]->vector[arg_object[ifield]];
+  if (computes[index]->extensive && normflag) dvalue /= natoms;
+}
+
+/* ---------------------------------------------------------------------- */
+
+void Thermo::compute_fix()
 {
-  if (nfix_energy) modify->thermo_compute(fixvalues);
+  int index = field2object[ifield];
+  dvalue = fixes[index]->thermo(arg_object[ifield]);
+  if (normflag) dvalue /= natoms;
+}
+
+/* ---------------------------------------------------------------------- */
+
+void Thermo::compute_variable()
+{
+  int index = field2object[ifield];
+  dvalue = atof(input->variable->retrieve(id_variable[index]));
 }
 
 /* ----------------------------------------------------------------------
-   one routine for every quantity thermo can output
+   one routine for every thermo keyword can output
+   thermoflag = 1 if called by Thermo::compute()
+   thermoflag = 0 if called by evaluate_keyword() via Variable
    set ivalue/dvalue if value is integer/double
-   customize by adding a method
+   customize a new keyword by adding a method
 ------------------------------------------------------------------------- */
 
 void Thermo::compute_step()
@@ -796,7 +1027,8 @@ void Thermo::compute_step()
 
 void Thermo::compute_atoms()
 {
-  ivalue = static_cast<int> (natoms);
+  if (thermoflag) ivalue = static_cast<int> (natoms);
+  else ivalue = static_cast<int> (atom->natoms);
 }
 
 /* ---------------------------------------------------------------------- */
@@ -811,14 +1043,19 @@ void Thermo::compute_cpu()
 
 void Thermo::compute_temp()
 {
-  dvalue = tempvalue;
+  if (thermoflag) dvalue = temperature->scalar;
+  else dvalue = temperature->compute_scalar();
 }
 
 /* ---------------------------------------------------------------------- */
 
 void Thermo::compute_press()
 {
-  dvalue = pressure->p_total;
+  if (thermoflag) dvalue = pressure->scalar;
+  else {
+    dvalue = temperature->compute_scalar();
+    dvalue = pressure->compute_scalar();
+  }
 }
 
 /* ---------------------------------------------------------------------- */
@@ -845,8 +1082,7 @@ void Thermo::compute_pe()
     double volume = domain->xprd * domain->yprd * domain->zprd;
     dvalue += force->pair->etail / volume;
   }
-  if (nfix_energy)
-    for (int i = 0; i < nfix_energy; i++) dvalue += fixvalues[fixenergy[i]];
+  if (modify->n_thermo_energy) dvalue += modify->thermo_energy();
 
   if (normflag) dvalue /= natoms;
 
@@ -859,22 +1095,25 @@ void Thermo::compute_pe()
 
 void Thermo::compute_ke()
 {
-  dvalue = 0.5 * temperature->dof * force->boltz * tempvalue;
+  if (thermoflag) dvalue = temperature->scalar;
+  else dvalue = temperature->compute_scalar();
+  dvalue *= 0.5 * temperature->dof * force->boltz;
   if (normflag) dvalue /= natoms;
 }
 
-
 /* ---------------------------------------------------------------------- */
 
 void Thermo::compute_etotal()
 {
   compute_pe();
-  double ke = 0.5 * temperature->dof * force->boltz * tempvalue;
+  double ke;
+  if (thermoflag) ke = temperature->scalar;
+  else ke = temperature->compute_scalar();
+  ke *= 0.5 * temperature->dof * force->boltz;
   if (normflag) ke /= natoms;
   dvalue += ke;
 }
 
-
 /* ---------------------------------------------------------------------- */
 
 void Thermo::compute_enthalpy()
@@ -1024,28 +1263,6 @@ void Thermo::compute_etail()
 
 /* ---------------------------------------------------------------------- */
 
-void Thermo::compute_erot()
-{
-  int *type = atom->type;
-  double *dipole = atom->dipole;
-  double **omega = atom->omega;
-  int nlocal = atom->nlocal;
-
-  double erot = 0.0;
-  for (int i = 0; i < nlocal; i++) {
-    if (dipole[type[i]] > 0.0)
-      erot += inertia[type[i]] * 
-	(omega[i][0]*omega[i][0] + omega[i][1]*omega[i][1] + 
-	 omega[i][2]*omega[i][2]);
-  }
-  double all;
-  MPI_Allreduce(&erot,&all,1,MPI_DOUBLE,MPI_SUM,world);
-  dvalue = 0.5 * all;
-  if (normflag) dvalue /= natoms;
-}
-
-/* ---------------------------------------------------------------------- */
-
 void Thermo::compute_vol()
 {
   dvalue = domain->xprd * domain->yprd * domain->zprd;
@@ -1076,108 +1293,97 @@ void Thermo::compute_lz()
 
 void Thermo::compute_pxx()
 {
-  dvalue = pressure->p_tensor[0];
+  if (!thermoflag) {
+    temperature->compute_vector();
+    pressure->compute_vector();
+  }
+  dvalue = pressure->vector[0];
 }
 
 /* ---------------------------------------------------------------------- */
 
 void Thermo::compute_pyy()
 {
-  dvalue = pressure->p_tensor[1];
+  if (!thermoflag) {
+    temperature->compute_vector();
+    pressure->compute_vector();
+  }
+  dvalue = pressure->vector[1];
 }
 
 /* ---------------------------------------------------------------------- */
 
 void Thermo::compute_pzz()
 {
-  dvalue = pressure->p_tensor[2];
+  if (!thermoflag) {
+    temperature->compute_vector();
+    pressure->compute_vector();
+  }
+  dvalue = pressure->vector[2];
 }
 
 /* ---------------------------------------------------------------------- */
 
 void Thermo::compute_pxy()
 {
-  dvalue = pressure->p_tensor[3];
+  if (!thermoflag) {
+    temperature->compute_vector();
+    pressure->compute_vector();
+  }
+  dvalue = pressure->vector[3];
 }
 
 /* ---------------------------------------------------------------------- */
 
 void Thermo::compute_pxz()
 {
-  dvalue = pressure->p_tensor[4];
+  if (!thermoflag) {
+    temperature->compute_vector();
+    pressure->compute_vector();
+  }
+  dvalue = pressure->vector[4];
 }
 
 /* ---------------------------------------------------------------------- */
 
 void Thermo::compute_pyz()
 {
-  dvalue = pressure->p_tensor[5];
+  if (!thermoflag) {
+    temperature->compute_vector();
+    pressure->compute_vector();
+  }
+  dvalue = pressure->vector[5];
 }
 
 /* ---------------------------------------------------------------------- */
 
-void Thermo::compute_gke()
+void Thermo::compute_drot()
 {
-  double *rmass = atom->rmass;
-  double **v = atom->v;
-  int *mask = atom->mask;
-  int nlocal = atom->nlocal;
-  
-  double nactive = 0.0;
-  double ke = 0.0;
-  for (int i = 0; i < nlocal; i++)
-    if (!(mask[i] & freeze_group_bit)) {
-      nactive++;
-      ke += (v[i][0]*v[i][0] + v[i][1]*v[i][1] + v[i][2]*v[i][2]) * rmass[i];
-    }
-
-  ke *= 0.5 * force->mvv2e;
-  MPI_Allreduce(&ke,&dvalue,1,MPI_DOUBLE,MPI_SUM,world);
-  if (normflag) {
-    ke = dvalue;
-    MPI_Allreduce(&nactive,&dvalue,1,MPI_DOUBLE,MPI_SUM,world);
-    if (dvalue > 0) dvalue = ke / dvalue;
-  }
+  if (thermoflag) dvalue = rotate_dipole->scalar;
+  else dvalue = rotate_dipole->compute_scalar();
+  if (normflag) dvalue /= natoms;
 }
 
 /* ---------------------------------------------------------------------- */
 
 void Thermo::compute_grot()
 {
-  double *rmass = atom->rmass;
-  double *radius = atom->radius;
-  double **phiv = atom->phiv;
-  int *mask = atom->mask;
-  int nlocal = atom->nlocal;
-  
-  double nactive = 0.0;
-  double ephi = 0.0;
-  for (int i = 0; i < nlocal; i++)
-    if (!(mask[i] & freeze_group_bit)) {
-      nactive++;
-      ephi += (phiv[i][0]*phiv[i][0] + phiv[i][1]*phiv[i][1] + 
-	       phiv[i][2]*phiv[i][2]) * radius[i]*radius[i]*rmass[i];
-    }
-
-  if (force->dimension == 3) ephi *= 0.5 * force->mvv2e * INERTIA3D;
-  else ephi *= 0.5 * force->mvv2e * INERTIA2D;
-  MPI_Allreduce(&ephi,&dvalue,1,MPI_DOUBLE,MPI_SUM,world);
-  if (normflag) {
-    ephi = dvalue;
-    MPI_Allreduce(&nactive,&dvalue,1,MPI_DOUBLE,MPI_SUM,world);
-    if (dvalue > 0) dvalue = ephi / dvalue;
-  }
+  if (thermoflag) dvalue = rotate_gran->scalar;
+  else dvalue = rotate_gran->compute_scalar();
+  if (normflag) dvalue /= natoms;
 }
 
 /* ---------------------------------------------------------------------- */
 
 void Thermo::compute_tave()
 {
+  compute_temp();
+
   if (firststep == 0) {
     if (npartial_t == 0) {
       ncurrent_t = 0;
       npartial_t = 1;
-      tsum = tpast[0] = tempvalue;
+      tsum = tpast[0] = dvalue;
     }
     dvalue = tsum/npartial_t;
   } else {
@@ -1185,7 +1391,7 @@ void Thermo::compute_tave()
     if (ncurrent_t == nwindow) ncurrent_t = 0;
     if (npartial_t == nwindow) tsum -= tpast[ncurrent_t];
     else npartial_t++;
-    tpast[ncurrent_t] = tempvalue;
+    tpast[ncurrent_t] = dvalue;
     tsum += tpast[ncurrent_t];
     dvalue = tsum/npartial_t;
   }
@@ -1195,11 +1401,13 @@ void Thermo::compute_tave()
 
 void Thermo::compute_pave()
 {
+  compute_press();
+
   if (firststep == 0) {
     if (npartial_p == 0) {
       ncurrent_p = 0;
       npartial_p = 1;
-      psum = ppast[0] = pressure->p_total;
+      psum = ppast[0] = dvalue;
     }
     dvalue = psum/npartial_p;
   } else {
@@ -1207,7 +1415,7 @@ void Thermo::compute_pave()
     if (ncurrent_p == nwindow) ncurrent_p = 0;
     if (npartial_p == nwindow) psum -= ppast[ncurrent_p];
     else npartial_p++;
-    ppast[ncurrent_p] = pressure->p_total;
+    ppast[ncurrent_p] = dvalue;
     psum += ppast[ncurrent_p];
     dvalue = psum/npartial_p;
   }
@@ -1260,18 +1468,3 @@ void Thermo::compute_peave()
     dvalue = pesum/npartial_pe;
   }
 }
-
-/* ---------------------------------------------------------------------- */
-
-void Thermo::compute_t_id()
-{
-  dvalue = force->templist[tempindices[itemp_print++]]->compute();
-}
-
-/* ---------------------------------------------------------------------- */
-
-void Thermo::compute_fix()
-{
-  dvalue = fixvalues[fixprint[ifix_print++]];
-  if (normflag) dvalue /= natoms;
-}
diff --git a/src/thermo.h b/src/thermo.h
index e05af51e722308f9ee1c23a7eef10660e25fab1a..4c40da14b7a9a75c368b5c82d707c271290230e6 100644
--- a/src/thermo.h
+++ b/src/thermo.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -14,47 +14,40 @@
 #ifndef THERMO_H
 #define THERMO_H
 
-#include "lammps.h"
+#include "pointers.h"
 
-class Temperature;
-class Pressure;
+namespace LAMMPS_NS {
 
-class Thermo : public LAMMPS {
+class Thermo : protected Pointers {
   friend class WriteRestart;           // accesses lostflag
-  friend class Pressure;               // accesses temperature,tensorflag
-  friend class Temper;                 // accesses peflag,potential_energy
-  friend class MinCG;                  // accesses compute_pe,potential_energy
+  friend class MinCG;                  // accesses compute_pe
 
  public:
   char *style;
+  int peflag;
+  double potential_energy;
 
-  Thermo(int, char **);
+  Thermo(class LAMMPS *, int, char **);
   ~Thermo();
   void init();
   double lost_check();
   void modify_params(int, char **);
   void header();
   void compute(int);
-  int compute_value(char *, double *);
-  void fix_compute_pe();
+  int evaluate_keyword(char *, double *);
 
  private:
   int me;
+
   char *line;
   int nfield,nfield_initial;
   char **keyword;
   int *vtype;
-  int freeze_group_bit;
-  int tensorflag,granflag,dipoleflag;
-  double *inertia;
 
-  char *format_int_def,*format_g_def,*format_f_def,*format_multi;
-  int format_iflag,format_fflag;
+  char *format_multi,*format_int_one_def,*format_int_multi_def;
+  char *format_g_def,*format_f_def;
   char *format_int_user,*format_float_user;
-  int nformat;
-  char **format_user;
-  int *format_index;
-  char **format;
+  char **format,**format_user;
 
   int normflag;          // 0 if do not normalize by atoms, 1 if normalize
   int normvalue;         // use this for normflag unless natoms = 0
@@ -65,33 +58,65 @@ class Thermo : public LAMMPS {
   int lostflag,lostbefore;
   int flushflag,lineflag;
 
-  Pressure *pressure;
-  Temperature *temperature;
-
-  int ivalue,tempflag,pressflag,peflag;
-  double dvalue,natoms,tempvalue,potential_energy;
-
-  int ntemp,itemp_print;
-  int *tempindices;
-  int nfix,ifix_print,nfix_print,nfix_energy;
-  double *fixvalues;
-  int *fixflags,*fixenergy,*fixprint;
-  int nextra;
-
-  int nwindow;
+                         // data used by routines that compute single values
+  int ivalue;            // integer value to print
+  double dvalue,natoms;  // dvalue = double value to print
+  int ifield;            // which field in thermo output is being computed
+  int thermoflag;        // 1 when called by compute(), 0 from variable eval
+  int *field2object;     // which object (C,F,v) computes this field
+  int *arg_object;       // integer arg to pass to routine that computes it
+
+                         // data for keyword-specific Compute objects
+                         // index = where they are in computes list
+                         // internal = 1/0 if Thermo created them or not
+                         // id = ID of Compute objects
+                         // Compute * = ptrs to the Compute objects
+  int index_temp,index_press,index_drot,index_grot;
+  int internal_temp,internal_press,internal_drot,internal_grot;
+  char *id_temp,*id_press,*id_drot,*id_grot;
+  class Compute *temperature,*pressure,*rotate_dipole,*rotate_gran;
+
+  int ncompute;          // # of Compute objects called by thermo
+  char **id_compute;     // their IDs
+  int *compute_which;    // 0/1/2 if should call scalar() or vector() or both
+  class Compute **computes;    // list of ptrs to the Compute objects
+
+  int nfix;              // # of Fix objects called by thermo
+  char **id_fix;         // their IDs
+  class Fix **fixes;     // list of ptrs to the Fix objects
+
+  int nvariable;         // # of variables evaulated by thermo
+  char **id_variable;    // list of variable names
+
+  int nwindow;            // time averaged values
   int npartial_t,ncurrent_t,npartial_p,ncurrent_p;
   int npartial_e,ncurrent_e,npartial_pe,ncurrent_pe;
   double tsum,psum,esum,pesum;
   double *tpast,*ppast,*epast,*pepast;
 
-  typedef void (Thermo::*FnPtr)();
+  // private methods
+
+  void allocate();
+  void deallocate();
+
   void parse_fields(char *);
+  int add_compute(char *, int);
+  int add_fix(char *);
+  int add_variable(char *);
+  void create_compute(char *, char *, char *);
+
+  typedef void (Thermo::*FnPtr)();
   void addfield(char *, FnPtr, int);
-  FnPtr *vfunc;                      // list of ptrs to functions
+  FnPtr *vfunc;                // list of ptrs to functions
 
-  // customize by adding a method prototype
+  void compute_compute();      // functions that compute a single value
+  void compute_fix();          // via calls to  Compute,Fix,Variable classes
+  void compute_variable();
 
-  void compute_step();      // functions that each compute one value to print
+  // functions that compute a single value
+  // customize a new keyword by adding a method prototype
+
+  void compute_step();    
   void compute_atoms();
   void compute_cpu();
   void compute_temp();
@@ -110,7 +135,6 @@ class Thermo : public LAMMPS {
   void compute_emol();
   void compute_elong();
   void compute_etail();
-  void compute_erot();
   void compute_vol();
   void compute_lx();
   void compute_ly();
@@ -121,14 +145,14 @@ class Thermo : public LAMMPS {
   void compute_pxy();
   void compute_pyz();
   void compute_pxz();
-  void compute_gke();
+  void compute_drot();
   void compute_grot();
-  void compute_fix();
   void compute_tave();
   void compute_pave();
   void compute_eave();
   void compute_peave();
-  void compute_t_id();
 };
 
+}
+
 #endif
diff --git a/src/timer.cpp b/src/timer.cpp
index 385af066a8be8e0e4c4f18f107d5c1966ccb296f..cca090ea89309adff8e4506a8babc4e8a049ebf7 100644
--- a/src/timer.cpp
+++ b/src/timer.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -15,9 +15,11 @@
 #include "timer.h"
 #include "memory.h"
 
+using namespace LAMMPS_NS;
+
 /* ---------------------------------------------------------------------- */
 
-Timer::Timer()
+Timer::Timer(LAMMPS *lmp) : Pointers(lmp)
 {
   array = (double *) memory->smalloc(TIME_N*sizeof(double),"array");
 }
diff --git a/src/timer.h b/src/timer.h
index be0be7a72ea78039fa31166f2e2b7a61b7dc36f6..d48181b1980ba1e2d0ca00a8950e5704dd19348a 100644
--- a/src/timer.h
+++ b/src/timer.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -14,7 +14,9 @@
 #ifndef TIMER_H
 #define TIMER_H
 
-#include "lammps.h"
+#include "pointers.h"
+
+#define TIME_N           8
 
 #define TIME_TOTAL       0
 #define TIME_LOOP        1
@@ -25,13 +27,13 @@
 #define TIME_COMM        6
 #define TIME_OUTPUT      7
 
-#define TIME_N           8
+namespace LAMMPS_NS {
 
-class Timer : public LAMMPS {
+class Timer : protected Pointers {
  public:
   double *array;
 
-  Timer();
+  Timer(class LAMMPS *);
   ~Timer();
   void init();
   void stamp();
@@ -44,4 +46,6 @@ class Timer : public LAMMPS {
   double previous_time;
 };
 
+}
+
 #endif
diff --git a/src/universe.cpp b/src/universe.cpp
index 90db6851b110cad380e9cfc757ab85a4fef8faca..37f761cf3b93c5542836e2ce162411ac8a8d9083 100644
--- a/src/universe.cpp
+++ b/src/universe.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -18,11 +18,13 @@
 #include "universe.h"
 #include "memory.h"
 
+using namespace LAMMPS_NS;
+
 /* ----------------------------------------------------------------------
    create & initialize the universe of processors in communicator
 ------------------------------------------------------------------------- */
 
-Universe::Universe(MPI_Comm communicator)
+Universe::Universe(LAMMPS *lmp, MPI_Comm communicator) : Pointers(lmp)
 {
   version = "1 Oct 2006";
 
diff --git a/src/universe.h b/src/universe.h
index fdcad37630161931cc1c014952bdcddac6884b62..c23059885ef8446389e236d48a8644676859df14 100644
--- a/src/universe.h
+++ b/src/universe.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,9 +16,11 @@
 
 #include "mpi.h"
 #include "stdio.h"
-#include "lammps.h"
+#include "pointers.h"
 
-class Universe : public LAMMPS {
+namespace LAMMPS_NS {
+
+class Universe : protected Pointers {
  public:
   char *version;          // LAMMPS version string = date
 
@@ -33,10 +35,12 @@ class Universe : public LAMMPS {
   int *procs_per_world;   // # of procs in each world
   int *root_proc;         // root proc in each world
 
-  Universe(MPI_Comm);
+  Universe(class LAMMPS *, MPI_Comm);
   ~Universe();
   void add_world(char *);
   int consistent();
 };
 
+}
+
 #endif
diff --git a/src/update.cpp b/src/update.cpp
index 8f8c6a5ac3ef539278a852c683830b3e48050700..12ab0db154a30b829247f1d670ead374062b7c92 100644
--- a/src/update.cpp
+++ b/src/update.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -25,9 +25,11 @@
 #undef IntegrateInclude
 #undef MinimizeInclude
 
+using namespace LAMMPS_NS;
+
 /* ---------------------------------------------------------------------- */
 
-Update::Update()
+Update::Update(LAMMPS *lmp) : Pointers(lmp)
 {
   int n;
   char *str;
@@ -46,13 +48,13 @@ Update::Update()
   n = strlen(str) + 1;
   integrate_style = new char[n];
   strcpy(integrate_style,str);
-  integrate = new Verlet(0,NULL);
+  integrate = new Verlet(lmp,0,NULL);
 
   str = "cg";
   n = strlen(str) + 1;
   minimize_style = new char[n];
   strcpy(minimize_style,str);
-  minimize = new MinCG();
+  minimize = new MinCG(lmp);
 }
 
 /* ---------------------------------------------------------------------- */
@@ -140,7 +142,7 @@ void Update::create_integrate(int narg, char **arg)
 
 #define IntegrateClass
 #define IntegrateStyle(key,Class) \
-  else if (strcmp(arg[0],#key) == 0) integrate = new Class(narg-1,&arg[1]);
+  else if (strcmp(arg[0],#key) == 0) integrate = new Class(lmp,narg-1,&arg[1]);
 #include "style.h"
 #undef IntegrateClass
 
@@ -164,7 +166,7 @@ void Update::create_minimize(int narg, char **arg)
 
 #define MinimizeClass
 #define MinimizeStyle(key,Class) \
-  else if (strcmp(arg[0],#key) == 0) minimize = new Class();
+  else if (strcmp(arg[0],#key) == 0) minimize = new Class(lmp);
 #include "style.h"
 #undef MinimizeClass
 
diff --git a/src/update.h b/src/update.h
index 3db0dd0e20007b0af0c9154915d70e64a633aba9..4f1aa29139a53ac936184ebdae929d85376c0dec 100644
--- a/src/update.h
+++ b/src/update.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -14,12 +14,11 @@
 #ifndef UPDATE_H
 #define UPDATE_H
 
-#include "lammps.h"
+#include "pointers.h"
 
-class Integrate;
-class Min;
+namespace LAMMPS_NS {
 
-class Update : public LAMMPS {
+class Update : protected Pointers {
  public:
   double dt;                      // timestep
   double tolerance;               // minimizer tolerance
@@ -36,13 +35,13 @@ class Update : public LAMMPS {
 
   char *unit_style;
 
-  Integrate *integrate;
+  class Integrate *integrate;
   char *integrate_style;
 
-  Min *minimize;
+  class Min *minimize;
   char *minimize_style;
 
-  Update();
+  Update(class LAMMPS *);
   ~Update();
   void init();
   void set_units(char *);
@@ -51,4 +50,6 @@ class Update : public LAMMPS {
   int memory_usage();
 };
 
+}
+
 #endif
diff --git a/src/variable.cpp b/src/variable.cpp
index 487dbb4be7a62259302ac0c05a2123326edc93a1..96f3ee5ecffea1899de22956ee867bce0c6df020 100644
--- a/src/variable.cpp
+++ b/src/variable.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -14,6 +14,7 @@
 #include "math.h"
 #include "stdlib.h"
 #include "string.h"
+#include "ctype.h"
 #include "unistd.h"
 #include "variable.h"
 #include "universe.h"
@@ -21,18 +22,22 @@
 #include "update.h"
 #include "group.h"
 #include "domain.h"
+#include "modify.h"
+#include "compute.h"
 #include "output.h"
 #include "thermo.h"
 #include "memory.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 #define VARDELTA 4
 
 enum{INDEX,LOOP,EQUAL,WORLD,UNIVERSE,ULOOP};
 
 /* ---------------------------------------------------------------------- */
 
-Variable::Variable()
+Variable::Variable(LAMMPS *lmp) : Pointers(lmp)
 {
   MPI_Comm_rank(world,&me);
 
@@ -390,16 +395,26 @@ void Variable::copy(int narg, char **from, char **to)
 }
 
 /* ----------------------------------------------------------------------
-   recursive method to evaluate a string
-   string can be a number: 0.0, -5.45, etc
-   string can be a keyword: lx, ly, lz, vol, etc
-   string can be a vector: x[123], y[3], vx[34], etc
-     value inside brackets must be global ID from 1 to Natoms
-   string can be a function: div(x,y), mult(x,y), add(x,y), xcm(group,x), etc
-     function args can be combo of  number, keyword, vector, fn(), group, etc
-   see lists of valid keywords, vectors, and functions below
+   recursive evaluation of a "string"
+   string is defined as one of several items:
+     number =  0.0, -5.45, 2.8e-4, ...
+     thermo keyword = ke, vol, atoms, ...
+     variable keyword = v_a, v_myvar, ...
+     math function = div(x,y), mult(x,y), add(x,y), ...
+     group function = mass(group), xcm(group,x), ...
+     atom vector = x[123], y[3], vx[34], ...
+     compute vector = c_mytemp[0], c_thermo_press[3], ...
+   functions contain ()
+     can have 1 or 2 args, each of which can be a "string"
+   vectors contain []
+     single arg must be integer
+     for atom vectors, it is global ID of atom
+     for compute vectors, 0 is the scalar value, 1-N are vector values
+   keywords start with a lowercase letter (no parens or brackets)
+   numbers start with a digit or "." or "-" (no parens or brackets)
+   see lists of valid functions, vectors, keywords below
    when string is evaluated, put result in a newly allocated string
-   return address of result string (will be freed by caller)
+   return the address of result string (will be freed by caller)
 ------------------------------------------------------------------------- */
 
 char *Variable::evaluate(char *str)
@@ -409,7 +424,10 @@ char *Variable::evaluate(char *str)
   char *result = new char[32];
   double answer;
 
-  // if string is "function", grab one or two args, evaulate args recursively
+  // string is a "function" since contains ()
+  // grab one or two args, separated by ","
+  // evaulate args recursively
+  // then evaluate math or group function
 
   if (strchr(str,'(')) {
     if (str[strlen(str)-1] != ')')
@@ -452,11 +470,9 @@ char *Variable::evaluate(char *str)
     char *strarg1 = NULL;
     char *strarg2 = NULL;
 
-    // customize by adding function to this list and to if statement
-    // math functions: add(x,y),sub(x,y),mult(x,y),div(x,y),
-    //                 neg(x),pow(x,y),exp(x),ln(x),sqrt(x)
-    // group functions: mass(group),charge(group),xcm(group,dim),
-    //                  vcm(group,dim),bound(group,xmin),gyration(group)
+    // customize by adding math function to this list and to if statement
+    //   add(x,y),sub(x,y),mult(x,y),div(x,y),neg(x),
+    //   pow(x,y),exp(x),ln(x),sqrt(x)
 
     if (strcmp(func,"add") == 0) {
       if (!arg2) error->all("Cannot evaluate variable equal command");
@@ -530,6 +546,10 @@ char *Variable::evaluate(char *str)
 	error->all("Cannot evaluate variable equal command");
       answer = sqrt(value1);
 
+    // customize by adding group function to this list and to if statement
+    //   mass(group),charge(group),xcm(group,dim),vcm(group,dim),
+    //   bound(group,xmin),gyration(group)
+
     } else if (strcmp(func,"mass") == 0) {
       if (arg2) error->all("Cannot evaluate variable equal command");
       int igroup = group->find(arg1);
@@ -593,7 +613,7 @@ char *Variable::evaluate(char *str)
       group->xcm(igroup,masstotal,xcm);
       answer = group->gyration(igroup,masstotal,xcm);
 
-    } else error->all("Cannot evaluate variable equal command");
+    } else error->all("Invalid math/group function in variable equal command");
 
     delete [] func;
     delete [] arg1;
@@ -604,13 +624,17 @@ char *Variable::evaluate(char *str)
     }
     sprintf(result,"%.10g",answer);
 
-  // if string is "vector", find which proc owns atom, grab vector value
+  // string is a "vector" since contains []
+  // index = everything between [] evaluated as integer
+  // if vector name starts with "c_", trailing chars are compute ID
+  //   check if compute ID exists, invoke it with index as arg
+  // else is atom vector
+  //   find which proc owns atom via atom->map()
+  //   grab atom-based value with index as global atom ID
 
   } else if (strchr(str,'[')) {
     if (str[strlen(str)-1] != ']')
       error->all("Cannot evaluate variable equal command");
-    if (atom->map_style == 0)
-      error->all("Cannot use vectors in variables unless atom map exists");
 
     char *ptr = strchr(str,'[');
     int n = ptr - str;
@@ -625,77 +649,121 @@ char *Variable::evaluate(char *str)
     arg = new char[n+1];
     strncpy(arg,ptr,n);
     arg[n] = '\0';
-    int i = atom->map(atoi(arg));
 
-    double mine;
-    if (i >= 0 && i < atom->nlocal) {
+    if (strncmp(vector,"c_",2) == 0) {
+      n = strlen(vector) - 2 + 1;
+      char *id = new char[n];
+      strcpy(id,&vector[2]);
+
+      int icompute;
+      for (icompute = 0; icompute < modify->ncompute; icompute++)
+	if (strcmp(id,modify->compute[icompute]->id) == 0) break;
+      if (icompute == modify->ncompute)
+	error->all("Invalid compute ID in variable equal");
+      delete [] id;
+      modify->compute[icompute]->init();
+
+      // call compute() if index = 0, else compute_vector()
+      // make pre-call to Compute object's id_pre if it is defined
+
+      int index = atoi(arg);
+      if (index == 0) {
+	if (modify->compute[icompute]->scalar_flag == 0)
+	  error->all("Variable compute ID does not compute scalar info");
+	if (modify->compute[icompute]->id_pre) {
+	  int ipre = modify->find_compute(modify->compute[icompute]->id_pre);
+	  if (ipre < 0) error->all("Could not pre-compute in variable equal");
+	  answer = modify->compute[ipre]->compute_scalar();
+	}
+	answer = modify->compute[icompute]->compute_scalar();
+      } else if (index > 0) {
+	if (modify->compute[icompute]->vector_flag == 0)
+	  error->all("Variable compute ID does not compute scalar info");
+	if (index > modify->compute[icompute]->size_vector)
+	  error->all("Variable compute ID vector is not large enough");
+	if (modify->compute[icompute]->id_pre) {
+	  int ipre = modify->find_compute(modify->compute[icompute]->id_pre);
+	  if (ipre < 0) error->all("Could not pre-compute in variable equal");
+	  modify->compute[ipre]->compute_vector();
+	}
+	modify->compute[icompute]->compute_vector();
+	answer = modify->compute[icompute]->vector[index-1];
+      } else error->all("Invalid compute ID index in variable equal");
 
-      // customize by adding vector to this list and to if statement
-      // x,y,z,vx,vy,vz,fx,fy,fz
+    } else {
+
+      if (atom->map_style == 0)
+	error->all("Cannot use atom vectors in variable "
+                   "unless atom map exists");
 
-      if (strcmp(vector,"x") == 0) mine = atom->x[i][0];
-      else if (strcmp(vector,"y") == 0) mine = atom->x[i][1];
-      else if (strcmp(vector,"z") == 0) mine = atom->x[i][2];
-      else if (strcmp(vector,"vx") == 0) mine = atom->v[i][0];
-      else if (strcmp(vector,"vy") == 0) mine = atom->v[i][1];
-      else if (strcmp(vector,"vz") == 0) mine = atom->v[i][2];
-      else if (strcmp(vector,"fx") == 0) mine = atom->f[i][0];
-      else if (strcmp(vector,"fy") == 0) mine = atom->f[i][1];
-      else if (strcmp(vector,"fz") == 0) mine = atom->f[i][2];
+      int index = atom->map(atoi(arg));
 
-      else error->one("Invalid vector in variable equal command");
+      // customize by adding atom vector to this list and to if statement
+      // x,y,z,vx,vy,vz,fx,fy,fz
 
-    } else mine = 0.0;
-    MPI_Allreduce(&mine,&answer,1,MPI_DOUBLE,MPI_SUM,world);
+      double mine;
+      if (index >= 0 && index < atom->nlocal) {
+
+	if (strcmp(vector,"x") == 0) mine = atom->x[index][0];
+	else if (strcmp(vector,"y") == 0) mine = atom->x[index][1];
+	else if (strcmp(vector,"z") == 0) mine = atom->x[index][2];
+	else if (strcmp(vector,"vx") == 0) mine = atom->v[index][0];
+	else if (strcmp(vector,"vy") == 0) mine = atom->v[index][1];
+	else if (strcmp(vector,"vz") == 0) mine = atom->v[index][2];
+	else if (strcmp(vector,"fx") == 0) mine = atom->f[index][0];
+	else if (strcmp(vector,"fy") == 0) mine = atom->f[index][1];
+	else if (strcmp(vector,"fz") == 0) mine = atom->f[index][2];
+	
+	else error->one("Invalid atom vector in variable equal command");
+	
+      } else mine = 0.0;
+
+      MPI_Allreduce(&mine,&answer,1,MPI_DOUBLE,MPI_SUM,world);
+    }
 
     delete [] vector;
     delete [] arg;
     sprintf(result,"%.10g",answer);
 
-  // if string is "keyword", compute appropriate value via thermo
-
-  } else if (str[0] - 'a' >= 0 && str[0] - 'a' < 26) {
-
-    // customize by adding keyword to this list and to if statement
-    // keywords defined by thermo_style custom are passed to compute_value()
-
-    if (domain->box_exist == 0)
-      error->all("Using variable equal keyword before simulation box is defined");
-
-    // process these keywords here, not in thermo
-    // they are allowed anytime after simulation box is defined
-
-    if (strcmp(str,"step") == 0)
-      answer = update->ntimestep;
-    else if (strcmp(str,"atoms") == 0)
-      answer = atom->natoms;
-    else if (strcmp(str,"lx") == 0)
-      answer = domain->xprd;
-    else if (strcmp(str,"ly") == 0)
-      answer = domain->yprd;
-    else if (strcmp(str,"lz") == 0)
-      answer = domain->zprd;
-    else if (strcmp(str,"vol") == 0)
-      answer = domain->xprd * domain->yprd * domain->zprd;
-
-    // process other keywords via thermo
-    // error if 1st run has not yet started
-    // warning if out-of-sync with thermo, since values can be bogus
-
-    else {
-      if (update->first_update == 0)
-	error->all("Using variable equal keyword before initial run");
-      if (update->ntimestep != output->next_thermo && me == 0)
-	error->warning("Using variable equal keyword with non-current thermo");
-      int flag = output->thermo->compute_value(str,&answer);
-      if (flag) error->all("Invalid keyword in variable equal command");
+  // string is "keyword" since starts with lowercase letter
+  // if keyword starts with "v_", trailing chars are variable name
+  //   evaluate it via retrieve(), convert it to double
+  // else is thermo keyword
+  //   evaluate it via evaluate_keyword()
+
+  // compute appropriate value via thermo
+
+  } else if (islower(str[0])) {
+
+    if (strncmp(str,"v_",2) == 0) {
+      int n = strlen(str) - 2 + 1;
+      char *id = new char[n];
+      strcpy(id,&str[2]);
+
+      char *v = retrieve(id);
+      if (v == NULL)
+	error->all("Invalid variable name in variable equal command");
+      delete [] id;
+
+      answer = atof(v);
+
+    } else {
+      int flag = output->thermo->evaluate_keyword(str,&answer);
+      if (flag) error->all("Invalid thermo keyword in variable equal command");
     }
-    
+
     sprintf(result,"%.10g",answer);
 
-  // string is a number, just copy to result
+  // string is a number since starts with digit or "." or "-"
+  // just copy to result
+
+  } else if (isdigit(str[0]) || str[0] == '.' || str[0] == '-') {
+
+    strcpy(result,str);
+
+  // string is an error
 
-  } else strcpy(result,str);
+  } else error->all("Cannot evaluate variable equal command");
 
   // return newly allocated string
 
diff --git a/src/variable.h b/src/variable.h
index 1e9c3a04270b3fa19174928c8a55f6de152cc5e8..860f93200d949db4bf56b60d17238052fe5b3f59 100644
--- a/src/variable.h
+++ b/src/variable.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -14,15 +14,18 @@
 #ifndef VARIABLE_H
 #define VARIABLE_H
 
-#include "lammps.h"
+#include "pointers.h"
 
-class Variable : public LAMMPS {
+namespace LAMMPS_NS {
+
+class Variable : protected Pointers {
  public:
-  Variable();
+  Variable(class LAMMPS *);
   ~Variable();
   void set(int, char **);
   void set(char *, char *);
   int next(int, char **);
+  int find(char *);
   char *retrieve(char *);
 
  private:
@@ -35,10 +38,11 @@ class Variable : public LAMMPS {
   int *index;              // next available value for each variable
   char ***data;            // str value of each variable's values
 
-  int find(char *);
   void copy(int, char **, char **);
   char *evaluate(char *);
   void remove(int);
 };
 
+}
+
 #endif
diff --git a/src/velocity.cpp b/src/velocity.cpp
index f0a04f5fd6149d06c0793cdb20cf54d30b33683f..9d03e31979686b8822015f9cccea79efc93c3cb1 100644
--- a/src/velocity.cpp
+++ b/src/velocity.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -22,23 +22,19 @@
 #include "domain.h"
 #include "lattice.h"
 #include "force.h"
-#include "temperature.h"
-#include "temp_full.h"
+#include "modify.h"
+#include "compute.h"
+#include "compute_temp.h"
 #include "random_park.h"
 #include "group.h"
 #include "comm.h"
 #include "memory.h"
 #include "error.h"
 
-#define CREATE   1
-#define SET      2
-#define SCALE    3
-#define RAMP     4
-#define ZERO     5
+using namespace LAMMPS_NS;
 
-#define ALL      1
-#define LOCAL    2
-#define GEOM     3
+enum{CREATE,SET,SCALE,RAMP,ZERO};
+enum{ALL,LOCAL,GEOM};
 
 #define WARMUP 100
 #define SMALL  0.001
@@ -48,6 +44,10 @@
 
 /* ---------------------------------------------------------------------- */
 
+Velocity::Velocity(LAMMPS *lmp) : Pointers(lmp) {}
+
+/* ---------------------------------------------------------------------- */
+
 void Velocity::command(int narg, char **arg)
 {
   // require atom masses to all be set
@@ -77,7 +77,7 @@ void Velocity::command(int narg, char **arg)
 
   // set defaults
 
-  tempwhich = -1;
+  temperature = NULL;
   dist_flag = 0;
   sum_flag = 0;
   momentum_flag = 1;
@@ -126,24 +126,24 @@ void Velocity::create(int narg, char **arg)
   double t_desired = atof(arg[0]);
   int seed = atoi(arg[1]);
 
-  // if tempwhich = -1, create a new temperature full style with the vel group
-  // else use pre-defined temperature
+  // if temperature = NULL, create a new ComputeTemp with the velocity group
 
-  Temperature *temperature;
-  if (tempwhich == -1) {
+  int tflag = 0;
+  if (temperature == NULL) {
     char **arg = new char*[3];
-    arg[0] = "temp";
+    arg[0] = "velocity_temp";
     arg[1] = group->names[igroup];
-    arg[2] = "full";
-    temperature = new TempFull(3,arg);
+    arg[2] = "temp";
+    temperature = new ComputeTemp(lmp,3,arg);
+    tflag = 1;
     delete [] arg;
-  } else temperature = force->templist[tempwhich];
+  }
 
   // initialize temperature computation
   // warn if groups don't match
 
   if (igroup != temperature->igroup && comm->me == 0)
-    error->warning("Mismatch between velocity and temperature groups");
+    error->warning("Mismatch between velocity and compute groups");
   temperature->init();
 
   // store a copy of current velocities
@@ -177,7 +177,6 @@ void Velocity::create(int narg, char **arg)
   double *mass = atom->mass;
   double *rmass = atom->rmass;
   int dimension = force->dimension;
-  int mass_require = atom->mass_require;
 
   int m;
   double vx,vy,vz,factor;
@@ -195,7 +194,7 @@ void Velocity::create(int narg, char **arg)
       atom->map_set();
     }
 
-    random = new RanPark(seed);
+    random = new RanPark(lmp,seed);
 
     if (atom->tag_enable == 0)
       error->all("Cannot use velocity create loop all unless atoms have IDs");
@@ -237,7 +236,7 @@ void Velocity::create(int narg, char **arg)
       m = atom->map(i);
       if (m >= 0 && m < nlocal) {
 	if (mask[m] & groupbit) {
-	  if (mass_require) factor = 1.0/sqrt(mass[type[m]]);
+	  if (mass) factor = 1.0/sqrt(mass[type[m]]);
 	  else factor = 1.0/sqrt(rmass[m]);
 	  v[m][0] = vx * factor;
 	  v[m][1] = vy * factor;
@@ -255,7 +254,7 @@ void Velocity::create(int narg, char **arg)
     }
 
   } else if (loop_flag == LOCAL) {
-    random = new RanPark(seed + comm->me);
+    random = new RanPark(lmp,seed + comm->me);
     for (i = 0; i < WARMUP; i++) random->uniform();
 
     for (i = 0; i < nlocal; i++) {
@@ -269,7 +268,7 @@ void Velocity::create(int narg, char **arg)
 	  vy = random->gaussian();
 	  vz = random->gaussian();
 	}
-	if (mass_require) factor = 1.0/sqrt(mass[type[i]]);
+	if (mass) factor = 1.0/sqrt(mass[type[i]]);
 	else factor = 1.0/sqrt(rmass[i]);
 	v[i][0] = vx * factor;
 	v[i][1] = vy * factor;
@@ -279,13 +278,13 @@ void Velocity::create(int narg, char **arg)
     }
 
   } else if (loop_flag == GEOM) {
-    random = new RanPark(seed);
+    random = new RanPark(lmp,seed);
     double **x = atom->x;
     
     for (i = 0; i < nlocal; i++) {
       if (mask[i] & groupbit) {
 	triple(x[i][0],x[i][1],x[i][2],&vx,&vy,&vz,seed,random);
-	if (mass_require) factor = 1.0/sqrt(mass[type[i]]);
+	if (mass) factor = 1.0/sqrt(mass[type[i]]);
 	else factor = 1.0/sqrt(rmass[i]);
 	v[i][0] = vx * factor;
 	v[i][1] = vy * factor;
@@ -302,7 +301,7 @@ void Velocity::create(int narg, char **arg)
 
   // scale temp to desired value
 
-  double t = temperature->compute();
+  double t = temperature->compute_scalar();
   rescale(t,t_desired);
 
   // if sum_flag set, add back in previous velocities 
@@ -322,7 +321,7 @@ void Velocity::create(int narg, char **arg)
 
   memory->destroy_2d_double_array(vhold);
   delete random;
-  if (tempwhich == -1) delete temperature;
+  if (tflag) delete temperature;
 }
 
 /* ---------------------------------------------------------------------- */
@@ -376,34 +375,34 @@ void Velocity::scale(int narg, char **arg)
 {
   double t_desired = atof(arg[0]);
 
-  // if tempwhich = -1, create a new temperature full style with the vel group
-  // else use pre-defined temperature
+  // if temperature = NULL, create a new ComputeTemp with the velocity group
 
-  Temperature *temperature;
-  if (tempwhich == -1) {
+  int tflag = 0;
+  if (temperature == NULL) {
     char **arg = new char*[3];
-    arg[0] = "temp";
+    arg[0] = "velocity_temp";
     arg[1] = group->names[igroup];
-    arg[2] = "full";
-    temperature = new TempFull(3,arg);
+    arg[2] = "temp";
+    temperature = new ComputeTemp(lmp,3,arg);
+    tflag = 1;
     delete [] arg;
-  } else temperature = force->templist[tempwhich];
+  }
 
   // initialize temperature computation
   // warn if groups don't match
 
   if (igroup != temperature->igroup && comm->me == 0)
-    error->warning("Mismatch between velocity and temperature groups");
+    error->warning("Mismatch between velocity and compute groups");
   temperature->init();
 
   // scale temp to desired value
 
-  double t = temperature->compute();
+  double t = temperature->compute_scalar();
   rescale(t,t_desired);
 
   // if temperature was created, delete it
 
-  if (tempwhich == -1) delete temperature;
+  if (tflag) delete temperature;
 }
 
 /* ----------------------------------------------------------------------
@@ -542,7 +541,7 @@ void Velocity::zero_momentum()
 
 void Velocity::zero_rotation()
 {
-  int i,j;
+  int i;
 
   // cannot have 0 atoms in group
 
@@ -556,7 +555,7 @@ void Velocity::zero_rotation()
   group->xcm(igroup,masstotal,xcm);
   group->angmom(igroup,xcm,angmom);
   group->inertia(igroup,xcm,inertia);
-  group->omega(igroup,angmom,inertia,omega);
+  group->omega(angmom,inertia,omega);
 
   // adjust velocities to zero omega
   // vnew_i = v_i - w x r_i
@@ -624,10 +623,14 @@ void Velocity::options(int narg, char **arg)
       iarg += 2;
     } else if (strcmp(arg[iarg],"temp") == 0) {
       if (iarg+2 > narg) error->all("Illegal velocity command");
-      for (tempwhich = 0; tempwhich < force->ntemp; tempwhich++)
-	if (strcmp(arg[iarg+1],force->templist[tempwhich]->id) == 0) break;
-      if (tempwhich == force->ntemp) 
-	error->all("Could not find velocity temperature ID");
+      int icompute;
+      for (icompute = 0; icompute < modify->ncompute; icompute++)
+	if (strcmp(arg[iarg+1],modify->compute[icompute]->id) == 0) break;
+      if (icompute == modify->ncompute) 
+	error->all("Could not find velocity temp ID");
+      temperature = modify->compute[icompute];
+      if (temperature->tempflag == 0)
+	error->all("Velocity temp ID does not compute temperature");
       iarg += 2;
     } else if (strcmp(arg[iarg],"loop") == 0) {
       if (iarg+2 > narg) error->all("Illegal velocity command");
diff --git a/src/velocity.h b/src/velocity.h
index facedc5a84ff4aca596e2099de66b4589a2a6bd4..a1a079532121aaba5bd0356b3139fd6d4b28ca67 100644
--- a/src/velocity.h
+++ b/src/velocity.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -14,23 +14,21 @@
 #ifndef VELOCITY_H
 #define VELOCITY_H
 
-#include "lammps.h"
+#include "pointers.h"
 
-class Temperature;
-class RanPark;
+namespace LAMMPS_NS {
 
-class Velocity : public LAMMPS {
+class Velocity : protected Pointers {
  public:
-  Velocity() {}
-  ~Velocity() {}
+  Velocity(class LAMMPS *);
   void command(int, char **);
 
  private:
   int igroup,groupbit;
-  int style,tempwhich;
+  int style;
   int dist_flag,sum_flag,momentum_flag,rotation_flag,loop_flag,scale_flag;
   double xscale,yscale,zscale;
-  Temperature *temperature;
+  class Compute *temperature;
 
   void create(int, char **);
   void set(int, char **);
@@ -44,7 +42,9 @@ class Velocity : public LAMMPS {
 
   void options(int, char **);
   void triple(double, double, double, double *, double *, double *,
-	      int, RanPark *);
+	      int, class RanPark *);
 };
 
+}
+
 #endif
diff --git a/src/verlet.cpp b/src/verlet.cpp
index b97383ac2ecdf1290c3b890ffe5822a73b5fc57b..d0c7874941e9581c8b7055d88dadbd93d5e32a06 100644
--- a/src/verlet.cpp
+++ b/src/verlet.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -32,9 +32,12 @@
 #include "memory.h"
 #include "error.h"
 
+using namespace LAMMPS_NS;
+
 /* ---------------------------------------------------------------------- */
 
-Verlet::Verlet(int narg, char **arg) : Integrate(narg, arg) {}
+Verlet::Verlet(LAMMPS *lmp, int narg, char **arg) :
+  Integrate(lmp, narg, arg) {}
 
 /* ----------------------------------------------------------------------
    initialization before run
@@ -78,7 +81,7 @@ void Verlet::init()
   granflag = 0;
   if (atom->check_style("granular")) granflag = 1;
   pairflag = 1;
-  if (strcmp(atom->style,"granular") == 0) pairflag = 0;
+  if (strcmp(atom->atom_style,"granular") == 0) pairflag = 0;
 
   // local versions of Update quantities
 
diff --git a/src/verlet.h b/src/verlet.h
index d6a4ebb08cc280da40ed48a813b843f9f1293ec1..ef9fbb0f84daecc3c9fd06534de3eaf2465cf0e9 100644
--- a/src/verlet.h
+++ b/src/verlet.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,10 +16,11 @@
 
 #include "integrate.h"
 
+namespace LAMMPS_NS {
+
 class Verlet : public Integrate {
  public:
-  Verlet(int, char **);
-  ~Verlet() {}
+  Verlet(class LAMMPS *, int, char **);
   void init();
   void setup();
   void iterate(int);
@@ -35,4 +36,6 @@ class Verlet : public Integrate {
   void force_clear(int);
 };
 
+}
+
 #endif
diff --git a/src/write_restart.cpp b/src/write_restart.cpp
index f0fe38f7d0dc844adcfc8ccd8cce0e14d95478f2..5a87e0735601671438ebba30ffdae0d7b6bcc778 100644
--- a/src/write_restart.cpp
+++ b/src/write_restart.cpp
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -14,8 +14,9 @@
 #include "mpi.h"
 #include "string.h"
 #include "write_restart.h"
-#include "system.h"
 #include "atom.h"
+#include "atom_vec.h"
+#include "atom_vec_hybrid.h"
 #include "group.h"
 #include "force.h"
 #include "pair.h"
@@ -33,11 +34,13 @@
 #include "memory.h"
 #include "error.h"
 
-enum {IGNORE,WARN,ERROR};     // same as thermo.cpp
+using namespace LAMMPS_NS;
+
+enum{IGNORE,WARN,ERROR};     // same as thermo.cpp
 
 /* ---------------------------------------------------------------------- */
 
-WriteRestart::WriteRestart()
+WriteRestart::WriteRestart(LAMMPS *lmp) : Pointers(lmp)
 {
   MPI_Comm_rank(world,&me);
   MPI_Comm_size(world,&nprocs);
@@ -69,7 +72,7 @@ void WriteRestart::command(int narg, char **arg)
 
   if (comm->me == 0 && screen)
     fprintf(screen,"System init for write_restart ...\n");
-  sys->init();
+  lmp->init();
 
   // move atoms to new processors before writing file
   // enforce PBC before in case atoms are outside box
@@ -129,8 +132,8 @@ void WriteRestart::write(char *file)
   if (me == 0) {
     header();
     group->write_restart(fp);
-    if (atom->mass_require) mass();
-    if (atom->dipole_require) dipole();
+    if (atom->mass) mass();
+    if (atom->dipole) dipole();
     force_fields();
   }
 
@@ -140,7 +143,7 @@ void WriteRestart::write(char *file)
   // max_size = largest buffer needed by any proc
 
   int max_size;
-  int send_size = atom->size_restart();
+  int send_size = atom->avec->size_restart();
   MPI_Allreduce(&send_size,&max_size,1,MPI_INT,MPI_MAX,world);
 
   double *buf;
@@ -153,8 +156,9 @@ void WriteRestart::write(char *file)
 
   // pack my atom data into buf
 
+  AtomVec *avec = atom->avec;
   int n = 0;
-  for (int i = 0; i < atom->nlocal; i++) n += atom->pack_restart(i,&buf[n]);
+  for (int i = 0; i < atom->nlocal; i++) n += avec->pack_restart(i,&buf[n]);
 
   // if single file:
   //   write one chunk of atoms per proc to file
@@ -235,22 +239,20 @@ void WriteRestart::header()
 
   // atom_style must be written before atom class values
   // so read_restart can create class before reading class values
-  // if style = hybrid, also write sub-class names (1 to nwords)
+  // if style = hybrid, also write sub-class styles
 
-  write_char(19,atom->style);
+  write_char(19,atom->atom_style);
 
-  if (strcmp(atom->style,"hybrid") == 0) {
-    char **words;
-    int nwords = atom->style2arg(words);
-    int nm1 = nwords - 1;
-    fwrite(&nm1,sizeof(int),1,fp);
-    for (int i = 1; i < nwords; i++) {
-      int n = strlen(words[i]) + 1;
+  if (strcmp(atom->atom_style,"hybrid") == 0) {
+    AtomVecHybrid *avec_hybrid = (AtomVecHybrid *) atom->avec;
+    int nstyles = avec_hybrid->nstyles;
+    char **keywords = avec_hybrid->keywords;
+    fwrite(&nstyles,sizeof(int),1,fp);
+    for (int i = 0; i < nstyles; i++) {
+      int n = strlen(keywords[i]) + 1;
       fwrite(&n,sizeof(int),1,fp);
-      fwrite(words[i],sizeof(char),n,fp);
+      fwrite(keywords[i],sizeof(char),n,fp);
     }
-    for (int i = 0; i < nwords; i++) delete [] words[i];
-    delete [] words;
   }
 
   write_double(20,natoms);
@@ -322,7 +324,7 @@ void WriteRestart::force_fields()
     force->pair->write_restart(fp);
   }
 
-  if (atom->bonds_allow) {
+  if (atom->avec->bonds_allow) {
     if (force->bond) n = strlen(force->bond_style) + 1;
     else n = 0;
     fwrite(&n,sizeof(int),1,fp);
@@ -332,7 +334,7 @@ void WriteRestart::force_fields()
     }
   }
 
-  if (atom->angles_allow) {
+  if (atom->avec->angles_allow) {
     if (force->angle) n = strlen(force->angle_style) + 1;
     else n = 0;
     fwrite(&n,sizeof(int),1,fp);
@@ -342,7 +344,7 @@ void WriteRestart::force_fields()
     }
   }
 
-  if (atom->dihedrals_allow) {
+  if (atom->avec->dihedrals_allow) {
     if (force->dihedral) n = strlen(force->dihedral_style) + 1;
     else n = 0;
     fwrite(&n,sizeof(int),1,fp);
@@ -352,7 +354,7 @@ void WriteRestart::force_fields()
     }
   }
 
-  if (atom->impropers_allow) {
+  if (atom->avec->impropers_allow) {
     if (force->improper) n = strlen(force->improper_style) + 1;
     else n = 0;
     fwrite(&n,sizeof(int),1,fp);
@@ -364,7 +366,7 @@ void WriteRestart::force_fields()
 }
 
 /* ----------------------------------------------------------------------
-   write_int - write a flag and an int into restart file 
+   write a flag and an int into restart file 
 ------------------------------------------------------------------------- */
 
 void WriteRestart::write_int(int flag, int value)
@@ -374,7 +376,7 @@ void WriteRestart::write_int(int flag, int value)
 }
 
 /* ----------------------------------------------------------------------
-   write_double - write a flag and a double into restart file 
+   write a flag and a double into restart file 
 ------------------------------------------------------------------------- */
 
 void WriteRestart::write_double(int flag, double value)
@@ -384,7 +386,7 @@ void WriteRestart::write_double(int flag, double value)
 }
 
 /* ----------------------------------------------------------------------
-   write_char - write a flag and a char str into restart file 
+   write a flag and a char str into restart file 
 ------------------------------------------------------------------------- */
 
 void WriteRestart::write_char(int flag, char *value)
diff --git a/src/write_restart.h b/src/write_restart.h
index f890c723b12a2f09e67408a8ffe79e6848c3f0d1..96c9f863a7d897d02b8a0bcfb1e679dcc5fcce69 100644
--- a/src/write_restart.h
+++ b/src/write_restart.h
@@ -1,7 +1,7 @@
 /* ----------------------------------------------------------------------
    LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
-   www.cs.sandia.gov/~sjplimp/lammps.html
-   Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
+   http://lammps.sandia.gov, Sandia National Laboratories
+   Steve Plimpton, sjplimp@sandia.gov
 
    Copyright (2003) Sandia Corporation.  Under the terms of Contract
    DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
@@ -16,12 +16,13 @@
 #define WRITE_RESTART_H
 
 #include "stdio.h"
-#include "lammps.h"
+#include "pointers.h"
 
-class WriteRestart : public LAMMPS {
+namespace LAMMPS_NS {
+
+class WriteRestart : protected Pointers {
  public:
-  WriteRestart();
-  ~WriteRestart() {}
+  WriteRestart(class LAMMPS *);
   void command(int, char **);
   void write(char *);
 
@@ -40,4 +41,6 @@ class WriteRestart : public LAMMPS {
   void write_char(int, char *);
 };
 
+}
+
 #endif