diff --git a/lib/.gitignore b/lib/.gitignore
index cbeae7705e8c95436cc956bd01e60ca0cd1caff7..4f9ebba6a5bcb570e8c9c9ad5ac23e93820b8fa9 100644
--- a/lib/.gitignore
+++ b/lib/.gitignore
@@ -1,2 +1,3 @@
 Makefile.lammps
 .depend
+Makefile.auto
diff --git a/lib/Install.py b/lib/Install.py
index 6b90254336b6b54adee6453a2ed249e576329640..d30cbffcf140ef3f8b0edfdfe902a78b819d39b3 100644
--- a/lib/Install.py
+++ b/lib/Install.py
@@ -23,8 +23,9 @@ specify -m and optionally -e, order does not matter
 
 Examples:
 
-make lib-poems args="-m g++"    # build COLVARS lib with GNU g++ compiler
-make lib-meam args="-m ifort"   # build MEAM lib with Intel ifort compiler
+make lib-poems args="-m serial" # build POEMS lib with same settings as in the serial Makefile in src
+make lib-colvars args="-m mpi"  # build USER-COLVARS lib with same settings as in the mpi Makefile in src
+make lib-meam args="-m ifort"   # build MEAM lib with custom Makefile.ifort (using Intel Fortran)
 """
 
 # print error message or help
@@ -70,23 +71,31 @@ if not os.path.exists("Makefile.%s" % machine):
 lines = open("Makefile.%s" % machine,'r').readlines()
 fp = open("Makefile.auto",'w')
 
+has_extramake = False
 for line in lines:
   words = line.split()
-  if len(words) == 3 and extraflag and \
-        words[0] == "EXTRAMAKE" and words[1] == '=':
-    line = line.replace(words[2],"Makefile.lammps.%s" % suffix)
-  print >>fp,line,
+  if len(words) == 3 and words[0] == "EXTRAMAKE" and words[1] == '=':
+    has_extramake = True
+    if extraflag:
+      line = line.replace(words[2],"Makefile.lammps.%s" % suffix)
+  fp.write(line)
 
 fp.close()
 
-# make the library via Makefile.auto
+# make the library via Makefile.auto optionally with parallel make
+
+try:
+  import multiprocessing
+  n_cpus = multiprocessing.cpu_count()
+except:
+  n_cpus = 1
 
 print("Building lib%s.a ..." % lib)
-cmd = "make -f Makefile.auto clean; make -f Makefile.auto"
+cmd = "make -f Makefile.auto clean; make -f Makefile.auto -j%d" % n_cpus
 txt = subprocess.check_output(cmd,shell=True,stderr=subprocess.STDOUT)
-print(txt)
+print(txt.decode('UTF-8'))
 
 if os.path.exists("lib%s.a" % lib): print("Build was successful")
 else: error("Build of lib/%s/lib%s.a was NOT successful" % (lib,lib))
-if not os.path.exists("Makefile.lammps"):
+if has_extramake and not os.path.exists("Makefile.lammps"):
   print("lib/%s/Makefile.lammps was NOT created" % lib)
diff --git a/lib/awpmd/Makefile.mpi b/lib/awpmd/Makefile.mpi
new file mode 100644
index 0000000000000000000000000000000000000000..e4b424e77638cdccb681710e09854b3f4fc8f6b6
--- /dev/null
+++ b/lib/awpmd/Makefile.mpi
@@ -0,0 +1,71 @@
+SHELL = /bin/sh
+
+# which file will be copied to Makefile.lammps
+
+EXTRAMAKE = Makefile.lammps.linalg
+
+# ------ FILES ------
+
+SRC = \
+    ivutils/src/logexc.cpp \
+    systems/interact/TCP/wpmd.cpp \
+    systems/interact/TCP/wpmd_split.cpp
+
+INC = \
+    cerf.h \
+    cerf2.h \
+    cerf_octave.h \
+    cvector_3.h \
+    lapack_inter.h \
+    logexc.h \
+    pairhash.h \
+    refobj.h \
+    tcpdefs.h \
+    vector_3.h \
+    wavepacket.h \
+    wpmd.h \
+    wpmd_split.h
+
+# ------ DEFINITIONS ------
+
+LIB = libawpmd.a
+OBJ =   $(SRC:.cpp=.o)
+
+# ------ SETTINGS ------
+
+# include any MPI settings needed for the ATC library to build with
+# the same MPI library that LAMMPS is built with
+
+CC =	    mpicxx
+CCFLAGS = -O3 -fPIC -Isystems/interact/TCP/ -Isystems/interact -Iivutils/include \
+	  -DMPICH_IGNORE_CXX_SEEK -DOMPI_SKIP_MPICXX=1
+
+ARCHIVE =	ar
+ARCHFLAG =	-rc
+DEPFLAGS =  -M
+#LINK =         
+#LINKFLAGS =	
+USRLIB =
+SYSLIB =
+
+# ------ MAKE PROCEDURE ------
+
+lib: 	$(OBJ)
+	$(ARCHIVE) $(ARFLAGS) $(LIB) $(OBJ)
+	@cp $(EXTRAMAKE) Makefile.lammps
+
+# ------ COMPILE RULES ------
+
+%.o:%.cpp
+	$(CC) $(CCFLAGS) -c $< -o $@
+%.d:%.cpp
+	$(CC) $(CCFLAGS) $(DEPFLAGS) $< > $@		
+
+# ------ DEPENDENCIES ------
+
+DEPENDS = $(OBJ:.o=.d)
+
+# ------ CLEAN ------
+
+clean:
+	-rm -f *.d *~ $(OBJ) $(LIB)
diff --git a/lib/awpmd/Makefile.mpicc b/lib/awpmd/Makefile.mpicc
index 4c289ad88ac303ad4cbc6b5f2a67c0d2a446c255..5cf6a75bd760e70666c1a5ea978bb0198d820c20 100644
--- a/lib/awpmd/Makefile.mpicc
+++ b/lib/awpmd/Makefile.mpicc
@@ -36,8 +36,10 @@ OBJ =   $(SRC:.cpp=.o)
 # include any MPI settings needed for the ATC library to build with
 # the same MPI library that LAMMPS is built with
 
-CC =	    mpic++ 
-CCFLAGS = -O -fPIC -Isystems/interact/TCP/ -Isystems/interact -Iivutils/include
+CC =	    mpicxx
+CCFLAGS = -O3 -fPIC -Isystems/interact/TCP/ -Isystems/interact -Iivutils/include \
+	  -DMPICH_IGNORE_CXX_SEEK -DOMPI_SKIP_MPICXX=1
+
 ARCHIVE =	ar
 ARCHFLAG =	-rc
 DEPFLAGS =  -M
@@ -66,4 +68,4 @@ DEPENDS = $(OBJ:.o=.d)
 # ------ CLEAN ------
 
 clean:
-	-rm *.d *~ $(OBJ) $(LIB)
+	-rm -f *.d *~ $(OBJ) $(LIB)
diff --git a/lib/awpmd/Makefile.serial b/lib/awpmd/Makefile.serial
new file mode 100644
index 0000000000000000000000000000000000000000..f51714fc9ac9ffb514754bf23e22b5ad67561005
--- /dev/null
+++ b/lib/awpmd/Makefile.serial
@@ -0,0 +1,71 @@
+SHELL = /bin/sh
+
+# which file will be copied to Makefile.lammps
+
+EXTRAMAKE = Makefile.lammps.linalg
+
+# ------ FILES ------
+
+SRC = \
+    ivutils/src/logexc.cpp \
+    systems/interact/TCP/wpmd.cpp \
+    systems/interact/TCP/wpmd_split.cpp
+
+INC = \
+    cerf.h \
+    cerf2.h \
+    cerf_octave.h \
+    cvector_3.h \
+    lapack_inter.h \
+    logexc.h \
+    pairhash.h \
+    refobj.h \
+    tcpdefs.h \
+    vector_3.h \
+    wavepacket.h \
+    wpmd.h \
+    wpmd_split.h
+
+# ------ DEFINITIONS ------
+
+LIB = libawpmd.a
+OBJ =   $(SRC:.cpp=.o)
+
+# ------ SETTINGS ------
+
+# include any MPI settings needed for the ATC library to build with
+# the same MPI library that LAMMPS is built with
+
+CC =	    g++
+CCFLAGS = -O3 -fPIC -Isystems/interact/TCP/ -Isystems/interact -Iivutils/include \
+	  -I../../src/STUBS
+
+ARCHIVE =	ar
+ARCHFLAG =	-rc
+DEPFLAGS =  -M
+#LINK =         
+#LINKFLAGS =	
+USRLIB =
+SYSLIB =
+
+# ------ MAKE PROCEDURE ------
+
+lib: 	$(OBJ)
+	$(ARCHIVE) $(ARFLAGS) $(LIB) $(OBJ)
+	@cp $(EXTRAMAKE) Makefile.lammps
+
+# ------ COMPILE RULES ------
+
+%.o:%.cpp
+	$(CC) $(CCFLAGS) -c $< -o $@
+%.d:%.cpp
+	$(CC) $(CCFLAGS) $(DEPFLAGS) $< > $@		
+
+# ------ DEPENDENCIES ------
+
+DEPENDS = $(OBJ:.o=.d)
+
+# ------ CLEAN ------
+
+clean:
+	-rm -f *.d *~ $(OBJ) $(LIB)
diff --git a/lib/colvars/Install.py b/lib/colvars/Install.py
index 2fc207710c54e4303dc1ffc9c589be977219b3e9..01e70543f22dd9575821fbaf289521838ecd54ba 100644
--- a/lib/colvars/Install.py
+++ b/lib/colvars/Install.py
@@ -13,7 +13,7 @@ Syntax from lib/colvars dir: python Install.py -m machine -e suffix
 
 specify -m and optionally -e, order does not matter
 
-  -m = peform a clean followed by "make -f Makefile.machine"
+  -m = delete all existing objects, followed by "make -f Makefile.machine"
        machine = suffix of a lib/colvars/Makefile.* or of a
          src/MAKE/MACHINES/Makefile.* file
   -e = set EXTRAMAKE variable in Makefile.machine to Makefile.lammps.suffix
@@ -21,7 +21,7 @@ specify -m and optionally -e, order does not matter
 
 Examples:
 
-make lib-colvars args="-m g++"     # build COLVARS lib with GNU g++ compiler
+make lib-colvars args="-m mpi"     # build COLVARS lib with default mpi compiler wrapper
 """
 
 # print error message or help
@@ -122,7 +122,7 @@ for line in lines:
   fp.write(line)
 fp.close()
 
-# make the library via Makefile.auto
+# make the library via Makefile.auto optionally with parallel make
 
 try:
   import multiprocessing
@@ -132,9 +132,9 @@ except:
 
 print("Building lib%s.a ..." % lib)
 cmd = ["make -f Makefile.auto clean"]
-print(subprocess.check_output(cmd, shell=True).decode())
+print(subprocess.check_output(cmd, shell=True).decode('UTF-8'))
 cmd = ["make -f Makefile.auto -j%d" % n_cpus]
-print(subprocess.check_output(cmd, shell=True).decode())
+print(subprocess.check_output(cmd, shell=True).decode('UTF-8'))
 
 if os.path.exists("lib%s.a" % lib): print("Build was successful")
 else: error("Build of lib/%s/lib%s.a was NOT successful" % (lib,lib))
diff --git a/lib/colvars/Makefile.mingw32-cross b/lib/colvars/Makefile.mingw32-cross
deleted file mode 100644
index 29c64b26a29b23924934127fc25939ac6dbda878..0000000000000000000000000000000000000000
--- a/lib/colvars/Makefile.mingw32-cross
+++ /dev/null
@@ -1,31 +0,0 @@
-# -*- makefile -*- to build Colvars module with MinGW 32-bit
-
-EXTRAMAKE = Makefile.lammps.empty
-
-COLVARS_LIB = libcolvars.a
-COLVARS_OBJ_DIR = Obj_mingw64/
-
-CXX =		i686-w64-mingw32-g++
-CXXFLAGS =	-O2 -march=i686 -mtune=generic -mfpmath=387 -mpc64	\
-		-fno-rtti -fno-exceptions -finline-functions		\
-                -ffast-math -funroll-loops -fstrict-aliasing		\
-                -Wall -W -Wno-uninitialized
-AR =		i686-w64-mingw32-ar
-ARFLAGS =	-rscv
-SHELL =		/bin/sh
-
-.PHONY: default clean
-
-default: $(COLVARS_OBJ_DIR) $(COLVARS_LIB) Makefile.lammps
-
-include Makefile.common
-
-$(COLVARS_OBJ_DIR):
-	mkdir $(COLVARS_OBJ_DIR)
-
-clean:
-	-rm -f $(COLVARS_OBJS) $(COLVARS_LIB)
-	-rmdir $(COLVARS_OBJ_DIR)
-
-Makefile.lammps:
-	-cp $(EXTRAMAKE) Makefile.lammps
diff --git a/lib/colvars/Makefile.mingw32-cross-mpi b/lib/colvars/Makefile.mingw32-cross-mpi
deleted file mode 100644
index 1e35c5b46151a9c380a87c3a501bb6a758d2d4eb..0000000000000000000000000000000000000000
--- a/lib/colvars/Makefile.mingw32-cross-mpi
+++ /dev/null
@@ -1,13 +0,0 @@
-# -*- makefile -*- wrapper for non-MPI libraries
-
-SHELL=/bin/sh
-
-all:
-	$(MAKE) $(MFLAGS) mingw32-cross
-	-rm -f Obj_mingw32-mpi
-	ln -s Obj_mingw32 Obj_mingw32-mpi
-
-clean:
-	$(MAKE) $(MFLAGS) clean-mingw32-cross
-	-rm -f Obj_mingw32-mpi
-
diff --git a/lib/colvars/Makefile.mingw64-cross b/lib/colvars/Makefile.mingw64-cross
deleted file mode 100644
index 2fd1c6fc67f26a50b067965a0502a31f7d142ee2..0000000000000000000000000000000000000000
--- a/lib/colvars/Makefile.mingw64-cross
+++ /dev/null
@@ -1,31 +0,0 @@
-# -*- makefile -*- to build Colvars module with MinGW 32-bit
-
-EXTRAMAKE = Makefile.lammps.empty
-
-COLVARS_LIB = libcolvars.a
-COLVARS_OBJ_DIR = Obj_mingw32/
-
-CXX =		x86_64-w64-mingw32-g++
-CXXFLAGS =	-O2 -march=core2 -mtune=core2 -mpc64 -msse2		\
-		-fno-rtti -fno-exceptions -finline-functions		\
-                -ffast-math -funroll-loops -fstrict-aliasing		\
-                -Wall -W -Wno-uninitialized
-AR =		x86_64-w64-mingw32-ar
-ARFLAGS =	-rscv
-SHELL =		/bin/sh
-
-.PHONY: default clean
-
-default: $(COLVARS_OBJ_DIR) $(COLVARS_LIB) Makefile.lammps
-
-include Makefile.common
-
-$(COLVARS_OBJ_DIR):
-	mkdir $(COLVARS_OBJ_DIR)
-
-clean:
-	-rm -f $(COLVARS_OBJS) $(COLVARS_LIB)
-	-rmdir $(COLVARS_OBJ_DIR)
-
-Makefile.lammps:
-	-cp $(EXTRAMAKE) Makefile.lammps
diff --git a/lib/colvars/Makefile.mingw64-cross-mpi b/lib/colvars/Makefile.mingw64-cross-mpi
deleted file mode 100644
index ca6f4a6d43226f15bcf0e0a431b20528cfc7ff4b..0000000000000000000000000000000000000000
--- a/lib/colvars/Makefile.mingw64-cross-mpi
+++ /dev/null
@@ -1,13 +0,0 @@
-# -*- makefile -*- wrapper for non-MPI libraries
-
-SHELL=/bin/sh
-
-all:
-	$(MAKE) $(MFLAGS) mingw64-cross
-	-rm -f Obj_mingw64-mpi
-	ln -s Obj_mingw64 Obj_mingw64-mpi
-
-clean:
-	$(MAKE) $(MFLAGS) clean-mingw64-cross
-	-rm -f Obj_mingw64-mpi
-
diff --git a/lib/colvars/Makefile.mpi b/lib/colvars/Makefile.mpi
new file mode 100644
index 0000000000000000000000000000000000000000..6343ed7c06b9c88e4da35e26bb74002cf63d09b3
--- /dev/null
+++ b/lib/colvars/Makefile.mpi
@@ -0,0 +1,25 @@
+# -*- makefile -*- to build Colvars module with default MPI compiler wrapper
+
+EXTRAMAKE = Makefile.lammps.empty
+
+COLVARS_LIB = libcolvars.a
+COLVARS_OBJ_DIR =
+
+CXX =		mpicxx
+CXXFLAGS =	-O2 -g -Wall -fPIC -funroll-loops
+AR =		ar
+ARFLAGS =	-rscv
+SHELL =		/bin/sh
+
+.PHONY: default clean
+
+default: $(COLVARS_LIB) Makefile.lammps
+
+include Makefile.common
+
+clean:
+	-rm -f $(COLVARS_OBJS) $(COLVARS_LIB)
+
+Makefile.lammps:
+	-cp $(EXTRAMAKE) Makefile.lammps
+
diff --git a/lib/colvars/Makefile.serial b/lib/colvars/Makefile.serial
new file mode 100644
index 0000000000000000000000000000000000000000..556e39d070d78b0de98e5775a4e0179d7fdb9db2
--- /dev/null
+++ b/lib/colvars/Makefile.serial
@@ -0,0 +1,25 @@
+# -*- makefile -*- to build Colvars module with GNU compiler
+
+EXTRAMAKE = Makefile.lammps.empty
+
+COLVARS_LIB = libcolvars.a
+COLVARS_OBJ_DIR =
+
+CXX =		g++
+CXXFLAGS =	-O2 -g -Wall -fPIC -funroll-loops
+AR =		ar
+ARFLAGS =	-rscv
+SHELL =		/bin/sh
+
+.PHONY: default clean
+
+default: $(COLVARS_LIB) Makefile.lammps
+
+include Makefile.common
+
+clean:
+	-rm -f $(COLVARS_OBJS) $(COLVARS_LIB)
+
+Makefile.lammps:
+	-cp $(EXTRAMAKE) Makefile.lammps
+
diff --git a/lib/gpu/.gitignore b/lib/gpu/.gitignore
index 228a9f7731efcf3ad4344a09126311b7fc2bb538..9ad6046a09c08a3b59f0ba01ad4ad8a5d2fb69c8 100644
--- a/lib/gpu/.gitignore
+++ b/lib/gpu/.gitignore
@@ -1,4 +1,6 @@
-obj
-obj_ocl
-ocl_get_devices
-nvc_get_devices
+/obj
+/obj_ocl
+/ocl_get_devices
+/nvc_get_devices
+/*.cubin
+/*_cubin.h
diff --git a/lib/gpu/Install.py b/lib/gpu/Install.py
index c6cd1f3021b117ec7bf0986e685f840cd59e998c..657f1c8fcc7b0be48db185f318a67f65e1d12635 100644
--- a/lib/gpu/Install.py
+++ b/lib/gpu/Install.py
@@ -3,53 +3,57 @@
 # Install.py tool to build the GPU library
 # used to automate the steps described in the README file in this dir
 
-import sys,os,re,commands
+from __future__ import print_function
+import sys,os,subprocess
 
 # help message
 
 help = """
-Syntax from src dir: make lib-gpu args="-i isuffix -h hdir -a arch -p precision -e esuffix -m -o osuffix"
-Syntax from lib dir: python Install.py -i isuffix -h hdir -a arch -p precision -e esuffix -m -o osuffix
+Syntax from src dir: make lib-gpu args="-m machine -h hdir -a arch -p precision -e esuffix -m -o osuffix"
+Syntax from lib dir: python Install.py -m machine -h hdir -a arch -p precision -e esuffix -m -o osuffix
 
 specify one or more options, order does not matter
 
-copies an existing Makefile.isuffix in lib/gpu to Makefile.auto 
+copies an existing Makefile.machine in lib/gpu to Makefile.auto 
 optionally edits these variables in Makefile.auto:
   CUDA_HOME, CUDA_ARCH, CUDA_PRECISION, EXTRAMAKE
 optionally uses Makefile.auto to build the GPU library -> libgpu.a
   and to copy a Makefile.lammps.esuffix -> Makefile.lammps
 optionally copies Makefile.auto to a new Makefile.osuffix
 
-  -i = use Makefile.isuffix as starting point, copy to Makefile.auto
-       default isuffix = linux
+  -m = use Makefile.machine as starting point, copy to Makefile.auto
+       default machine = linux
   -h = set CUDA_HOME variable in Makefile.auto to hdir
        hdir = path to NVIDIA Cuda software, e.g. /usr/local/cuda
   -a = set CUDA_ARCH variable in Makefile.auto to arch
-       use arch = ?? for K40 (Tesla)
-       use arch = 37 for dual K80 (Tesla)
-       use arch = 60 for P100 (Pascal)
+       use arch = 20 for Tesla C2050/C2070 (Fermi) (deprecated as of CUDA 8.0) 
+                     or GeForce GTX 580 or similar
+       use arch = 30 for Tesla K10 (Kepler)
+       use arch = 35 for Tesla K40 (Kepler) or GeForce GTX Titan or similar
+       use arch = 37 for Tesla dual K80 (Kepler)
+       use arch = 60 for Tesla P100 (Pascal)
   -p = set CUDA_PRECISION variable in Makefile.auto to precision
        use precision = double or mixed or single
   -e = set EXTRAMAKE variable in Makefile.auto to Makefile.lammps.esuffix
-  -m = make the GPU library using Makefile.auto
+  -b = make the GPU library using Makefile.auto
        first performs a "make clean"
-       produces libgpu.a if successful
+       then produces libgpu.a if successful
        also copies EXTRAMAKE file -> Makefile.lammps
          -e can set which Makefile.lammps.esuffix file is copied
   -o = copy final Makefile.auto to Makefile.osuffix
 
 Examples:
 
-make lib-gpu args="-m"      # build GPU lib with default Makefile.linux
-make lib-gpu args="-i xk7 -p single -o xk7.single"      # create new Makefile.xk7.single, altered for single-precision
-make lib-gpu args="-i xk7 -p single -o xk7.single -m"   # ditto, also build GPU lib
+make lib-gpu args="-b"      # build GPU lib with default Makefile.linux
+make lib-gpu args="-m xk7 -p single -o xk7.single"      # create new Makefile.xk7.single, altered for single-precision
+make lib-gpu args="-m mpi -a 35 -p single -o mpi.mixed -b" # create new Makefile.mpi.mixed, also build GPU lib with these settings
 """
 
 # print error message or help
 
 def error(str=None):
-  if not str: print help
-  else: print "ERROR",str
+  if not str: print(help)
+  else: print("ERROR",str)
   sys.exit()
 
 # parse args
@@ -65,7 +69,7 @@ outflag = 0
 
 iarg = 0
 while iarg < nargs:
-  if args[iarg] == "-i":
+  if args[iarg] == "-m":
     if iarg+2 > nargs: error()
     isuffix = args[iarg+1]
     iarg += 2
@@ -89,7 +93,7 @@ while iarg < nargs:
     eflag = 1
     lmpsuffix = args[iarg+1]
     iarg += 2
-  elif args[iarg] == "-m":
+  elif args[iarg] == "-b":
     makeflag = 1
     iarg += 1
   elif args[iarg] == "-o":
@@ -117,9 +121,9 @@ fp = open("Makefile.auto",'w')
 for line in lines:
   words = line.split()
   if len(words) != 3:
-    print >>fp,line,
+    fp.write(line)
     continue
-  
+
   if hflag and words[0] == "CUDA_HOME" and words[1] == '=':
     line = line.replace(words[2],hdir)
   if aflag and words[0] == "CUDA_ARCH" and words[1] == '=':
@@ -128,20 +132,20 @@ for line in lines:
     line = line.replace(words[2],precstr)
   if eflag and words[0] == "EXTRAMAKE" and words[1] == '=':
     line = line.replace(words[2],"Makefile.lammps.%s" % lmpsuffix)
-    
-  print >>fp,line,
 
+  fp.write(line)
 fp.close()
 
 # perform make
 # make operations copies EXTRAMAKE file to Makefile.lammps
 
 if makeflag:
-  print "Building libgpu.a ..."
+  print("Building libgpu.a ...")
   cmd = "rm -f libgpu.a"
-  commands.getoutput(cmd)
+  subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
   cmd = "make -f Makefile.auto clean; make -f Makefile.auto"
-  commands.getoutput(cmd)
+  txt = subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
+  print(txt.decode('UTF-8'))
   if not os.path.exists("libgpu.a"):
     error("Build of lib/gpu/libgpu.a was NOT successful")
   if not os.path.exists("Makefile.lammps"):
@@ -150,6 +154,6 @@ if makeflag:
 # copy new Makefile.auto to Makefile.osuffix
 
 if outflag:
-  print "Creating new Makefile.%s" % osuffix
+  print("Creating new Makefile.%s" % osuffix)
   cmd = "cp Makefile.auto Makefile.%s" % osuffix
-  commands.getoutput(cmd)
+  subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
diff --git a/lib/gpu/Makefile.linux b/lib/gpu/Makefile.linux
index d72c0ba437fb3e58ff8193fdc44adcc63ec3d500..dfcc5bf7d3339c2e668c551627c783c6c6733970 100644
--- a/lib/gpu/Makefile.linux
+++ b/lib/gpu/Makefile.linux
@@ -37,7 +37,7 @@ CUDA_INCLUDE = -I$(CUDA_HOME)/include
 CUDA_LIB = -L$(CUDA_HOME)/lib64
 CUDA_OPTS = -DUNIX -O3 -Xptxas -v --use_fast_math $(LMP_INC)
 
-CUDR_CPP = mpic++ -DMPI_GERYON -DUCL_NO_EXIT -DMPICH_IGNORE_CXX_SEEK -DOMPI_SKIP_MPICXX=1 -fPIC
+CUDR_CPP = mpicxx -DMPI_GERYON -DUCL_NO_EXIT -DMPICH_IGNORE_CXX_SEEK -DOMPI_SKIP_MPICXX=1 -fPIC
 CUDR_OPTS = -O2 $(LMP_INC) # -xHost -no-prec-div -ansi-alias
 
 BIN_DIR = ./
diff --git a/lib/gpu/Makefile.mingw32-cross b/lib/gpu/Makefile.mingw32-cross
deleted file mode 100644
index 6f77634755c58a9dffa4522085d7c65cb86cf3b8..0000000000000000000000000000000000000000
--- a/lib/gpu/Makefile.mingw32-cross
+++ /dev/null
@@ -1,17 +0,0 @@
-CUDA_HOME = ../../tools/mingw-cross/OpenCL
-
-OCL_CPP = i686-w64-mingw32-g++ -O2 -march=i686 -mtune=generic -mfpmath=387 \
-        -mpc64 -DMPI_GERYON -DUCL_NO_EXIT -I../../src/STUBS \
-        -I$(CUDA_HOME)/include
-OCL_LINK = -static -Wl,--enable-stdcall-fixup -L$(CUDA_HOME)/../Obj_mingw32 -Wl,-Bdynamic,-lOpenCL,-Bstatic -L../../src/STUBS -lmpi_mingw32
-OCL_PREC = -D_SINGLE_DOUBLE
-OCL_TUNE = -DFERMI_OCL
-EXTRAMAKE = Makefile.lammps.mingw-cross
-
-BIN_DIR = Obj_mingw32
-OBJ_DIR = Obj_mingw32
-LIB_DIR = Obj_mingw32
-AR = i686-w64-mingw32-ar
-BSH = /bin/sh
-
-include Opencl.makefile
diff --git a/lib/gpu/Makefile.mingw32-cross-mpi b/lib/gpu/Makefile.mingw32-cross-mpi
deleted file mode 100644
index 94099cd90b5a8f43424d75830c504ebcc08c61b9..0000000000000000000000000000000000000000
--- a/lib/gpu/Makefile.mingw32-cross-mpi
+++ /dev/null
@@ -1,19 +0,0 @@
-CUDA_HOME = ../../tools/mingw-cross/OpenCL
-
-OCL_CPP = i686-w64-mingw32-g++ -O2 -march=i686 -mtune=generic -mfpmath=387 \
-        -mpc64 -DMPI_GERYON -DUCL_NO_EXIT -I$(CUDA_HOME)/include \
-	-I../../tools/mingw-cross/mpich2-win32/include/ \
-        -DMPICH_IGNORE_CXX_SEEK
-OCL_LINK = -static -Wl,--enable-stdcall-fixup -L$(CUDA_HOME)/../Obj_mingw32 -Wl,-Bdynamic,-lOpenCL,-Bstatic \
-	-L../../tools/mingw-cross/mpich2-win32/lib -lmpi
-OCL_PREC = -D_SINGLE_DOUBLE
-OCL_TUNE = -DFERMI_OCL
-EXTRAMAKE = Makefile.lammps.mingw-cross
-
-BIN_DIR = Obj_mingw32-mpi
-OBJ_DIR = Obj_mingw32-mpi
-LIB_DIR = Obj_mingw32-mpi
-AR = i686-w64-mingw32-ar
-BSH = /bin/sh
-
-include Opencl.makefile
diff --git a/lib/gpu/Makefile.mingw64-cross b/lib/gpu/Makefile.mingw64-cross
deleted file mode 100644
index 54f6af8c6579c7a0f07172adf40b25153367fb2a..0000000000000000000000000000000000000000
--- a/lib/gpu/Makefile.mingw64-cross
+++ /dev/null
@@ -1,18 +0,0 @@
-CUDA_HOME = ../../tools/mingw-cross/OpenCL
-
-OCL_CPP = x86_64-w64-mingw32-g++ -O3 -march=core2 -mtune=core2 -mpc64 \
-	-msse2 -DMPI_GERYON -DUCL_NO_EXIT -I../../src/STUBS \
-        -I$(CUDA_HOME)/include
-OCL_LINK = -static -Wl,--enable-stdcall-fixup -L$(CUDA_HOME)/../Obj_mingw64 -Wl,-Bdynamic,-lOpenCL,-Bstatic \
-	-L../../src/STUBS -lmpi_mingw64
-OCL_PREC = -D_SINGLE_DOUBLE
-OCL_TUNE = -DFERMI_OCL
-EXTRAMAKE = Makefile.lammps.mingw-cross
-
-BIN_DIR = Obj_mingw64
-OBJ_DIR = Obj_mingw64
-LIB_DIR = Obj_mingw64
-AR = x86_64-w64-mingw32-ar
-BSH = /bin/sh
-
-include Opencl.makefile
diff --git a/lib/gpu/Makefile.mingw64-cross-mpi b/lib/gpu/Makefile.mingw64-cross-mpi
deleted file mode 100644
index 2ff72d98b188c2de36862f63217a5a10bd2b785b..0000000000000000000000000000000000000000
--- a/lib/gpu/Makefile.mingw64-cross-mpi
+++ /dev/null
@@ -1,20 +0,0 @@
-CUDA_HOME = ../../tools/mingw-cross/OpenCL
-
-OCL_CPP = x86_64-w64-mingw32-g++ -O3 -march=core2 -mtune=core2 -mpc64 \
-	-msse2 -DMPI_GERYON -DUCL_NO_EXIT -I$(CUDA_HOME)/include \
-	-I../../tools/mingw-cross/mpich2-win64/include/ \
-        -DMPICH_IGNORE_CXX_SEEK
- 
-OCL_LINK = -static -Wl,--enable-stdcall-fixup -L$(CUDA_HOME)/../Obj_mingw64 -Wl,-Bdynamic,-lOpenCL,-Bstatic \
-	-L../../tools/mingw-cross/mpich2-win64/lib -lmpi
-OCL_PREC = -D_SINGLE_DOUBLE
-OCL_TUNE = -DFERMI_OCL
-EXTRAMAKE = Makefile.lammps.mingw-cross
-
-BIN_DIR = Obj_mingw64-mpi
-OBJ_DIR = Obj_mingw64-mpi
-LIB_DIR = Obj_mingw64-mpi
-AR = x86_64-w64-mingw32-ar
-BSH = /bin/sh
-
-include Opencl.makefile
diff --git a/lib/gpu/Makefile.mpi b/lib/gpu/Makefile.mpi
new file mode 120000
index 0000000000000000000000000000000000000000..8bad27d0818849aa7a0e1b83150f80d1eb47cf09
--- /dev/null
+++ b/lib/gpu/Makefile.mpi
@@ -0,0 +1 @@
+Makefile.linux
\ No newline at end of file
diff --git a/lib/gpu/Makefile.serial b/lib/gpu/Makefile.serial
index 809e99cc94d40e1eb4653aa337caef43bd57c466..9348dc565ac7e156774541d315d8eafc986d1966 100644
--- a/lib/gpu/Makefile.serial
+++ b/lib/gpu/Makefile.serial
@@ -1,5 +1,5 @@
 # /* ----------------------------------------------------------------------   
-#  Generic Makefile for CUDA using MPI STUBS library
+#  Generic Linux Makefile for CUDA 
 #     - Change CUDA_ARCH for your GPU
 # ------------------------------------------------------------------------- */
 
@@ -7,23 +7,38 @@
 
 EXTRAMAKE = Makefile.lammps.standard
 
-CUDA_HOME = $(HOME)/cuda
+ifeq ($(CUDA_HOME),)
+CUDA_HOME = /usr/local/cuda
+endif
+
 NVCC = nvcc
 
 # Tesla CUDA
-CUDA_ARCH = -arch=sm_20
+CUDA_ARCH = -arch=sm_21
 # newer CUDA
 #CUDA_ARCH = -arch=sm_13
 # older CUDA
 #CUDA_ARCH = -arch=sm_10 -DCUDA_PRE_THREE
+CUDA_ARCH = -arch=sm_35
+
+# this setting should match LAMMPS Makefile
+# one of LAMMPS_SMALLBIG (default), LAMMPS_BIGBIG and LAMMPS_SMALLSMALL
+
+LMP_INC = -DLAMMPS_SMALLBIG
+
+# precision for GPU calculations
+# -D_SINGLE_SINGLE  # Single precision for all calculations
+# -D_DOUBLE_DOUBLE  # Double precision for all calculations
+# -D_SINGLE_DOUBLE  # Accumulation of forces, etc. in double
 
 CUDA_PRECISION = -D_SINGLE_DOUBLE
+
 CUDA_INCLUDE = -I$(CUDA_HOME)/include
-CUDA_LIB = -L$(CUDA_HOME)/lib64 -L../../src/STUBS -lmpi
-CUDA_OPTS = -DUNIX -O3 -Xptxas -v --use_fast_math
+CUDA_LIB = -L$(CUDA_HOME)/lib64 -L../../src/STUBS -lmpi_stubs
+CUDA_OPTS = -DUNIX -O3 -Xptxas -v --use_fast_math $(LMP_INC)
 
-CUDR_CPP = g++ -DMPI_GERYON -DUCL_NO_EXIT -I../../src/STUBS
-CUDR_OPTS = -O2 
+CUDR_CPP = g++ -DMPI_GERYON -DUCL_NO_EXIT -fPIC -I../../src/STUBS
+CUDR_OPTS = -O2 $(LMP_INC) # -xHost -no-prec-div -ansi-alias
 
 BIN_DIR = ./
 OBJ_DIR = ./
@@ -31,5 +46,7 @@ LIB_DIR = ./
 AR = ar
 BSH = /bin/sh
 
+CUDPP_OPT = -DUSE_CUDPP -Icudpp_mini
+
 include Nvidia.makefile
 
diff --git a/lib/h5md/Makefile.h5cc b/lib/h5md/Makefile.h5cc
index bd3e8a978432448a446d415ccfc7a062e0390f22..9feed2d74e3d93a283bf2c52a89604a2276f37fe 100644
--- a/lib/h5md/Makefile.h5cc
+++ b/lib/h5md/Makefile.h5cc
@@ -9,12 +9,14 @@ HDF5_PATH=/usr
 INC=-I include
 AR=ar
 ARFLAGS=rc
-LIB=libch5md.a
+# need to build two libraries to not break compatibility and to support Install.py
+LIB=libh5md.a libch5md.a
 
 all: lib Makefile.lammps
 
 build:
 	mkdir -p build
+
 build/ch5md.o: src/ch5md.c | build
 	$(CC) $(INC) $(CFLAGS) -c $< -o $@
 
@@ -23,8 +25,11 @@ Makefile.lammps:
 
 .PHONY: all lib clean
 
-$(LIB): build/ch5md.o
-	$(AR) $(ARFLAGS) $(LIB) build/ch5md.o
+libch5md.a : build/ch5md.o
+	$(AR) $(ARFLAGS) $@ build/ch5md.o
+
+libh5md.a : build/ch5md.o
+	$(AR) $(ARFLAGS) $@ build/ch5md.o
 
 lib: $(LIB)
 
diff --git a/lib/kim/Install.py b/lib/kim/Install.py
index 315bb4e11c47cd41ec28935255fa9e76c9bedbc2..06479d2d4dd9480f0de8685f6b1535e61d240e0e 100644
--- a/lib/kim/Install.py
+++ b/lib/kim/Install.py
@@ -1,44 +1,41 @@
 #!/usr/bin/env python
 
-# install.py tool to setup the kim-api library
+# install.py tool to download, compile, and setup the kim-api library
 # used to automate the steps described in the README file in this dir
+
 from __future__ import print_function
 import sys,os,re,subprocess
 
-# transparently use either urllib or an external tool
-try:
-  import ssl
-  try: from urllib.request import urlretrieve as geturl
-  except: from urllib import urlretrieve as geturl
-except:
-  def geturl(url,fname):
-    cmd = "curl -o %s %s" % (fname,url)
-    txt = subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
-    return txt
-
 help = """
-Syntax from src dir: make lib-kim args="-v version  -a kim-name"
-Syntax from lib dir: python Install.py -v version  -a kim-name
+Syntax from src dir: make lib-kim args="-b -v version  -a kim-name"
+                 or: make lib-kim args="-b -a everything"
+                 or: make lib-kim args="-n -a kim-name"
+                 or: make lib-kim args="-p /usr/local/open-kim -a kim-name"
+Syntax from lib dir: python Install.py -b -v version  -a kim-name
+                 or: python Install.py -b -a everything
+                 or: python Install.py -n -a kim-name
+                 or: python Install.py -p /usr/local/open-kim -a kim-name
 
 specify one or more options, order does not matter
 
   -v = version of KIM API library to use
        default = kim-api-v1.8.2 (current as of June 2017)
-  -b = download and build base KIM API library with example Models (default)
+  -b = download and build base KIM API library with example Models
        this will delete any previous installation in the current folder
-  -n = do NOT download and build base KIM API library. Use an existing installation
+  -n = do NOT download and build base KIM API library.
+       Use an existing installation 
   -p = specify location of KIM API installation (implies -n)
   -a = add single KIM model or model driver with kim-name
        to existing KIM API lib (see example below).
        If kim-name = everything, then rebuild KIM API library with
-       all available OpenKIM Models (this implies -b).
+       *all* available OpenKIM Models (make take a long time).
   -vv = be more verbose about what is happening while the script runs
 
 Examples:
 
-make lib-kim           # install KIM API lib with only example models
+make lib-kim args="-b" # install KIM API lib with only example models
 make lib-kim args="-a Glue_Ercolessi_Adams_Al__MO_324507536345_001"  # Ditto plus one model
-make lib-kim args="-a everything"   # install KIM API lib with all models
+make lib-kim args="-b -a everything"   # install KIM API lib with all models
 make lib-kim args="-n -a EAM_Dynamo_Ackland_W__MO_141627196590_002"   # only add one model or model driver
 
 See the list of KIM model drivers here:
@@ -52,8 +49,9 @@ https://openkim.org/kim-api
 in the "What is in the KIM API source package?" section
 """
 
-def error():
-  print(help)
+def error(str=None):
+  if not str: print(help)
+  else: print("ERROR",str)
   sys.exit()
 
 # expand to full path name
@@ -62,15 +60,21 @@ def error():
 def fullpath(path):
   return os.path.abspath(os.path.expanduser(path))
 
+def geturl(url,fname):
+  cmd = 'curl -L -o "%s" %s' % (fname,url)
+  txt = subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
+  return txt
+
 # parse args
 
 args = sys.argv[1:]
 nargs = len(args)
+if nargs == 0: error()
 
 thisdir = os.environ['PWD']
 version = "kim-api-v1.8.2"
 
-buildflag = True
+buildflag = False
 everythingflag = False
 addflag = False
 verboseflag = False
@@ -139,7 +143,7 @@ if buildflag:
 
   if os.path.isdir(kimdir):
     print("kim-api is already installed at %s.\nRemoving it for re-install" % kimdir)
-    cmd = "rm -rf %s" % kimdir
+    cmd = 'rm -rf "%s"' % kimdir
     subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
 
   # configure LAMMPS to use kim-api to be installed
@@ -160,48 +164,48 @@ if buildflag:
   print("Downloading kim-api tarball ...")
   geturl(url,"%s/%s.tgz" % (thisdir,version))
   print("Unpacking kim-api tarball ...")
-  cmd = "cd %s; rm -rf %s; tar zxvf %s.tgz" % (thisdir,version,version)
+  cmd = 'cd "%s"; rm -rf "%s"; tar -xzvf %s.tgz' % (thisdir,version,version)
   subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
 
   # configure kim-api
 
   print("Configuring kim-api ...")
-  cmd = "cd %s/%s; ./configure --prefix='%s'" % (thisdir,version,kimdir)
+  cmd = 'cd "%s/%s"; ./configure --prefix="%s"' % (thisdir,version,kimdir)
   subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
 
   # build kim-api
 
   print("Configuring example Models")
-  cmd = "cd %s/%s; make add-examples" % (thisdir,version)
+  cmd = 'cd "%s/%s"; make add-examples' % (thisdir,version)
   txt = subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
   if verboseflag: print (txt.decode("UTF-8"))
 
   if everythingflag:
     print("Configuring all OpenKIM models, this will take a while ...")
-    cmd = "cd %s/%s; make add-OpenKIM" % (thisdir,version)
+    cmd = 'cd "%s/%s"; make add-OpenKIM' % (thisdir,version)
     txt = subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
     if verboseflag: print(txt.decode("UTF-8"))
 
   print("Building kim-api ...")
-  cmd = "cd %s/%s; make" % (thisdir,version)
+  cmd = 'cd "%s/%s"; make' % (thisdir,version)
   txt = subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
   if verboseflag: print(txt.decode("UTF-8"))
 
   # install kim-api
 
   print("Installing kim-api ...")
-  cmd = "cd %s/%s; make install" % (thisdir,version)
+  cmd = 'cd "%s/%s"; make install' % (thisdir,version)
   txt = subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
   if verboseflag: print(txt.decode("UTF-8"))
 
-  cmd = "cd %s/%s; make install-set-default-to-v1" %(thisdir,version)
+  cmd = 'cd "%s/%s"; make install-set-default-to-v1' %(thisdir,version)
   txt = subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
   if verboseflag: print(txt.decode("UTF-8"))
 
   # remove source files
 
   print("Removing kim-api source and build files ...")
-  cmd = "cd %s; rm -rf %s; rm -rf %s.tgz" % (thisdir,version,version)
+  cmd = 'cd "%s"; rm -rf %s; rm -rf %s.tgz' % (thisdir,version,version)
   subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
 
 # add a single model (and possibly its driver) to existing KIM installation
@@ -219,11 +223,11 @@ if addflag:
   geturl(url,"%s/%s.tgz" % (thisdir,addmodelname))
 
   print("Unpacking item tarball ...")
-  cmd = "cd %s; tar zxvf %s.tgz" % (thisdir,addmodelname)
+  cmd = 'cd "%s"; tar -xzvf %s.tgz' % (thisdir,addmodelname)
   subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
 
   print("Building item ...")
-  cmd = "cd %s/%s; make; make install" %(thisdir,addmodelname)
+  cmd = 'cd "%s/%s"; make; make install' %(thisdir,addmodelname)
   try:
     txt = subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
   except subprocess.CalledProcessError as e:
@@ -231,18 +235,18 @@ if addflag:
     # Error: but first, check to see if it needs a driver
     firstRunOutput = e.output.decode("UTF-8")
 
-    cmd = "cd %s/%s; make kim-item-type" % (thisdir,addmodelname)
+    cmd = 'cd "%s/%s"; make kim-item-type' % (thisdir,addmodelname)
     txt = subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
     txt = txt.decode("UTF-8")
     if txt == "ParameterizedModel":
 
       # Get and install driver
 
-      cmd = "cd %s/%s; make model-driver-name" % (thisdir,addmodelname)
+      cmd = 'cd "%s/%s"; make model-driver-name' % (thisdir,addmodelname)
       txt = subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
       adddrivername = txt.decode("UTF-8").strip()
       print("First installing model driver: %s..." % adddrivername)
-      cmd = "cd %s; python Install.py -n -a %s" % (thisdir,adddrivername)
+      cmd = 'cd "%s"; python Install.py -n -a %s' % (thisdir,adddrivername)
       try:
         txt = subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
       except subprocess.CalledProcessError as e:
@@ -254,7 +258,7 @@ if addflag:
       # now install the model that needed the driver
 
       print("Now installing model : %s" % addmodelname)
-      cmd = "cd %s; python Install.py -n -a %s" % (thisdir,addmodelname)
+      cmd = 'cd "%s"; python Install.py -n -a %s' % (thisdir,addmodelname)
       try:
         txt = subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
       except subprocess.CalledProcessError as e:
@@ -272,5 +276,5 @@ if addflag:
 
   if verboseflag: print(txt.decode("UTF-8"))
   print("Removing kim item source and build files ...")
-  cmd = "cd %s; rm -rf %s; rm -rf %s.tgz" %(thisdir,addmodelname,addmodelname)
+  cmd = 'cd "%s"; rm -rf %s; rm -rf %s.tgz' %(thisdir,addmodelname,addmodelname)
   subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
diff --git a/lib/linalg/Install.py b/lib/linalg/Install.py
deleted file mode 100644
index 560afecec42a844184b6723f1f87c55177cfd768..0000000000000000000000000000000000000000
--- a/lib/linalg/Install.py
+++ /dev/null
@@ -1,58 +0,0 @@
-#!/usr/bin/env python
-
-# install.py tool to do build of the linear algebra library
-# used to automate the steps described in the README file in this dir
-
-import sys,commands,os
-
-# help message
-
-help = """
-Syntax from src dir: make lib-linalg args="-m machine"
-Syntax from lib dir: python Install.py -m machine
-
-  -m = peform a clean followed by "make -f Makefile.machine"
-       machine = suffix of a lib/Makefile.* file
-
-Example:
-
-make lib-linalg args="-m gfortran"   # build with GNU Fortran compiler
-"""
-
-# print error message or help
-
-def error(str=None):
-  if not str: print help
-  else: print "ERROR",str
-  sys.exit()
-
-# parse args
-
-args = sys.argv[1:]
-nargs = len(args)
-if nargs == 0: error()
-
-machine = None
-
-iarg = 0
-while iarg < nargs:
-  if args[iarg] == "-m":
-    if iarg+2 > nargs: error()
-    machine = args[iarg+1]
-    iarg += 2  
-  else: error()
-
-# set lib from working dir
-
-cwd = os.getcwd()
-lib = os.path.basename(cwd)
-
-# make the library
-
-print "Building lib%s.a ..." % lib
-cmd = "make -f Makefile.%s clean; make -f Makefile.%s" % (machine,machine)
-txt = commands.getoutput(cmd)
-print txt
-
-if os.path.exists("lib%s.a" % lib): print "Build was successful"
-else: error("Build of lib/%s/lib%s.a was NOT successful" % (lib,lib))
diff --git a/lib/linalg/Install.py b/lib/linalg/Install.py
new file mode 120000
index 0000000000000000000000000000000000000000..ffe709d44c22d2060ad41538d1f8fc0df2b09b30
--- /dev/null
+++ b/lib/linalg/Install.py
@@ -0,0 +1 @@
+../Install.py
\ No newline at end of file
diff --git a/lib/linalg/Makefile.gfortran b/lib/linalg/Makefile.gfortran
index 89b7f2d7a038831a58a4310a072241bab04d8491..7e1d97a5bce8bc2982fba617541d9f48bee4e0dd 100644
--- a/lib/linalg/Makefile.gfortran
+++ b/lib/linalg/Makefile.gfortran
@@ -18,10 +18,8 @@ OBJ =   $(SRC:.f=.o)
 # ------ SETTINGS ------
 
 FC =           gfortran
-FFLAGS =      -O3 -fPIC -march=native -mpc64  \
-         -ffast-math -funroll-loops -fstrict-aliasing -Wall -W -Wno-uninitialized -fno-second-underscore
-FFLAGS0 =      -O0 -fPIC -march=native -mpc64  \
-         -Wall -W -Wno-uninitialized -fno-second-underscore
+FFLAGS =      -O3 -fPIC -ffast-math -fstrict-aliasing -fno-second-underscore
+FFLAGS0 =     -O0 -fPIC -fno-second-underscore
 ARCHIVE =	ar
 AR =	ar
 ARCHFLAG =	-rcs
@@ -47,7 +45,7 @@ dlamch.o: dlamch.f
 # ------ CLEAN ------
 
 clean:
-	-rm *.o *.mod *~ $(LIB)
+	-rm -f *.o *.mod *~ $(LIB)
 
 tar:
 	-tar -czvf ../linalg.tar.gz $(FILES)
diff --git a/lib/linalg/Makefile.mingw32-cross b/lib/linalg/Makefile.mingw32-cross
deleted file mode 100644
index 02aa3f71a34e102130d2e0da9543888c07ca9f2d..0000000000000000000000000000000000000000
--- a/lib/linalg/Makefile.mingw32-cross
+++ /dev/null
@@ -1,67 +0,0 @@
-# -*- makefile -*-
-# *_________________________________________________________________________*
-# *      Minimal BLAS/LAPACK Library for use by other LAMMPS packages
-
-SHELL = /bin/sh
-
-# ------ FILES ------
-
-SRC =	$(wildcard *.f)
-
-FILES = $(SRC) Makefile.* README
-
-# ------ DEFINITIONS ------
-
-DIR = Obj_mingw32/
-LIB = $(DIR)liblinalg.a
-OBJ =   $(SRC:%.f=$(DIR)%.o)
-
-# ------ SETTINGS ------
-
-FC =    	i686-w64-mingw32-gfortran
-FFLAGS =	-O3 -march=i686 -mtune=generic -mfpmath=387 -mpc64	\
-		-ffast-math -funroll-loops -fstrict-aliasing -Wall -W	\
-		-Wno-uninitialized -fno-second-underscore
-FFLAGS0 =	-O0 -march=i686 -mtune=generic -mfpmath=387 -mpc64	\
-		-Wall -W -Wno-uninitialized -fno-second-underscore
-ARCHIVE =	i686-w64-mingw32-ar
-AR =		i686-w64-mingw32-ar
-ARCHFLAG =	-rcs
-USRLIB =
-SYSLIB =
-
-.PHONY: default clean tar
-
-.SUFFIXES:
-.SUFFIXES: .F .f .o
-
-# ------ MAKE PROCEDURE ------
-
-default: $(DIR) $(LIB)
-
-$(LIB): $(OBJ)
-	$(ARCHIVE) $(ARFLAGS) $(LIB) $(OBJ)
-
-$(DIR):
-	mkdir $(DIR)
-
-# ------ COMPILE RULES ------
-
-$(DIR)%.o:%.F
-	$(F90) $(F90FLAGS) -c $< -o $@
-
-$(DIR)%.o:%.f
-	$(FC) $(FFLAGS) -c $< -o $@
-
-$(DIR)dlamch.o: dlamch.f
-	$(FC) $(FFLAGS0) -c $< -o $@
-
-# ------ CLEAN ------
-
-clean:
-	-rm $(DIR)*.o $(DIR)*.mod *~ $(LIB)
-	-rmdir $(DIR)
-
-tar:
-	-tar -czvf ../linalg.tar.gz $(FILES)
-
diff --git a/lib/linalg/Makefile.mingw32-cross-mpi b/lib/linalg/Makefile.mingw32-cross-mpi
deleted file mode 100644
index 1e35c5b46151a9c380a87c3a501bb6a758d2d4eb..0000000000000000000000000000000000000000
--- a/lib/linalg/Makefile.mingw32-cross-mpi
+++ /dev/null
@@ -1,13 +0,0 @@
-# -*- makefile -*- wrapper for non-MPI libraries
-
-SHELL=/bin/sh
-
-all:
-	$(MAKE) $(MFLAGS) mingw32-cross
-	-rm -f Obj_mingw32-mpi
-	ln -s Obj_mingw32 Obj_mingw32-mpi
-
-clean:
-	$(MAKE) $(MFLAGS) clean-mingw32-cross
-	-rm -f Obj_mingw32-mpi
-
diff --git a/lib/linalg/Makefile.mingw64-cross b/lib/linalg/Makefile.mingw64-cross
deleted file mode 100644
index ee6eef819b7dbf58b5dcaa6cfb5cfef0460eaf0a..0000000000000000000000000000000000000000
--- a/lib/linalg/Makefile.mingw64-cross
+++ /dev/null
@@ -1,67 +0,0 @@
-# -*- makefile -*-
-# *_________________________________________________________________________*
-# *      Minimal BLAS/LAPACK Library for use by other LAMMPS packages
-
-SHELL = /bin/sh
-
-# ------ FILES ------
-
-SRC =	$(wildcard *.f)
-
-FILES = $(SRC) Makefile.* README
-
-# ------ DEFINITIONS ------
-
-DIR = Obj_mingw64/
-LIB = $(DIR)liblinalg.a
-OBJ =   $(SRC:%.f=$(DIR)%.o)
-
-# ------ SETTINGS ------
-
-FC =    	x86_64-w64-mingw32-gfortran
-FFLAGS =	-O3 -march=core2 -mtune=generic -msse2 -mpc64	\
-		-ffast-math -funroll-loops -fstrict-aliasing -Wall -W	\
-		-Wno-uninitialized -fno-second-underscore
-FFLAGS0 =	-O0 -march=core2 -mtune=generic -msse2 -mpc64	\
-		-Wall -W -Wno-uninitialized -fno-second-underscore
-ARCHIVE =	x86_64-w64-mingw32-ar
-AR =		x86_64-w64-mingw32-ar
-ARCHFLAG =	-rcs
-USRLIB =
-SYSLIB =
-
-.PHONY: default clean tar
-
-.SUFFIXES:
-.SUFFIXES: .F .f .o
-
-# ------ MAKE PROCEDURE ------
-
-default: $(DIR) $(LIB)
-
-$(LIB): $(OBJ)
-	$(ARCHIVE) $(ARFLAGS) $(LIB) $(OBJ)
-
-$(DIR):
-	mkdir $(DIR)
-
-# ------ COMPILE RULES ------
-
-$(DIR)%.o:%.F
-	$(F90) $(F90FLAGS) -c $< -o $@
-
-$(DIR)%.o:%.f
-	$(FC) $(FFLAGS) -c $< -o $@
-
-$(DIR)dlamch.o: dlamch.f
-	$(FC) $(FFLAGS0) -c $< -o $@
-
-# ------ CLEAN ------
-
-clean:
-	-rm $(DIR)*.o $(DIR)*.mod *~ $(LIB)
-	-rmdir $(DIR)
-
-tar:
-	-tar -czvf ../linalg.tar.gz $(FILES)
-
diff --git a/lib/linalg/Makefile.mingw64-cross-mpi b/lib/linalg/Makefile.mingw64-cross-mpi
deleted file mode 100644
index ca6f4a6d43226f15bcf0e0a431b20528cfc7ff4b..0000000000000000000000000000000000000000
--- a/lib/linalg/Makefile.mingw64-cross-mpi
+++ /dev/null
@@ -1,13 +0,0 @@
-# -*- makefile -*- wrapper for non-MPI libraries
-
-SHELL=/bin/sh
-
-all:
-	$(MAKE) $(MFLAGS) mingw64-cross
-	-rm -f Obj_mingw64-mpi
-	ln -s Obj_mingw64 Obj_mingw64-mpi
-
-clean:
-	$(MAKE) $(MFLAGS) clean-mingw64-cross
-	-rm -f Obj_mingw64-mpi
-
diff --git a/lib/linalg/Makefile.mpi b/lib/linalg/Makefile.mpi
new file mode 100644
index 0000000000000000000000000000000000000000..dd22ff134caf02e6350304125af4a0420da1cf25
--- /dev/null
+++ b/lib/linalg/Makefile.mpi
@@ -0,0 +1,52 @@
+# -*- makefile -*-
+# *_________________________________________________________________________*
+# *      Minimal BLAS/LAPACK Library for use by other LAMMPS packages
+
+SHELL = /bin/sh
+
+# ------ FILES ------
+
+SRC =	$(wildcard *.f)
+
+FILES = $(SRC) Makefile.* README
+
+# ------ DEFINITIONS ------
+
+LIB = liblinalg.a
+OBJ =   $(SRC:.f=.o)
+
+# ------ SETTINGS ------
+
+FC =          mpifort
+FFLAGS =      -O3 -fPIC
+FFLAGS0 =     -O0 -fPIC
+ARCHIVE =	ar
+AR =	ar
+ARCHFLAG =	-rcs
+USRLIB =
+SYSLIB =
+
+# ------ MAKE PROCEDURE ------
+
+lib: 	$(OBJ)
+	$(ARCHIVE) $(ARFLAGS) $(LIB) $(OBJ)
+
+# ------ COMPILE RULES ------
+
+%.o:%.F
+	$(F90) $(F90FLAGS) -c $<
+
+%.o:%.f
+	$(FC) $(FFLAGS) -c $<
+
+dlamch.o: dlamch.f
+	$(FC) $(FFLAGS0) -c $<
+
+# ------ CLEAN ------
+
+clean:
+	-rm -f *.o *.mod *~ $(LIB)
+
+tar:
+	-tar -czvf ../linalg.tar.gz $(FILES)
+
diff --git a/lib/linalg/Makefile.serial b/lib/linalg/Makefile.serial
new file mode 120000
index 0000000000000000000000000000000000000000..c52fbcb986822e3dfdc79a978a876fb39a762f71
--- /dev/null
+++ b/lib/linalg/Makefile.serial
@@ -0,0 +1 @@
+Makefile.gfortran
\ No newline at end of file
diff --git a/lib/colvars/Makefile.lammps b/lib/meam/Makefile.lammps.empty
similarity index 60%
rename from lib/colvars/Makefile.lammps
rename to lib/meam/Makefile.lammps.empty
index 99f57b050bff35859eed023961d703cfdcb2c8c0..10394b68ad3ae35dda3fde8463195ba72b4cb69f 100644
--- a/lib/colvars/Makefile.lammps
+++ b/lib/meam/Makefile.lammps.empty
@@ -1,5 +1,5 @@
 # Settings that the LAMMPS build will import when this package library is used
 
-colvars_SYSINC =
-colvars_SYSLIB =
-colvars_SYSPATH =
+meam_SYSINC =
+meam_SYSLIB = 
+meam_SYSPATH =
diff --git a/lib/meam/Makefile.mingw32-cross b/lib/meam/Makefile.mingw32-cross
deleted file mode 100644
index d4d2dad09339cfa682e9d908c6402db9449a1670..0000000000000000000000000000000000000000
--- a/lib/meam/Makefile.mingw32-cross
+++ /dev/null
@@ -1,69 +0,0 @@
-# * -*- makefile -*-
-# *_________________________________________________________________________*
-# *      MEAM: MODEFIED EMBEDDED ATOM METHOD                                *
-# *      DESCRIPTION: SEE READ-ME                                           *
-# *      FILE NAME: Makefile                                                *
-# *      AUTHORS: Greg Wagner, Sandia National Laboratories                 * 
-# *      CONTACT: gjwagne@sandia.gov                                        *
-# *_________________________________________________________________________*/
-
-SHELL = /bin/sh
-
-# which file will be copied to Makefile.lammps
-
-EXTRAMAKE = Makefile.lammps.gfortran
-
-# ------ FILES ------
-
-SRC = meam_data.F meam_setup_done.F meam_setup_global.F meam_setup_param.F meam_dens_init.F meam_dens_final.F meam_force.F meam_cleanup.F
-
-FILES = $(SRC) Makefile 
-
-# ------ DEFINITIONS ------
-
-DIR = Obj_mingw32/
-LIB = $(DIR)libmeam.a
-OBJ = $(SRC:%.F=$(DIR)%.o) $(DIR)fm_exp.o
-
-# ------ SETTINGS ------
-
-F90 =           i686-w64-mingw32-gfortran
-F90FLAGS =      -O3 -march=i686 -mtune=generic -mfpmath=387 -mpc64  \
-		-ffast-math -funroll-loops -fstrict-aliasing -J$(DIR) \
-		-Wall -W -Wno-uninitialized -fno-second-underscore
-#F90FLAGS =      -O 
-ARCHIVE =	i686-w64-mingw32-ar
-ARCHFLAG =	-rcs
-LINK =         	i686-w64-mingw32-g++
-LINKFLAGS =	-O
-USRLIB =
-SYSLIB =
-
-# ------ MAKE PROCEDURE ------
-
-default: $(DIR) $(LIB)
-
-$(DIR):
-	-mkdir $(DIR)
-
-$(LIB):  $(OBJ)
-	$(ARCHIVE) $(ARFLAGS) $(LIB) $(OBJ)
-	@cp $(EXTRAMAKE) Makefile.lammps
-
-# ------ COMPILE RULES ------
-
-$(DIR)%.o:%.F
-	$(F90) $(F90FLAGS) -c $< -o $@
-
-$(DIR)%.o:%.c
-	$(F90) $(F90FLAGS) -c $< -o $@
-
-include .depend
-# ------ CLEAN ------
-
-clean:
-	-rm $(DIR)*.o $(DIR)*.mod *~ $(LIB)
-	-rmdir $(DIR)
-
-tar:
-	-tar -cvf ../MEAM.tar $(FILES)
diff --git a/lib/meam/Makefile.mingw32-cross-mpi b/lib/meam/Makefile.mingw32-cross-mpi
deleted file mode 100644
index 1e35c5b46151a9c380a87c3a501bb6a758d2d4eb..0000000000000000000000000000000000000000
--- a/lib/meam/Makefile.mingw32-cross-mpi
+++ /dev/null
@@ -1,13 +0,0 @@
-# -*- makefile -*- wrapper for non-MPI libraries
-
-SHELL=/bin/sh
-
-all:
-	$(MAKE) $(MFLAGS) mingw32-cross
-	-rm -f Obj_mingw32-mpi
-	ln -s Obj_mingw32 Obj_mingw32-mpi
-
-clean:
-	$(MAKE) $(MFLAGS) clean-mingw32-cross
-	-rm -f Obj_mingw32-mpi
-
diff --git a/lib/meam/Makefile.mingw64-cross-mpi b/lib/meam/Makefile.mingw64-cross-mpi
deleted file mode 100644
index ca6f4a6d43226f15bcf0e0a431b20528cfc7ff4b..0000000000000000000000000000000000000000
--- a/lib/meam/Makefile.mingw64-cross-mpi
+++ /dev/null
@@ -1,13 +0,0 @@
-# -*- makefile -*- wrapper for non-MPI libraries
-
-SHELL=/bin/sh
-
-all:
-	$(MAKE) $(MFLAGS) mingw64-cross
-	-rm -f Obj_mingw64-mpi
-	ln -s Obj_mingw64 Obj_mingw64-mpi
-
-clean:
-	$(MAKE) $(MFLAGS) clean-mingw64-cross
-	-rm -f Obj_mingw64-mpi
-
diff --git a/lib/meam/Makefile.mingw64-cross b/lib/meam/Makefile.mpi
similarity index 63%
rename from lib/meam/Makefile.mingw64-cross
rename to lib/meam/Makefile.mpi
index 1a8e97febe2dc3630e889e803ab39e12d730bc7b..fd3dbde5558b6866dd3b870ebd622bb0fa757705 100644
--- a/lib/meam/Makefile.mingw64-cross
+++ b/lib/meam/Makefile.mpi
@@ -1,4 +1,4 @@
-# * -*- makefile -*-
+# *
 # *_________________________________________________________________________*
 # *      MEAM: MODEFIED EMBEDDED ATOM METHOD                                *
 # *      DESCRIPTION: SEE READ-ME                                           *
@@ -11,7 +11,7 @@ SHELL = /bin/sh
 
 # which file will be copied to Makefile.lammps
 
-EXTRAMAKE = Makefile.lammps.gfortran
+EXTRAMAKE = Makefile.lammps.empty
 
 # ------ FILES ------
 
@@ -21,49 +21,41 @@ FILES = $(SRC) Makefile
 
 # ------ DEFINITIONS ------
 
-DIR = Obj_mingw64/
-LIB = $(DIR)libmeam.a
-OBJ = $(SRC:%.F=$(DIR)%.o) $(DIR)fm_exp.o
+LIB = libmeam.a
+OBJ =   $(SRC:.F=.o) fm_exp.o
 
 # ------ SETTINGS ------
 
-F90 =           x86_64-w64-mingw32-gfortran
-F90FLAGS =      -O3 -march=core2 -mtune=core2 -msse2 -mpc64  \
-		-ffast-math -funroll-loops -fstrict-aliasing -J$(DIR) \
-		-Wall -W -Wno-uninitialized -fno-second-underscore
+F90 =           mpifort
+CC  =		mpicc
+F90FLAGS =      -O3 -fPIC
 #F90FLAGS =      -O 
-ARCHIVE =	x86_64-w64-mingw32-ar
-ARCHFLAG =	-rcs
-LINK =         	x86_64-w64-mingw32-g++
+ARCHIVE =	ar
+ARCHFLAG =	-rc
+LINK =         	mpicxx
 LINKFLAGS =	-O
 USRLIB =
 SYSLIB =
 
 # ------ MAKE PROCEDURE ------
 
-default: $(DIR) $(LIB)
-
-$(DIR):
-	-mkdir $(DIR)
-
-$(LIB):  $(OBJ)
+lib: 	$(OBJ)
 	$(ARCHIVE) $(ARFLAGS) $(LIB) $(OBJ)
 	@cp $(EXTRAMAKE) Makefile.lammps
 
 # ------ COMPILE RULES ------
 
-$(DIR)%.o:%.F
-	$(F90) $(F90FLAGS) -c $< -o $@
+%.o:%.F
+	$(F90) $(F90FLAGS) -c $<
 
-$(DIR)%.o:%.c
-	$(F90) $(F90FLAGS) -c $< -o $@
+%.o:%.c
+	$(CC) $(F90FLAGS) -c $<
 
 include .depend
 # ------ CLEAN ------
 
 clean:
-	-rm $(DIR)*.o $(DIR)*.mod *~ $(LIB)
-	-rmdir $(DIR)
+	-rm *.o *.mod *~ $(LIB)
 
 tar:
 	-tar -cvf ../MEAM.tar $(FILES)
diff --git a/lib/meam/Makefile.serial b/lib/meam/Makefile.serial
new file mode 120000
index 0000000000000000000000000000000000000000..c52fbcb986822e3dfdc79a978a876fb39a762f71
--- /dev/null
+++ b/lib/meam/Makefile.serial
@@ -0,0 +1 @@
+Makefile.gfortran
\ No newline at end of file
diff --git a/lib/mscg/.gitignore b/lib/mscg/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..7d45bcb60a974bad8d29a88e15e04c41de049451
--- /dev/null
+++ b/lib/mscg/.gitignore
@@ -0,0 +1,4 @@
+# files to ignore
+/liblink
+/includelink
+/MSCG-release-master
diff --git a/lib/mscg/Install.py b/lib/mscg/Install.py
index 7b10be189fee9b5c60fb84d318dcf388fb510926..e4e5ec5613c2b2f0c290df097b24dea8d257c11c 100644
--- a/lib/mscg/Install.py
+++ b/lib/mscg/Install.py
@@ -3,53 +3,55 @@
 # Install.py tool to download, unpack, build, and link to the MS-CG library
 # used to automate the steps described in the README file in this dir
 
-import sys,os,re,commands
+from __future__ import print_function
+import sys,os,re,subprocess
 
 # help message
 
 help = """
-Syntax from src dir: make lib-mscg args="-h hpath hdir -g -b [suffix] -l"
-Syntax from lib dir: python Install.py -h hpath hdir -g -b [suffix] -l
+Syntax from src dir: make lib-mscg args="-p [path] -m [suffix]"
+                 or: make lib-mscg args="-b -m [suffix]"
+Syntax from lib dir: python Install.py -p [path]  -m [suffix]
+Syntax from lib dir: python Install.py -b -m [suffix]
 
 specify one or more options, order does not matter
 
-  -h = set home dir of MS-CG to be hpath/hdir
-       hpath can be full path, contain '~' or '.' chars
-       default hpath = . = lib/mscg
-       default hdir = MSCG-release-master = what GitHub zipfile unpacks to
-  -g = grab (download) zipfile from MS-CG GitHub website
-       unpack it to hpath/hdir
-       hpath must already exist
-       if hdir already exists, it will be deleted before unpack
-  -b = build MS-CG library in its src dir
-       optional suffix specifies which src/Make/Makefile.suffix to use
+  -b = download and build MS-CG library
+  -p = specify folder of existing MS-CG installation
+  -m = machine suffix specifies which src/Make/Makefile.suffix to use
        default suffix = g++_simple
-  -l = create 2 softlinks (includelink,liblink) in lib/mscg to MS-CG src dir
 
 Example:
 
-make lib-mscg args="-g -b -l"   # download/build in lib/mscg/MSCG-release-master
+make lib-mscg args="-b -m serial " # download/build in lib/mscg/MSCG-release-master with settings compatible with "make serial"
+make lib-mscg args="-b -m mpi " # download/build in lib/mscg/MSCG-release-master with settings compatible with "make mpi"
+make lib-mscg args="-p /usr/local/mscg-release " # use existing MS-CG installation in /usr/local/mscg-release
 """
 
 # settings
 
-url = "https://github.com/uchicago-voth/MSCG-release/archive/master.zip"
-zipfile = "MS-CG-master.zip"
-zipdir = "MSCG-release-master"
+url = "http://github.com/uchicago-voth/MSCG-release/archive/master.tar.gz"
+tarfile = "MS-CG-master.tar.gz"
+tardir = "MSCG-release-master"
 
 # print error message or help
 
 def error(str=None):
-  if not str: print help
-  else: print "ERROR",str
+  if not str: print(help)
+  else: print("ERROR",str)
   sys.exit()
 
 # expand to full path name
 # process leading '~' or relative path
-  
+
 def fullpath(path):
   return os.path.abspath(os.path.expanduser(path))
-  
+
+def geturl(url,fname):
+  cmd = 'curl -L -o "%s" %s' % (fname,url)
+  txt = subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
+  return txt
+
 # parse args
 
 args = sys.argv[1:]
@@ -57,73 +59,93 @@ nargs = len(args)
 if nargs == 0: error()
 
 homepath = "."
-homedir = zipdir
+homedir = tardir
 
-grabflag = 0
-buildflag = 0
+buildflag = False
+pathflag = False
+linkflag = True
 msuffix = "g++_simple"
-linkflag = 0
 
 iarg = 0
 while iarg < nargs:
-  if args[iarg] == "-h":
-    if iarg+3 > nargs: error()
-    homepath = args[iarg+1]
-    homedir = args[iarg+2]
-    iarg += 3
-  elif args[iarg] == "-g":
-    grabflag = 1
-    iarg += 1
+  if args[iarg] == "-p":
+    if iarg+2 > nargs: error()
+    mscgpath = fullpath(args[iarg+1])
+    pathflag = True
+    iarg += 2
+  elif args[iarg] == "-m":
+    if iarg+2 > nargs: error()
+    msuffix = args[iarg+1]
+    iarg += 2
   elif args[iarg] == "-b":
-    buildflag = 1
-    if iarg+1 < nargs and args[iarg+1][0] != '-':
-      msuffix = args[iarg+1]
-      iarg += 1
-    iarg += 1
-  elif args[iarg] == "-l":
-    linkflag = 1
+    buildflag = True
     iarg += 1
   else: error()
 
 homepath = fullpath(homepath)
-if not os.path.isdir(homepath): error("MS-CG path does not exist")
 homedir = "%s/%s" % (homepath,homedir)
 
-# download and unpack MS-CG zipfile
+if (pathflag):
+    if not os.path.isdir(mscgpath): error("MS-CG path does not exist")
+    homedir = mscgpath
+
+if (buildflag and pathflag):
+    error("Cannot use -b and -p flag at the same time")
 
-if grabflag:
-  print "Downloading MS-CG ..."
-  cmd = "curl -L %s > %s/%s" % (url,homepath,zipfile)
-  print cmd
-  print commands.getoutput(cmd)
+if (not buildflag and not pathflag):
+    error("Have to use either -b or -p flag")
 
-  print "Unpacking MS-CG zipfile ..."
-  if os.path.exists("%s/%s" % (homepath,zipdir)):
-    commands.getoutput("rm -rf %s/%s" % (homepath,zipdir))
-  cmd = "cd %s; unzip %s" % (homepath,zipfile)
-  commands.getoutput(cmd)
-  if os.path.basename(homedir) != zipdir:
-    if os.path.exists(homedir): commands.getoutput("rm -rf %s" % homedir)
-    os.rename("%s/%s" % (homepath,zipdir),homedir)
+# download and unpack MS-CG tarfile
+
+if buildflag:
+  print("Downloading MS-CG ...")
+  geturl(url,"%s/%s" % (homepath,tarfile))
+
+  print("Unpacking MS-CG tarfile ...")
+  if os.path.exists("%s/%s" % (homepath,tardir)):
+    cmd = 'rm -rf "%s/%s"' % (homepath,tardir)
+    subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
+  cmd = 'cd "%s"; tar -xzvf %s' % (homepath,tarfile)
+  subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
+  os.remove("%s/%s" % (homepath,tarfile))
+  if os.path.basename(homedir) != tardir:
+    if os.path.exists(homedir):
+      cmd = 'rm -rf "%s"' % homedir
+      subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
+    os.rename("%s/%s" % (homepath,tardir),homedir)
 
 # build MS-CG
 
 if buildflag:
-  print "Building MS-CG ..."
-  cmd = "cd %s/src; cp Make/Makefile.%s .; make -f Makefile.%s" % \
-      (homedir,msuffix,msuffix)
-  txt = commands.getoutput(cmd)
-  print txt
+  print("Building MS-CG ...")
+  if os.path.exists("%s/src/Make/Makefile.%s" % (homedir,msuffix)):
+    cmd = 'cd "%s/src"; cp Make/Makefile.%s .; make -f Makefile.%s' % \
+        (homedir,msuffix,msuffix)
+  elif os.path.exists("Makefile.%s" % msuffix):
+    cmd = 'cd "%s/src"; cp ../../Makefile.%s .; make -f Makefile.%s' % \
+        (homedir,msuffix,msuffix)
+  else:
+    error("Cannot find Makefile.%s" % msuffix)
+  txt = subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
+  print(txt.decode('UTF-8'))
+  if not os.path.exists("Makefile.lammps"):
+    print("Creating Makefile.lammps")
+    if os.path.exists("Makefile.lammps.%s" % msuffix):
+      cmd = 'cp Makefile.lammps.%s Makefile.lammps' % msuffix
+    else:
+      cmd = 'cp Makefile.lammps.default Makefile.lammps'
+    subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
+  else: print("Makefile.lammps exists. Please check its settings")
 
 # create 2 links in lib/mscg to MS-CG src dir
 
 if linkflag:
-  print "Creating links to MS-CG include and lib files"
+  print("Creating links to MS-CG include and lib files")
   if os.path.isfile("includelink") or os.path.islink("includelink"):
     os.remove("includelink")
   if os.path.isfile("liblink") or os.path.islink("liblink"):
     os.remove("liblink")
-  cmd = "ln -s %s/src includelink" % homedir
-  commands.getoutput(cmd)
-  cmd = "ln -s %s/src liblink" % homedir
-  commands.getoutput(cmd)
+  cmd = 'ln -s "%s/src" includelink' % homedir
+  subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
+  cmd = 'ln -s "%s/src" liblink' % homedir
+  subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
diff --git a/lib/mscg/Makefile.lammps.default b/lib/mscg/Makefile.lammps.default
new file mode 100644
index 0000000000000000000000000000000000000000..7f04ff2eac9f96259547736ab12ebfb0734da4cd
--- /dev/null
+++ b/lib/mscg/Makefile.lammps.default
@@ -0,0 +1,5 @@
+# Settings that the LAMMPS build will import when this package library is used
+
+mscg_SYSINC = 
+mscg_SYSLIB =  -lgsl -lgslcblas
+mscg_SYSPATH = 
diff --git a/lib/mscg/Makefile.lammps b/lib/mscg/Makefile.lammps.g++_simple
similarity index 100%
rename from lib/mscg/Makefile.lammps
rename to lib/mscg/Makefile.lammps.g++_simple
diff --git a/lib/mscg/Makefile.lammps.mpi b/lib/mscg/Makefile.lammps.mpi
new file mode 100644
index 0000000000000000000000000000000000000000..7f04ff2eac9f96259547736ab12ebfb0734da4cd
--- /dev/null
+++ b/lib/mscg/Makefile.lammps.mpi
@@ -0,0 +1,5 @@
+# Settings that the LAMMPS build will import when this package library is used
+
+mscg_SYSINC = 
+mscg_SYSLIB =  -lgsl -lgslcblas
+mscg_SYSPATH = 
diff --git a/lib/mscg/Makefile.lammps.serial b/lib/mscg/Makefile.lammps.serial
new file mode 100644
index 0000000000000000000000000000000000000000..7f04ff2eac9f96259547736ab12ebfb0734da4cd
--- /dev/null
+++ b/lib/mscg/Makefile.lammps.serial
@@ -0,0 +1,5 @@
+# Settings that the LAMMPS build will import when this package library is used
+
+mscg_SYSINC = 
+mscg_SYSLIB =  -lgsl -lgslcblas
+mscg_SYSPATH = 
diff --git a/lib/mscg/Makefile.mpi b/lib/mscg/Makefile.mpi
new file mode 100644
index 0000000000000000000000000000000000000000..d5088176b4ba36afc69154b9982ae44b156d6534
--- /dev/null
+++ b/lib/mscg/Makefile.mpi
@@ -0,0 +1,104 @@
+# This Makefile is meant for use after
+# module load gsl/2.2.1+gcc-6.1 
+# module load gcc/6.1
+# It also requires LAPACK
+# Module names refer to those on any of RCC's clusters at UChicago.
+
+# This makefile does NOT include GROMACS reading or MKL (sparse matrix)
+# It uses the gcc/g++ compiler (v4.9+) for C++11 support
+
+# 1) Try this first (as it is the easiest)
+NO_GRO_LIBS    = -lgsl -lgslcblas
+
+# 2) If it does not find your libraries automatically, you can specify them manually
+# # A) Set the GSL_LIB to the location of your GSL library's lib directory (must be V2+)
+GSL_LIB = /software/gsl-2.2.1-el6-x86_64+gcc-6.1/lib
+# # B) Set the LAPACK_DIR to the location of your LAPACK library base directory 
+LAPACK_LIB = $(HOME)/local/lapack-3.7.0
+# # C) Uncomment this next line and then run again (after cleaning up any object files)
+#NO_GRO_LIBS    = -L$(GSL_LIB) -L$(LAPACK_LIB) -lgsl -lgslcblas -llapack -lm  
+
+OPT            = -O2
+NO_GRO_LDFLAGS = $(OPT)
+NO_GRO_CFLAGS  = $(OPT)
+DIMENSION      = 3
+CC             = mpicc
+
+COMMON_SOURCE = control_input.h fm_output.h force_computation.h geometry.h interaction_hashing.h interaction_model.h matrix.h splines.h topology.h trajectory_input.h misc.h mscg.h
+NO_GRO_COMMON_OBJECTS = control_input.o fm_output.o force_computation.o geometry.o interaction_hashing.o interaction_model.o matrix.o splines.o topology.o trajectory_input_no_gro.o misc.o
+
+# Target executables
+# The library for LAMMPS is lib_mscg.a
+libmscg.a: mscg.o $(NO_GRO_COMMON_OBJECTS)
+	ar rvs libmscg.a *.o
+
+newfm_no_gro.x: newfm.o $(NO_GRO_COMMON_OBJECTS)
+	$(CC) $(NO_GRO_LDFLAGS) -o $@ newfm.o $(NO_GRO_COMMON_OBJECTS) -D"_exclude_gromacs=1" $(NO_GRO_LIBS)
+	
+combinefm_no_gro.x: combinefm.o batch_fm_combination.o $(NO_GRO_COMMON_OBJECTS)
+	$(CC) $(NO_GRO_LDFLAGS) -o $@ combinefm.o batch_fm_combination.o $(NO_GRO_COMMON_OBJECTS) -D"_exclude_gromacs=1" $(NO_GRO_LIBS)
+
+rangefinder_no_gro.x: rangefinder.o range_finding.o $(NO_GRO_COMMON_OBJECTS)
+	$(CC) $(NO_GRO_LDFLAGS) -o $@ rangefinder.o range_finding.o $(NO_GRO_COMMON_OBJECTS) -D"_exclude_gromacs=1" $(NO_GRO_LIBS) 
+
+# Target objects
+
+mscg.o: mscg.cpp $(COMMON_SOURCE) range_finding.o
+	$(CC) $(NO_GRO_CFLAGS) -c mscg.cpp -o mscg.o $(NO_GRO_LIBS)
+
+newfm.o: newfm.cpp $(COMMON_SOURCE)
+	$(CC) $(NO_GRO_CFLAGS) -c newfm.cpp
+	
+combinefm.o: combinefm.cpp batch_fm_combination.h $(COMMON_SOURCE)
+	$(CC) $(NO_GRO_CFLAGS) -c combinefm.cpp
+
+rangefinder.o: rangefinder.cpp range_finding.h $(COMMON_SOURCE)
+	$(CC) $(NO_GRO_CFLAGS) -c rangefinder.cpp
+
+scalarfm.o: scalarfm.cpp $(COMMON_SOURCE)
+	$(CC) $(NO_GRO_CFLAGS) -c scalarfm.cpp
+
+batch_fm_combination.o: batch_fm_combination.cpp batch_fm_combination.h external_matrix_routines.h misc.h
+	$(CC) $(NO_GRO_CFLAGS) -c batch_fm_combination.cpp
+
+control_input.o: control_input.cpp control_input.h misc.h
+	$(CC) $(NO_GRO_CFLAGS) -c control_input.cpp
+
+geometry.o: geometry.cpp geometry.h
+	$(CC) $(NO_GRO_CFLAGS) -c geometry.cpp -DDIMENSION=$(DIMENSION)
+
+fm_output.o: fm_output.cpp fm_output.h force_computation.h misc.h
+	$(CC) $(NO_GRO_CFLAGS) -c fm_output.cpp
+
+force_computation.o: force_computation.cpp force_computation.h interaction_model.h matrix.h trajectory_input.h misc.h
+	$(CC) $(NO_GRO_CFLAGS) -c force_computation.cpp -DDIMENSION=$(DIMENSION)
+
+interaction_hashing.o: interaction_hashing.cpp interaction_hashing.h
+	$(CC) $(NO_GRO_CFLAGS) -c interaction_hashing.cpp
+
+interaction_model.o: interaction_model.cpp interaction_model.h control_input.h interaction_hashing.h topology.h misc.h
+	$(CC) $(NO_GRO_CFLAGS) -c interaction_model.cpp -DDIMENSION=$(DIMENSION)
+
+matrix.o: matrix.cpp matrix.h control_input.h external_matrix_routines.h interaction_model.h misc.h
+	$(CC) $(NO_GRO_CFLAGS) -c matrix.cpp -DDIMENSION=$(DIMENSION)
+
+misc.o: misc.cpp misc.h
+	$(CC) $(NO_GRO_CFLAGS) -c misc.cpp
+
+range_finding.o: range_finding.cpp range_finding.h force_computation.h interaction_model.h matrix.h misc.h
+	$(CC) $(NO_GRO_CFLAGS) -c range_finding.cpp -DDIMENSION=$(DIMENSION)
+
+splines.o: splines.cpp splines.h interaction_model.h
+	$(CC) $(NO_GRO_CFLAGS) -c splines.cpp -DDIMENSION=$(DIMENSION)
+
+topology.o: topology.cpp topology.h interaction_model.h misc.h
+	$(CC) $(NO_GRO_CFLAGS) -c topology.cpp -DDIMENSION=$(DIMENSION)
+
+trajectory_input_no_gro.o: trajectory_input.cpp trajectory_input.h control_input.h misc.h
+	$(CC) $(NO_GRO_CFLAGS) -c trajectory_input.cpp -D"_exclude_gromacs=1" -o trajectory_input_no_gro.o
+
+# Other convenient commands
+clean:
+	rm *.[o]
+
+all: libmscg.a newfm_no_gro.x rangefinder_no_gro.x combinefm_no_gro.x
diff --git a/lib/mscg/Makefile.serial b/lib/mscg/Makefile.serial
new file mode 100644
index 0000000000000000000000000000000000000000..4e34706f01b80d0e4cc9117d7d8500d69fbc73e5
--- /dev/null
+++ b/lib/mscg/Makefile.serial
@@ -0,0 +1,104 @@
+# This Makefile is meant for use after
+# module load gsl/2.2.1+gcc-6.1 
+# module load gcc/6.1
+# It also requires LAPACK
+# Module names refer to those on any of RCC's clusters at UChicago.
+
+# This makefile does NOT include GROMACS reading or MKL (sparse matrix)
+# It uses the gcc/g++ compiler (v4.9+) for C++11 support
+
+# 1) Try this first (as it is the easiest)
+NO_GRO_LIBS    = -lgsl -lgslcblas
+
+# 2) If it does not find your libraries automatically, you can specify them manually
+# # A) Set the GSL_LIB to the location of your GSL library's lib directory (must be V2+)
+GSL_LIB = /software/gsl-2.2.1-el6-x86_64+gcc-6.1/lib
+# # B) Set the LAPACK_DIR to the location of your LAPACK library base directory 
+LAPACK_LIB = $(HOME)/local/lapack-3.7.0
+# # C) Uncomment this next line and then run again (after cleaning up any object files)
+#NO_GRO_LIBS    = -L$(GSL_LIB) -L$(LAPACK_LIB) -lgsl -lgslcblas -llapack -lm  
+
+OPT            = -O2
+NO_GRO_LDFLAGS = $(OPT)
+NO_GRO_CFLAGS  = $(OPT)
+DIMENSION      = 3
+CC             = g++
+
+COMMON_SOURCE = control_input.h fm_output.h force_computation.h geometry.h interaction_hashing.h interaction_model.h matrix.h splines.h topology.h trajectory_input.h misc.h mscg.h
+NO_GRO_COMMON_OBJECTS = control_input.o fm_output.o force_computation.o geometry.o interaction_hashing.o interaction_model.o matrix.o splines.o topology.o trajectory_input_no_gro.o misc.o
+
+# Target executables
+# The library for LAMMPS is lib_mscg.a
+libmscg.a: mscg.o $(NO_GRO_COMMON_OBJECTS)
+	ar rvs libmscg.a *.o
+
+newfm_no_gro.x: newfm.o $(NO_GRO_COMMON_OBJECTS)
+	$(CC) $(NO_GRO_LDFLAGS) -o $@ newfm.o $(NO_GRO_COMMON_OBJECTS) -D"_exclude_gromacs=1" $(NO_GRO_LIBS)
+	
+combinefm_no_gro.x: combinefm.o batch_fm_combination.o $(NO_GRO_COMMON_OBJECTS)
+	$(CC) $(NO_GRO_LDFLAGS) -o $@ combinefm.o batch_fm_combination.o $(NO_GRO_COMMON_OBJECTS) -D"_exclude_gromacs=1" $(NO_GRO_LIBS)
+
+rangefinder_no_gro.x: rangefinder.o range_finding.o $(NO_GRO_COMMON_OBJECTS)
+	$(CC) $(NO_GRO_LDFLAGS) -o $@ rangefinder.o range_finding.o $(NO_GRO_COMMON_OBJECTS) -D"_exclude_gromacs=1" $(NO_GRO_LIBS) 
+
+# Target objects
+
+mscg.o: mscg.cpp $(COMMON_SOURCE) range_finding.o
+	$(CC) $(NO_GRO_CFLAGS) -c mscg.cpp -o mscg.o $(NO_GRO_LIBS)
+
+newfm.o: newfm.cpp $(COMMON_SOURCE)
+	$(CC) $(NO_GRO_CFLAGS) -c newfm.cpp
+	
+combinefm.o: combinefm.cpp batch_fm_combination.h $(COMMON_SOURCE)
+	$(CC) $(NO_GRO_CFLAGS) -c combinefm.cpp
+
+rangefinder.o: rangefinder.cpp range_finding.h $(COMMON_SOURCE)
+	$(CC) $(NO_GRO_CFLAGS) -c rangefinder.cpp
+
+scalarfm.o: scalarfm.cpp $(COMMON_SOURCE)
+	$(CC) $(NO_GRO_CFLAGS) -c scalarfm.cpp
+
+batch_fm_combination.o: batch_fm_combination.cpp batch_fm_combination.h external_matrix_routines.h misc.h
+	$(CC) $(NO_GRO_CFLAGS) -c batch_fm_combination.cpp
+
+control_input.o: control_input.cpp control_input.h misc.h
+	$(CC) $(NO_GRO_CFLAGS) -c control_input.cpp
+
+geometry.o: geometry.cpp geometry.h
+	$(CC) $(NO_GRO_CFLAGS) -c geometry.cpp -DDIMENSION=$(DIMENSION)
+
+fm_output.o: fm_output.cpp fm_output.h force_computation.h misc.h
+	$(CC) $(NO_GRO_CFLAGS) -c fm_output.cpp
+
+force_computation.o: force_computation.cpp force_computation.h interaction_model.h matrix.h trajectory_input.h misc.h
+	$(CC) $(NO_GRO_CFLAGS) -c force_computation.cpp -DDIMENSION=$(DIMENSION)
+
+interaction_hashing.o: interaction_hashing.cpp interaction_hashing.h
+	$(CC) $(NO_GRO_CFLAGS) -c interaction_hashing.cpp
+
+interaction_model.o: interaction_model.cpp interaction_model.h control_input.h interaction_hashing.h topology.h misc.h
+	$(CC) $(NO_GRO_CFLAGS) -c interaction_model.cpp -DDIMENSION=$(DIMENSION)
+
+matrix.o: matrix.cpp matrix.h control_input.h external_matrix_routines.h interaction_model.h misc.h
+	$(CC) $(NO_GRO_CFLAGS) -c matrix.cpp -DDIMENSION=$(DIMENSION)
+
+misc.o: misc.cpp misc.h
+	$(CC) $(NO_GRO_CFLAGS) -c misc.cpp
+
+range_finding.o: range_finding.cpp range_finding.h force_computation.h interaction_model.h matrix.h misc.h
+	$(CC) $(NO_GRO_CFLAGS) -c range_finding.cpp -DDIMENSION=$(DIMENSION)
+
+splines.o: splines.cpp splines.h interaction_model.h
+	$(CC) $(NO_GRO_CFLAGS) -c splines.cpp -DDIMENSION=$(DIMENSION)
+
+topology.o: topology.cpp topology.h interaction_model.h misc.h
+	$(CC) $(NO_GRO_CFLAGS) -c topology.cpp -DDIMENSION=$(DIMENSION)
+
+trajectory_input_no_gro.o: trajectory_input.cpp trajectory_input.h control_input.h misc.h
+	$(CC) $(NO_GRO_CFLAGS) -c trajectory_input.cpp -D"_exclude_gromacs=1" -o trajectory_input_no_gro.o
+
+# Other convenient commands
+clean:
+	rm *.[o]
+
+all: libmscg.a newfm_no_gro.x rangefinder_no_gro.x combinefm_no_gro.x
diff --git a/lib/mscg/README b/lib/mscg/README
index b73c8563cd1bc4d76051fcff05acb6c9d4fbaee2..329eebba969629ce734734dbf4bdaa92e1a097de 100755
--- a/lib/mscg/README
+++ b/lib/mscg/README
@@ -6,12 +6,11 @@ The MS-CG library is available at
 https://github.com/uchicago-voth/MSCG-release and was developed by
 Jacob Wagner in Greg Voth's group at the University of Chicago.
 
-This library requires a compiler with C++11 support (e.g., g++ v4.9+),
-LAPACK, and the GNU scientific library (GSL v 2.1+).
+This library requires a the GNU scientific library (GSL v 2.1+).
 
 You can type "make lib-mscg" from the src directory to see help on how
 to download and build this library via make commands, or you can do
-the same thing by typing "python Install.py" from within this
+the same thing by typing "python Install.py -m <machine>" from within this
 directory, or you can do it manually by following the instructions
 below.
 
@@ -21,17 +20,17 @@ You must perform the following steps yourself.
 
 1.  Download MS-CG at https://github.com/uchicago-voth/MSCG-release
     either as a tarball or via SVN, and unpack the tarball either in
-    this /lib/mscg directory or somewhere else on your system.
+    this lib/mscg directory or somewhere else on your system.
+
+2.  Ensure that you have GSL installed and a compiler with support for C++11.
 
-2.  Ensure that you have LAPACK and GSL (or Intel MKL) as well as a compiler
-    with support for C++11.
-    
 3.  Compile MS-CG from within its home directory using your makefile of choice:
-    % make -f Makefile."name" libmscg.a
-	It is recommended that you start with Makefile.g++_simple
-        for most machines
+    % make -f Makefile.<machine> libmscg.a
+    It is recommended that you start with Makefile.g++_simple for
+    most machines. There are also two Makefile with settings matching
+    the "mpi" and "serial" makefiles in the main LAMMPS folder.
 
-4.  There is no need to install MS-CG if you only wish 
+4.  There is no need to install MS-CG system-wide if you only wish
     to use it from LAMMPS.
 
 5.  Create two soft links in this dir (lib/mscg) to the MS-CG src
@@ -43,6 +42,9 @@ You must perform the following steps yourself.
       % ln -s /usr/local/include includelink
       % ln -s /usr/local/lib liblink
 
+6.  Copy a suitable Makefile.lammps.<machine> to Makefile.lammps or
+    copy Makefile.lammps.default to Makefile.lammps and edit as needed.
+
 -----------------
 
 When these steps are complete you can build LAMMPS with the MS-CG
diff --git a/lib/poems/Makefile.g++ b/lib/poems/Makefile.g++
index 54c897a22ccf976adcfd24220e6648fe26e86dc0..afcbc4a01df37268840643042ba6cb7921151c40 100644
--- a/lib/poems/Makefile.g++
+++ b/lib/poems/Makefile.g++
@@ -68,7 +68,7 @@ OBJ =   $(SRC:.cpp=.o)
 # ------ SETTINGS ------
 
 CC =	        g++
-CCFLAGS =       -O -g -fPIC -Wall #-Wno-deprecated
+CCFLAGS =       -O3 -g -fPIC -Wall #-Wno-deprecated
 ARCHIVE =	ar
 ARCHFLAG =	-rc
 DEPFLAGS =      -M
diff --git a/lib/poems/Makefile.mingw32-cross b/lib/poems/Makefile.mingw32-cross
deleted file mode 100644
index 17e81b51f0f1836c4b4a910fca09a8381b4a459d..0000000000000000000000000000000000000000
--- a/lib/poems/Makefile.mingw32-cross
+++ /dev/null
@@ -1,110 +0,0 @@
-# *
-# *_________________________________________________________________________*
-# *      POEMS: PARALLELIZABLE OPEN SOURCE EFFICIENT MULTIBODY SOFTWARE     *
-# *      DESCRIPTION: SEE READ-ME                                           *
-# *      FILE NAME: Makefile                                                *
-# *      AUTHORS: See Author List                                           * 
-# *      GRANTS: See Grants List                                            *
-# *      COPYRIGHT: (C) 2005 by Authors as listed in Author's List          *
-# *      LICENSE: Please see License Agreement                              *
-# *      DOWNLOAD: Free at www.rpi.edu/~anderk5                             *
-# *      ADMINISTRATOR: Prof. Kurt Anderson                                 *
-# *                     Computational Dynamics Lab                          *
-# *                     Rensselaer Polytechnic Institute                    *
-# *                     110 8th St. Troy NY 12180                           * 
-# *      CONTACT:        anderk5@rpi.edu                                    *
-# *_________________________________________________________________________*/
-
-SHELL = /bin/sh
-
-# which file will be copied to Makefile.lammps
-
-EXTRAMAKE = Makefile.lammps.empty
-
-# ------ FILES ------
-
-SRC_MAIN = workspace.cpp system.cpp poemsobject.cpp 
-INC_MAIN = workspace.h system.h poemsobject.h
-
-SRC_BODY =      body.cpp rigidbody.cpp particle.cpp inertialframe.cpp
-INC_BODY =      bodies.h body.h rigidbody.h particle.h inertialframe.h
-
-
-SRC_JOINT =     joint.cpp revolutejoint.cpp prismaticjoint.cpp sphericaljoint.cpp \
-    freebodyjoint.cpp body23joint.cpp mixedjoint.cpp
-INC_JOINT =     joints.h joint.h revolutejoint.h prismaticjoint.h sphericaljoint.h \
-    freebodyjoint.h body23joint.h mixedjoint.h
-
-SRC_POINT =     point.cpp fixedpoint.cpp
-INC_POINT =     points.h point.h fixedpoint.h
-
-SRC_SOLVE = solver.cpp  
-INC_SOLVE = solver.h  
-
-SRC_ORDERN = onsolver.cpp onfunctions.cpp onbody.cpp
-INC_ORDERN = onsolver.h onfunctions.h onbody.h
-
-SRC_MAT =       virtualmatrix.cpp matrix.cpp matrixfun.cpp mat3x3.cpp virtualcolmatrix.cpp \
-    colmatrix.cpp vect3.cpp virtualrowmatrix.cpp rowmatrix.cpp mat6x6.cpp vect6.cpp \
-    fastmatrixops.cpp colmatmap.cpp eulerparameters.cpp vect4.cpp norm.cpp mat4x4.cpp \
-    
-INC_MAT =       matrices.h virtualmatrix.h matrix.h matrixfun.h mat3x3.h virtualcolmatrix.h \
-    colmatrix.h vect3.h virtualrowmatrix.h rowmatrix.h mat6x6.h vect6.h \
-    fastmatrixops.h colmatmap.h eulerparameters.h vect4.h norm.h mat4x4.h 
-
-SRC_MISC = poemstreenode.cpp
-INC_MISC = poemslist.h poemstreenode.h poemstree.h poemsnodelib.h SystemProcessor.h defines.h POEMSChain.h
-
-SRC = $(SRC_MAIN) $(SRC_BODY) $(SRC_JOINT) $(SRC_POINT) $(SRC_SOLVE) $(SRC_ORDERN) $(SRC_MAT) $(SRC_MISC) 
-INC = $(INC_MAIN) $(INC_BODY) $(INC_JOINT) $(INC_POINT) $(INC_SOLVE) $(INC_ORDERN) $(INC_MAT) $(INC_MISC) 
-
-FILES = $(SRC) $(INC) Makefile Authors_List.txt Grants_List.txt POEMS_License.txt README Copyright_Notice
-
-# ------ DEFINITIONS ------
-
-DIR = Obj_mingw32/
-LIB = $(DIR)libpoems.a
-OBJ = $(SRC:%.cpp=$(DIR)%.o)
-
-# ------ SETTINGS ------
-
-CC =	        i686-w64-mingw32-g++
-CCFLAGS =	-O2 -march=i686 -mtune=generic -mfpmath=387 -mpc64	\
-		-ffast-math -funroll-loops -finline-functions -fno-rtti	\
-		-fno-exceptions -fstrict-aliasing \
-		-Wall -W -Wno-uninitialized 
-ARCHIVE =	i686-w64-mingw32-ar
-ARCHFLAG =	-rcs
-DEPFLAGS =      -M
-LINK =         	i686-w64-mingw32-g++
-LINKFLAGS =	-O
-USRLIB =
-SYSLIB =
-
-# ------ MAKE PROCEDURE ------
-
-default: $(DIR) $(LIB)
-
-$(DIR):
-	-mkdir $(DIR)
-
-$(LIB): $(OBJ)
-	$(ARCHIVE) $(ARFLAGS) $(LIB) $(OBJ)
-	@cp $(EXTRAMAKE) Makefile.lammps
-
-# ------ COMPILE RULES ------
-
-$(DIR)%.o:%.cpp
-	$(CC) $(CCFLAGS) -c $< -o $@
-
-# ------ DEPENDENCIES ------
-
-include .depend
-
-# ------ CLEAN ------
-
-clean:
-	-rm $(DIR)*.o $(DIR)*.d *~ $(LIB)
-
-tar:
-	-tar -cvf ../POEMS.tar $(FILES)
diff --git a/lib/poems/Makefile.mingw32-cross-mpi b/lib/poems/Makefile.mingw32-cross-mpi
deleted file mode 100644
index 1e35c5b46151a9c380a87c3a501bb6a758d2d4eb..0000000000000000000000000000000000000000
--- a/lib/poems/Makefile.mingw32-cross-mpi
+++ /dev/null
@@ -1,13 +0,0 @@
-# -*- makefile -*- wrapper for non-MPI libraries
-
-SHELL=/bin/sh
-
-all:
-	$(MAKE) $(MFLAGS) mingw32-cross
-	-rm -f Obj_mingw32-mpi
-	ln -s Obj_mingw32 Obj_mingw32-mpi
-
-clean:
-	$(MAKE) $(MFLAGS) clean-mingw32-cross
-	-rm -f Obj_mingw32-mpi
-
diff --git a/lib/poems/Makefile.mingw64-cross-mpi b/lib/poems/Makefile.mingw64-cross-mpi
deleted file mode 100644
index ca6f4a6d43226f15bcf0e0a431b20528cfc7ff4b..0000000000000000000000000000000000000000
--- a/lib/poems/Makefile.mingw64-cross-mpi
+++ /dev/null
@@ -1,13 +0,0 @@
-# -*- makefile -*- wrapper for non-MPI libraries
-
-SHELL=/bin/sh
-
-all:
-	$(MAKE) $(MFLAGS) mingw64-cross
-	-rm -f Obj_mingw64-mpi
-	ln -s Obj_mingw64 Obj_mingw64-mpi
-
-clean:
-	$(MAKE) $(MFLAGS) clean-mingw64-cross
-	-rm -f Obj_mingw64-mpi
-
diff --git a/lib/poems/Makefile.mingw64-cross b/lib/poems/Makefile.mpi
similarity index 86%
rename from lib/poems/Makefile.mingw64-cross
rename to lib/poems/Makefile.mpi
index 2df43dea947724307d9bac6652c81f2c7823ffba..0f0546419c7215f1c0f060874945317e266d0561 100644
--- a/lib/poems/Makefile.mingw64-cross
+++ b/lib/poems/Makefile.mpi
@@ -62,40 +62,31 @@ FILES = $(SRC) $(INC) Makefile Authors_List.txt Grants_List.txt POEMS_License.tx
 
 # ------ DEFINITIONS ------
 
-DIR = Obj_mingw64/
-LIB = $(DIR)libpoems.a
-OBJ = $(SRC:%.cpp=$(DIR)%.o)
+LIB = libpoems.a
+OBJ =   $(SRC:.cpp=.o)
 
 # ------ SETTINGS ------
 
-CC =	        x86_64-w64-mingw32-g++
-CCFLAGS =	-O2 -march=core2 -mtune=core2 -msse2 -mpc64	\
-		-ffast-math -funroll-loops -finline-functions -fno-rtti	\
-		-fno-exceptions -fstrict-aliasing \
-		-Wall -W -Wno-uninitialized 
-ARCHIVE =	x86_64-w64-mingw32-ar
-ARCHFLAG =	-rcs
+CC =	        mpicxx
+CCFLAGS =       -O3 -g -fPIC -Wall #-Wno-deprecated
+ARCHIVE =	ar
+ARCHFLAG =	-rc
 DEPFLAGS =      -M
-LINK =         	x86_64-w64-mingw32-g++
+LINK =         	mpicxx
 LINKFLAGS =	-O
 USRLIB =
 SYSLIB =
 
 # ------ MAKE PROCEDURE ------
 
-default: $(DIR) $(LIB)
-
-$(DIR):
-	-mkdir $(DIR)
-
-$(LIB): $(OBJ)
+lib: 	$(OBJ)
 	$(ARCHIVE) $(ARFLAGS) $(LIB) $(OBJ)
 	@cp $(EXTRAMAKE) Makefile.lammps
 
 # ------ COMPILE RULES ------
 
-$(DIR)%.o:%.cpp
-	$(CC) $(CCFLAGS) -c $< -o $@
+%.o:%.cpp
+	$(CC) $(CCFLAGS) -c $<
 
 # ------ DEPENDENCIES ------
 
@@ -104,7 +95,7 @@ include .depend
 # ------ CLEAN ------
 
 clean:
-	-rm $(DIR)*.o $(DIR)*.d *~ $(LIB)
+	-rm *.o *.d *~ $(LIB)
 
 tar:
 	-tar -cvf ../POEMS.tar $(FILES)
diff --git a/lib/poems/Makefile.serial b/lib/poems/Makefile.serial
new file mode 120000
index 0000000000000000000000000000000000000000..9d7bb000f9d5074bfe1234ef4c2ade3eea216c31
--- /dev/null
+++ b/lib/poems/Makefile.serial
@@ -0,0 +1 @@
+Makefile.g++
\ No newline at end of file
diff --git a/lib/qmmm/Makefile.mpi b/lib/qmmm/Makefile.mpi
new file mode 100644
index 0000000000000000000000000000000000000000..590b1047f89ac96515061651d1796d372daa7644
--- /dev/null
+++ b/lib/qmmm/Makefile.mpi
@@ -0,0 +1,66 @@
+# -*- Makefile -*- for coupling LAMMPS to PWscf for QM/MM molecular dynamics
+
+# this file will be copied to Makefile.lammps
+EXTRAMAKE = Makefile.lammps.empty
+
+# top level directory of Quantum ESPRESSO 5.4.1 or later
+QETOPDIR=$(HOME)/compile/espresso
+
+# import compiler settings from Quantum ESPRESSO
+sinclude $(QETOPDIR)/make.sys
+
+# FLAGS for c++ OpenMPI 1.8.8 or later when QE was compiled with GNU Fortran 4.x
+MPICXX=mpicxx
+MPICXXFLAGS= -DMPICH_SKIP_MPICXX -DOMPI_SKIP_MPICXX=1 -O2 -g -fPIC\
+	-I../../src -I$(QETOPDIR)/COUPLE/include
+MPILIBS=-fopenmp -lgfortran -ldl -ljpeg -lpng -lz -lmpi_mpifh -lmpi
+
+# location of required libraries
+# part 1: hi-level libraries for building pw.x
+PWOBJS = \
+$(QETOPDIR)/COUPLE/src/libqecouple.a \
+$(QETOPDIR)/PW/src/libpw.a \
+$(QETOPDIR)/Modules/libqemod.a
+# part 2: lo-level libraries for all of Q-E
+LIBOBJS = \
+$(QETOPDIR)/FFTXlib/libqefft.a \
+$(QETOPDIR)/LAXlib/libqela.a   \
+$(QETOPDIR)/clib/clib.a   \
+$(QETOPDIR)/iotk/src/libiotk.a
+
+# part 3: add-on libraries and main library for LAMMPS
+sinclude ../../src/Makefile.package
+LAMMPSCFG = mpi
+LAMMPSLIB = ../../src/liblammps_$(LAMMPSCFG).a
+
+# part 4: local QM/MM library and progams
+SRC=pwqmmm.c libqmmm.c
+OBJ=$(SRC:%.c=%.o)
+
+
+default: libqmmm.a
+
+all : tldeps libqmmm.a pwqmmm.x
+
+pwqmmm.x : pwqmmm.o $(OBJ) $(PWOBJS) $(LIBOBJS) $(LAMMPSLIB)
+	$(MPICXX) $(LDFLAGS) -o $@ $^ $(PKG_PATH) $(PKG_LIB) $(MPILIBS) $(LIBS)
+
+libqmmm.a: libqmmm.o
+	$(AR) $(ARFLAGS) $@ $^
+	@cp $(EXTRAMAKE) Makefile.lammps
+
+%.o: %.c
+	$(MPICXX) -c $(LAMMPSFLAGS) $(MPICXXFLAGS) $< -o $@
+
+tldeps:
+	( cd $(QETOPDIR) ; $(MAKE) $(MFLAGS) couple || exit 1)
+	$(MAKE) -C ../../src $(MFLAGS) $(LAMMPSCFG)
+	$(MAKE) -C ../../src $(MFLAGS) mode=lib $(LAMMPSCFG)
+
+clean :
+	-rm -f *.x *.o *.a *~ *.F90 *.d *.mod *.i *.L
+
+# explicit dependencies
+
+pwqmmm.o: pwqmmm.c libqmmm.h
+libqmmm.o: libqmmm.c libqmmm.h
diff --git a/lib/qmmm/Makefile.serial b/lib/qmmm/Makefile.serial
new file mode 100644
index 0000000000000000000000000000000000000000..f09148279263fc5907be3a55e9df9fae8078c569
--- /dev/null
+++ b/lib/qmmm/Makefile.serial
@@ -0,0 +1,66 @@
+# -*- Makefile -*- for coupling LAMMPS to PWscf for QM/MM molecular dynamics
+
+# this file will be copied to Makefile.lammps
+EXTRAMAKE = Makefile.lammps.empty
+
+# top level directory of Quantum ESPRESSO 5.4.1 or later
+QETOPDIR=$(HOME)/compile/espresso
+
+# import compiler settings from Quantum ESPRESSO
+sinclude $(QETOPDIR)/make.sys
+
+# FLAGS for GNU c++ with STUBS. non-functional for real coupling
+MPICXX=g++
+MPICXXFLAGS= -I../../src/STUBS -O2 -g -fPIC\
+	-I../../src -I$(QETOPDIR)/COUPLE/include
+MPILIBS=-fopenmp -lgfortran -ldl -ljpeg -lpng -lz -lmpi_mpifh -lmpi
+
+# location of required libraries
+# part 1: hi-level libraries for building pw.x
+PWOBJS = \
+$(QETOPDIR)/COUPLE/src/libqecouple.a \
+$(QETOPDIR)/PW/src/libpw.a \
+$(QETOPDIR)/Modules/libqemod.a
+# part 2: lo-level libraries for all of Q-E
+LIBOBJS = \
+$(QETOPDIR)/FFTXlib/libqefft.a \
+$(QETOPDIR)/LAXlib/libqela.a   \
+$(QETOPDIR)/clib/clib.a   \
+$(QETOPDIR)/iotk/src/libiotk.a
+
+# part 3: add-on libraries and main library for LAMMPS
+sinclude ../../src/Makefile.package
+LAMMPSCFG = mpi
+LAMMPSLIB = ../../src/liblammps_$(LAMMPSCFG).a
+
+# part 4: local QM/MM library and progams
+SRC=pwqmmm.c libqmmm.c
+OBJ=$(SRC:%.c=%.o)
+
+
+default: libqmmm.a
+
+all : tldeps libqmmm.a pwqmmm.x
+
+pwqmmm.x : pwqmmm.o $(OBJ) $(PWOBJS) $(LIBOBJS) $(LAMMPSLIB)
+	$(MPICXX) $(LDFLAGS) -o $@ $^ $(PKG_PATH) $(PKG_LIB) $(MPILIBS) $(LIBS)
+
+libqmmm.a: libqmmm.o
+	$(AR) $(ARFLAGS) $@ $^
+	@cp $(EXTRAMAKE) Makefile.lammps
+
+%.o: %.c
+	$(MPICXX) -c $(LAMMPSFLAGS) $(MPICXXFLAGS) $< -o $@
+
+tldeps:
+	( cd $(QETOPDIR) ; $(MAKE) $(MFLAGS) couple || exit 1)
+	$(MAKE) -C ../../src $(MFLAGS) $(LAMMPSCFG)
+	$(MAKE) -C ../../src $(MFLAGS) mode=lib $(LAMMPSCFG)
+
+clean :
+	-rm -f *.x *.o *.a *~ *.F90 *.d *.mod *.i *.L
+
+# explicit dependencies
+
+pwqmmm.o: pwqmmm.c libqmmm.h
+libqmmm.o: libqmmm.c libqmmm.h
diff --git a/lib/reax/Makefile.gfortran b/lib/reax/Makefile.gfortran
index b2b16fcc57cf5faacc2ca5058dfff014ac91dd76..ab423016887a444548529d84c6a32d03fdb5c880 100644
--- a/lib/reax/Makefile.gfortran
+++ b/lib/reax/Makefile.gfortran
@@ -28,7 +28,7 @@ OBJ =   $(SRC:.F=.o)
 # ------ SETTINGS ------
 
 F90 =           gfortran
-F90FLAGS =      -O -fPIC -fno-second-underscore
+F90FLAGS =      -O3 -fPIC -fno-second-underscore
 ARCHIVE =	ar
 ARCHFLAG =	-rc
 USRLIB =
diff --git a/lib/reax/Makefile.lammps.empty b/lib/reax/Makefile.lammps.empty
new file mode 100644
index 0000000000000000000000000000000000000000..758755f3c8064d8b40d3d1af1310bd093a366004
--- /dev/null
+++ b/lib/reax/Makefile.lammps.empty
@@ -0,0 +1,5 @@
+# Settings that the LAMMPS build will import when this package library is used
+
+reax_SYSINC =
+reax_SYSLIB = 
+reax_SYSPATH =
diff --git a/lib/reax/Makefile.mpi b/lib/reax/Makefile.mpi
new file mode 100644
index 0000000000000000000000000000000000000000..142f7e9bc6ffc01a1e18fe12548af8e1b4638564
--- /dev/null
+++ b/lib/reax/Makefile.mpi
@@ -0,0 +1,51 @@
+# *
+# *_________________________________________________________________________*
+# *      Fortran Library for Reactive Force Field                           *
+# *      DESCRIPTION: SEE READ-ME                                           *
+# *      FILE NAME: Makefile                                                *
+# *      CONTRIBUTING AUTHORS: Hansohl Cho(MIT), Aidan Thompson(SNL)        *
+# *                            and Greg Wagner(SNL)                         * 
+# *      CONTACT: hansohl@mit.edu, athompson@sandia.gov, gjwagne@sandia.gov *
+# *_________________________________________________________________________*/
+
+SHELL = /bin/sh
+
+# which file will be copied to Makefile.lammps
+
+EXTRAMAKE = Makefile.lammps.empty
+
+# ------ FILES ------
+
+SRC = reax_connect.F reax_inout.F reax_lammps.F reax_poten.F reax_reac.F reax_charges.F
+
+HEADERFILES = reax_defs.h *.blk 
+
+# ------ DEFINITIONS ------
+
+LIB = libreax.a
+OBJ =   $(SRC:.F=.o)
+
+# ------ SETTINGS ------
+
+F90 =           mpifort
+F90FLAGS =      -O3 -fPIC
+ARCHIVE =	ar
+ARCHFLAG =	-rc
+USRLIB =
+SYSLIB =
+
+# ------ MAKE PROCEDURE ------
+
+lib: 	$(OBJ)
+	$(ARCHIVE) $(ARFLAGS) $(LIB) $(OBJ)
+	@cp $(EXTRAMAKE) Makefile.lammps
+
+# ------ COMPILE RULES ------
+
+%.o:%.F $(HEADERFILES)
+	$(F90) $(F90FLAGS) -c $<
+
+# ------ CLEAN ------
+
+clean:
+	-rm *.o $(LIB)
diff --git a/lib/reax/Makefile.serial b/lib/reax/Makefile.serial
new file mode 120000
index 0000000000000000000000000000000000000000..c52fbcb986822e3dfdc79a978a876fb39a762f71
--- /dev/null
+++ b/lib/reax/Makefile.serial
@@ -0,0 +1 @@
+Makefile.gfortran
\ No newline at end of file
diff --git a/lib/smd/Install.py b/lib/smd/Install.py
index 337f993be5d192623996aa2f1cf361f0ff54eba2..1c270bea5e8e824f3671044dfcef64666c38ebb1 100644
--- a/lib/smd/Install.py
+++ b/lib/smd/Install.py
@@ -5,22 +5,20 @@
 
 from __future__ import print_function
 import sys,os,re,glob,subprocess
-try: from urllib.request import urlretrieve as geturl
-except: from urllib import urlretrieve as geturl
 
 # help message
 
 help = """
-Syntax from src dir: make lib-smd
+Syntax from src dir: make lib-smd args="-b"
                  or: make lib-smd args="-p /usr/include/eigen3"
 
-Syntax from lib dir: python Install.py
+Syntax from lib dir: python Install.py -b
                  or: python Install.py -p /usr/include/eigen3"
                  or: python Install.py -v 3.3.4 -b
 
 specify one or more options, order does not matter
 
-  -b = download and unpack/configure the Eigen library (default)
+  -b = download and unpack/configure the Eigen library
   -p = specify folder holding an existing installation of Eigen
   -v = set version of Eigen library to download and set up (default = 3.3.4)
 
@@ -28,6 +26,7 @@ specify one or more options, order does not matter
 Example:
 
 make lib-smd args="-b"   # download/build in default lib/smd/eigen-eigen-*
+make lib-smd args="-p /usr/include/eigen3" # use existing Eigen installation in /usr/include/eigen3
 """
 
 # settings
@@ -48,16 +47,21 @@ def error(str=None):
 def fullpath(path):
   return os.path.abspath(os.path.expanduser(path))
 
+def geturl(url,fname):
+  cmd = 'curl -L -o "%s" %s' % (fname,url)
+  txt = subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
+  return txt
+
 # parse args
 
 args = sys.argv[1:]
 nargs = len(args)
+if nargs == 0: error()
 
 homepath = "."
 homedir = "eigen3"
 
-grabflag = True
-buildflag = True
+buildflag = False
 pathflag = False
 linkflag = True
 
@@ -71,7 +75,6 @@ while iarg < nargs:
     if iarg+2 > nargs: error()
     eigenpath = fullpath(args[iarg+1])
     pathflag = True
-    buildflag = False
     iarg += 2
   elif args[iarg] == "-b":
     buildflag = True
@@ -86,6 +89,9 @@ if (pathflag):
 if (buildflag and pathflag):
     error("Cannot use -b and -p flag at the same time")
 
+if (not buildflag and not pathflag):
+    error("Have to use either -b or -p flag")
+
 # download and unpack Eigen tarball
 # use glob to find name of dir it unpacks to
 
@@ -98,7 +104,7 @@ if buildflag:
   edir = glob.glob("%s/eigen-eigen-*" % homepath)
   for one in edir:
     if os.path.isdir(one):
-      subprocess.check_output("rm -rf %s" % one,stderr=subprocess.STDOUT,shell=True)
+      subprocess.check_output('rm -rf "%s"' % one,stderr=subprocess.STDOUT,shell=True)
   cmd = 'cd "%s"; tar -xzvf %s' % (homepath,tarball)
   subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
   edir = glob.glob("%s/eigen-eigen-*" % homepath)
@@ -113,5 +119,5 @@ if linkflag:
     os.remove("includelink")
   if pathflag: linkdir = eigenpath
   else: linkdir = "%s/%s" % (homepath,homedir)
-  cmd = "ln -s %s includelink" % linkdir
+  cmd = 'ln -s "%s" includelink' % linkdir
   subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
diff --git a/lib/smd/Makefile.lammps b/lib/smd/Makefile.lammps
index 7bbf3924ef933076644c6c30c65871fcf2875cb0..6951a1394cfe928a4aa0fc6ac96281fd6d20d3db 100644
--- a/lib/smd/Makefile.lammps
+++ b/lib/smd/Makefile.lammps
@@ -1,5 +1,5 @@
 # Settings that the LAMMPS build will import when this package library is used
 
-user-smd_SYSINC = 
+user-smd_SYSINC = -I../../lib/includelink/eigen3
 user-smd_SYSLIB = 
 user-smd_SYSPATH = 
diff --git a/lib/voronoi/Install.py b/lib/voronoi/Install.py
index 17bba5e8eb5cdfe0e0cd013c74433c894c4f4038..5a246bbeb18a9b340d187b6b87495511bf8169a2 100644
--- a/lib/voronoi/Install.py
+++ b/lib/voronoi/Install.py
@@ -5,28 +5,27 @@
 
 from __future__ import print_function
 import sys,os,re,subprocess
-try: from urllib.request import urlretrieve as geturl
-except: from urllib import urlretrieve as geturl
 
 # help message
 
 help = """
-Syntax from src dir: make lib-voronoi
+Syntax from src dir: make lib-voronoi args="-b"
                  or: make lib-voronoi args="-p /usr/local/voro++-0.4.6"
-                 or: make lib-voronoi args="-v voro++-0.4.6 -b"
-Syntax from lib dir: python Install.py -v voro++-0.4.6 -b
-                 or: python Install.py
+                 or: make lib-voronoi args="-b -v voro++-0.4.6"
+Syntax from lib dir: python Install.py -b -v voro++-0.4.6
+                 or: python Install.py -b
                  or: python Install.py -p /usr/local/voro++-0.4.6
 
 specify one or more options, order does not matter
 
-  -b = download and build the Voro++ library (default)
-  -p = specify folder of existing Voro++ installation 
+  -b = download and build the Voro++ library
+  -p = specify folder of existing Voro++ installation
   -v = set version of Voro++ to download and build (default voro++-0.4.6)
 
 Example:
 
 make lib-voronoi args="-b"   # download/build in lib/voronoi/voro++-0.4.6
+make lib-voronoi args="-p $HOME/voro++-0.4.6" # use existing Voro++ installation in $HOME/voro++-0.4.6
 """
 
 # settings
@@ -47,16 +46,21 @@ def error(str=None):
 def fullpath(path):
   return os.path.abspath(os.path.expanduser(path))
 
+def geturl(url,fname):
+  cmd = 'curl -L -o "%s" %s' % (fname,url)
+  txt = subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
+  return txt
+
 # parse args
 
 args = sys.argv[1:]
 nargs = len(args)
+if nargs == 0: error()
 
 homepath = "."
 homedir = version
 
-grabflag = True
-buildflag = True
+buildflag = False
 pathflag = False
 linkflag = True
 
@@ -70,7 +74,6 @@ while iarg < nargs:
     if iarg+2 > nargs: error()
     voropath = fullpath(args[iarg+1])
     pathflag = True
-    buildflag = False
     iarg += 2
   elif args[iarg] == "-b":
     buildflag = True
@@ -87,9 +90,12 @@ if (pathflag):
 if (buildflag and pathflag):
     error("Cannot use -b and -p flag at the same time")
 
+if (not buildflag and not pathflag):
+    error("Have to use either -b or -p flag")
+
 # download and unpack Voro++ tarball
 
-if grabflag:
+if buildflag:
   print("Downloading Voro++ ...")
   geturl(url,"%s/%s.tar.gz" % (homepath,version))
 
@@ -122,7 +128,7 @@ if linkflag:
     os.remove("includelink")
   if os.path.isfile("liblink") or os.path.islink("liblink"):
     os.remove("liblink")
-  cmd = ['ln -s "%s/src" includelink' % homedir, 'includelink']
+  cmd = 'ln -s "%s/src" includelink' % homedir
   subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
-  cmd = ['ln -s "%s/src" liblink' % homedir]
+  cmd = 'ln -s "%s/src" liblink' % homedir
   subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
diff --git a/src/MSCG/fix_mscg.cpp b/src/MSCG/fix_mscg.cpp
index b5bfa926a107310f414d28a39b74ab63fba8f481..fba198c814c77b2cf5585fd7e73f8311a271b4ae 100644
--- a/src/MSCG/fix_mscg.cpp
+++ b/src/MSCG/fix_mscg.cpp
@@ -19,6 +19,7 @@
 #include <string.h>
 #include <stdlib.h>
 #include "fix_mscg.h"
+#include "mscg.h"
 #include "atom.h"
 #include "domain.h"
 #include "error.h"
diff --git a/src/MSCG/fix_mscg.h b/src/MSCG/fix_mscg.h
index f6dcf4f0f6f6a4b3ac69ef5f30594a3279e67abb..2c235d436a46300e6ac86f73c69a87ad3442d7c7 100644
--- a/src/MSCG/fix_mscg.h
+++ b/src/MSCG/fix_mscg.h
@@ -21,7 +21,6 @@ FixStyle(mscg,FixMSCG)
 #define LMP_FIX_MSCG_H
 
 #include "fix.h"
-#include "mscg.h"
 
 namespace LAMMPS_NS {
 
diff --git a/src/Makefile b/src/Makefile
index 3d1085e0be5c0a5bda16580dc60a0a6ce5474f8c..7dfc2c312aafe24337c7645e9e399eed2d05f0c9 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -224,7 +224,7 @@ mpi-stubs:
 	@cd STUBS; $(MAKE) clean; $(MAKE)
 
 # install LAMMPS shared lib and Python wrapper for Python usage
-# include python package settings to 
+# include python package settings to
 #   automatically adapt name of python interpreter
 
 sinclude ../lib/python/Makefile.lammps
@@ -343,10 +343,10 @@ no-%:
 lib-%:
 	@if [ -e ../lib/$(LIBDIR)/Install.py ]; then \
 	  echo "Installing lib $(@:lib-%=%)"; \
-	  cd ../lib/$(LIBDIR); python Install.py $(args); \
+	  cd ../lib/$(LIBDIR); $(PYTHON) Install.py $(args); \
 	elif [ -e ../lib/$(LIBUSERDIR)/Install.py ]; then \
 	  echo "Installing lib $(@:lib-user-%=%)"; \
-	  cd ../lib/$(LIBUSERDIR); python Install.py $(args); \
+	  cd ../lib/$(LIBUSERDIR); $(PYTHON) Install.py $(args); \
 	else \
 	  echo "Install script for lib $(@:lib-%=%) does not exist"; \
 	fi;