diff --git AmberTools/src/pbsa/Makefile AmberTools/src/pbsa/Makefile
index 0a3f12f..9bec290 100644
--- AmberTools/src/pbsa/Makefile
+++ AmberTools/src/pbsa/Makefile
@@ -33,8 +33,8 @@ SRC=\
 	dcopy.F90  dhels.F90   dorth.F90  ds2y.F90    dslugm.F90  dsmv.F90    qs2i1d.F90 \
 	d1mach.F90  fdump.F90   i1mach.F90  j4save.F90  xercnt.F90  xerhlt.F90  xermsg.F90  xerprn.F90  xersve.F90  xgetua.F90 \
         bicg.F90 dbcg.F90 dslui4.F90 dsluti.F90 dsmtv.F90 dslubc.F90 isdbcg.F90 \
-        pb_chkfrc.F90 svdcmp.F90 svbksb.F90 pythag.F90 fftw3.F90\
-	pb_augdrv.F90  gmresX.F90 interpX.F90 matvec3.F90 gen_dx_file.F90 aug_iccg.F90 membrane.F90
+        pb_chkfrc.F90 svdcmp.F90 svbksb.F90 pythag.F90 fftw3.F90 memory_module.F90 \
+	pb_augdrv.F90  gmresX.F90 interpX.F90 matvec3.F90 gen_dx_file.F90 aug_iccg.F90 membrane.F90 parms.F90
 
 OBJ=\
 	dsvdc.o  pbsa.o pb_read.o pb_write.o getcoor.o \
@@ -55,7 +55,7 @@ OBJ=\
 	bicg.o dbcg.o dslui4.o dsluti.o dsmtv.o dslubc.o isdbcg.o \
         pb_chkfrc.o svdcmp.o svbksb.o pythag.o\
         pb_augdrv.o gmresX.o interpX.o matvec3.o gen_dx_file.o \
-        aug_iccg.o membrane.o fftw3.o
+        aug_iccg.o membrane.o fftw3.o parms.o memory_module.o
 
 LIBPBSAOBJS= \
 	interface.o pbsaapi.LIBPBSA.o   myopen.o    pb_read.LIBPBSA.o pb_force.LIBPBSA.o \
@@ -76,8 +76,9 @@ LIBPBSAOBJS= \
 	isdbcg.o    qs2i1d.o    xermsg.o    d1mach.o          xercnt.o \
 	xerhlt.o    drlcal.o    j4save.o    isdgmr.o          fdump.o \
 	xerprn.o    dorth.o     dhels.o     xersve.o          dheqr.o \
-	i1mach.o    xgetua.o    dxlcal.o    fftw3.LIBPBSA.o\
-        svdcmp.o    svbksb.o    pythag.o aug_iccg.o gen_dx_file.LIBPBSA.o membrane.LIBPBSA.o
+	i1mach.o    xgetua.o    dxlcal.o    fftw3.LIBPBSA.o memory_module.o \
+        svdcmp.o    svbksb.o    pythag.o aug_iccg.o gen_dx_file.LIBPBSA.o membrane.LIBPBSA.o \
+	parms.LIBPBSA.o
 
 SANDERPBSAOBJS= dsvdc.o sa_driver.SANDER.o pb_nlsolver.o \
         pb_lsolver.o aug_iccg.o pb_force.SANDER.o np_force.SANDER.o \
@@ -95,7 +96,8 @@ SANDERPBSAOBJS= dsvdc.o sa_driver.SANDER.o pb_nlsolver.o \
         qs2i1d.o d1mach.o fdump.o  i1mach.o j4save.o xercnt.o xerhlt.o \
         xermsg.o xerprn.o xersve.o xgetua.o \
         bicg.o   dbcg.o   dslui4.o dsluti.o dsmtv.o  dslubc.o isdbcg.o \
-	svdcmp.o svbksb.o pythag.o gen_dx_file.SANDER.o membrane.SANDER.o
+	svdcmp.o svbksb.o pythag.o gen_dx_file.SANDER.o membrane.SANDER.o \
+	memory_module.SANDER.o
 
 install: install.$(INSTALLTYPE)
 
diff --git AmberTools/src/pbsa/debug.F90 AmberTools/src/pbsa/debug.F90
index 74bd0ca..c5b32a1 100644
--- AmberTools/src/pbsa/debug.F90
+++ AmberTools/src/pbsa/debug.F90
@@ -90,10 +90,12 @@ end subroutine load_debug
 !+ [Enter a one-line description of subroutine debug_frc here]
 subroutine debug_frc(xx,ix,ih,ipairs,x,f, &
       cn1,cn2,r_stack,i_stack)
+   
+   use memory_module
+
    implicit none
 #  include "flocntrl.h"
 #  include "debug.h"
-#  include "memory.h"
 #  include "extra.h"
 #  include "md.h"
    _REAL_ xx(*),x(*),f(3,*)
@@ -262,9 +264,11 @@ end subroutine crd_rst
 !+ [Enter a one-line description of subroutine get_analfrc here]
 subroutine get_analfrc(xx,ix,ih,ipairs,x,f, &
       vir,ene,r_stack,i_stack)
+
+   use memory_module
+
    implicit none
    character(kind=1,len=11) :: routine="get_analfrc"
-#  include "memory.h"
 #  include "md.h"
    _REAL_ xx(*),x(*),f(3,*), &
          ene(*),vir(*),r_stack(*)
@@ -303,8 +307,10 @@ end subroutine fix_xr
 !+ [Enter a one-line description of subroutine get_numfrc here]
 subroutine get_numfrc(xx,ix,ih,ipairs,x,f, &
       vir,ene,atomn,del,apfrc,r_stack,i_stack)
+   
+   use memory_module
+
    implicit none
-#  include "memory.h"
 #  include "md.h"
 
    _REAL_ xx(*),x(*),f(*), &
diff --git AmberTools/src/pbsa/decomp.F90 AmberTools/src/pbsa/decomp.F90
index 251b47f..a4605aa 100644
--- AmberTools/src/pbsa/decomp.F90
+++ AmberTools/src/pbsa/decomp.F90
@@ -182,6 +182,8 @@ subroutine decpair(nty,nat1,nat2,fval)
    ! Holger Gohlke
    !   12.11.2001
    
+   use memory_module, only : nres, npdec
+
    implicit none
    
    _REAL_  fval,hfval
@@ -196,7 +198,6 @@ subroutine decpair(nty,nat1,nat2,fval)
    logical isprot1, isprot2
    logical pairwise
 
-#include "memory.h"
    ! mjhsieh: warnings eliminator
    nssel = -1; nsdir = -1; nsind = -1
    nbsel = -1; nbind = -1; nbdir = -1
@@ -371,6 +372,8 @@ subroutine decangle(nat1,nat2,nat3,fval)
    ! Holger Gohlke
    !   12.11.2001
    
+   use memory_module, only : nres
+
    implicit none
    
    _REAL_  fval,hfval
@@ -381,8 +384,6 @@ subroutine decangle(nat1,nat2,nat3,fval)
    integer nssel, nsind, nsdir
    integer nbsel, nbind, nbdir
 
-#include "memory.h"
-
    hfval = 0.3333333333333333334d0 * fval
    nssel = ndecind(sideintsel)
    nsind = ndecind(sideintind)
@@ -494,6 +495,8 @@ subroutine decphi(nat1,nat2,nat3,nat4,fval)
    ! Holger Gohlke
    !   12.11.2001
    
+   use memory_module, only : nres
+
    implicit none
    
    _REAL_  fval,hfval
@@ -504,8 +507,6 @@ subroutine decphi(nat1,nat2,nat3,nat4,fval)
    integer nssel, nsind, nsdir
    integer nbsel, nbind, nbdir
 
-#include "memory.h"
-
    hfval = 0.25d0 * fval
    nssel = ndecind(sideintsel)
    nsind = ndecind(sideintind)
@@ -642,6 +643,8 @@ subroutine decsasa(nty,nat1,nat2,nat3,fval)
    ! Holger Gohlke
    !   12.11.2001
    
+   use memory_module, only : npdec, nres
+
    implicit none
    
    _REAL_  fval,hfval,addfval
@@ -656,7 +659,6 @@ subroutine decsasa(nty,nat1,nat2,nat3,fval)
    integer nssel, nsind, nsdir
    integer nbsel, nbind, nbdir
 
-#include "memory.h"
    ! mjhsieh: warning eliminator
    ntype = -1; nres3 = -1; isprot3 = .false.
    addfval = -1; nind3 = -1; nind1 = -1
@@ -866,6 +868,8 @@ subroutine checkdec(idecomp)
    ! Holger Gohlke
    !   13.11.2001
    
+   use memory_module, only : npdec, nres
+
    implicit none
    
    integer, intent(in) :: idecomp
@@ -887,8 +891,6 @@ subroutine checkdec(idecomp)
          nbeelsel, nbeelind, nbeeldir, nbpolsel, nbpolind, &
          nbpoldir, nbsassel, nbsasind, nbsasdir
 
-#include "memory.h"
-   
    nsintsel = ndecind(sideintsel)
    nsintind = ndecind(sideintind)
    nsvdwsel = ndecind(sidevdwsel)
@@ -1091,6 +1093,8 @@ subroutine printdec(ix)
    ! Holger Gohlke
    !   13.11.2001
    
+   use memory_module, only : i02, ibellygp, nres
+
    implicit none
    
    _REAL_  energy
@@ -1103,8 +1107,6 @@ subroutine printdec(ix)
    dimension nssel(5), nsind(5), nsdir(5)
    dimension nbsel(5), nbind(5), nbdir(5)
    
-#  include "memory.h"
-   
    ipresst  = i02
    igst     = ibellygp
 
@@ -1228,6 +1230,8 @@ subroutine printpdec(ix)
    ! Holger Gohlke
    !   29.11.2001
    
+   use memory_module, only : i02, ibellygp, npdec, nres
+
    implicit none
    
    _REAL_  energy
@@ -1241,8 +1245,6 @@ subroutine printpdec(ix)
    dimension nssel(5), nsind(5), nsdir(5)
    dimension nbsel(5), nbind(5), nbdir(5)
    
-#  include "memory.h"
-   
    ipresst  = i02
    igst     = ibellygp
 
diff --git AmberTools/src/pbsa/depend AmberTools/src/pbsa/depend
index 83abf99..884c16d 100644
--- AmberTools/src/pbsa/depend
+++ AmberTools/src/pbsa/depend
@@ -26,13 +26,13 @@ debug.o: \
                     flocntrl.h\
                     debug.h\
                     md.h\
-                    memory.h\
+                    memory_module.o\
                     extra.h
 
 decomp.o: \
                     copyright.h\
                     ../include/dprec.fh\
-                    memory.h
+                    memory_module.o
 
 dsvdc.o: \
                     ../include/dprec.fh
@@ -50,12 +50,12 @@ force.o: \
                     pb_force.o\
                     np_force.o\
                     timer.o\
+                    parms.o\
+                    memory_module.o\
                     pb_constants.h\
                     timer.h\
                     md.h\
                     box.h\
-                    memory.h\
-                    parms.h\
                     files.h\
                     flocntrl.h\
                     pb_md.h
@@ -114,8 +114,8 @@ jumps.o: \
 locmem.o: \
                     copyright.h\
                     ../include/dprec.fh\
+                    memory_module.o\
                     box.h\
-                    memory.h\
                     md.h\
                     dynph.h
 
@@ -136,6 +136,13 @@ membrane.LIBPBSA.o: \
                     ../include/dprec.fh\
                     pb_force.LIBPBSA.o\
                     pb_constants.h
+memory_module.o: \
+                    memory.h\
+                    parallel.h
+
+memory_module.SANDER.o: \
+                    memory.h\
+                    parallel.h
 miniop.o: \
                     ../include/dprec.fh
 
@@ -185,6 +192,25 @@ np_force.LIBPBSA.o: \
                     box.h\
                     pb_constants.h\
                     flocntrl.h
+parms.o: \
+                    copyright.h\
+                    ../include/dprec.fh\
+                    memory_module.o\
+                    extra.h\
+                    parallel.h
+
+parms.SANDER.o: \
+                    copyright.h\
+                    ../include/dprec.fh\
+                    memory_module.SANDER.o\
+                    extra.h\
+                    parallel.h
+parms.LIBPBSA.o: \
+                    copyright.h\
+                    ../include/dprec.fh\
+                    memory_module.o\
+                    extra.h\
+                    parallel.h
 pb_augdrv.o: \
                     copyright.h\
                     ../include/dprec.fh\
@@ -194,12 +220,12 @@ pb_augdrv.o: \
 pb_chkfrc.o: \
                     copyright.h\
                     ../include/dprec.fh\
+                    memory_module.o\
                     pb_force.o\
                     pb_constants.h\
                     ../lib/random.h\
                     md.h\
-                    pb_md.h\
-                    memory.h
+                    pb_md.h
 
 pb_direct.o: \
                     copyright.h\
@@ -353,9 +379,8 @@ pb_init.o: \
                     md.h\
                     ../../../src/sander/box.h\
                     box.h\
+                    parms.o\
                     np_force.o\
-                    ../../../src/sander/md.h\
-                    parms.h\
                     pb_md.h
 
 pb_init.SANDER.o: \
@@ -367,9 +392,8 @@ pb_init.SANDER.o: \
                     md.h\
                     ../../../src/sander/box.h\
                     box.h\
+                    parms.SANDER.o\
                     np_force.SANDER.o\
-                    ../../../src/sander/md.h\
-                    parms.h\
                     pb_md.h
 pb_init.LIBPBSA.o: \
                     copyright.h\
@@ -380,9 +404,8 @@ pb_init.LIBPBSA.o: \
                     md.h\
                     ../../../src/sander/box.h\
                     box.h\
+                    parms.LIBPBSA.o\
                     np_force.LIBPBSA.o\
-                    ../../../src/sander/md.h\
-                    parms.h\
                     pb_md.h
 pb_list.o: \
                     copyright.h\
@@ -433,12 +456,11 @@ pb_nlsolver.o: \
 pb_read.o: \
                     copyright.h\
                     ../include/dprec.fh\
+                    memory_module.o\
                     pb_constants.h\
                     files.h\
                     box.h\
                     md.h\
-                    memory.h\
-                    parms.h\
                     decomp.o\
                     pb_force.o\
                     np_force.o\
@@ -449,12 +471,11 @@ pb_read.o: \
 pb_read.SANDER.o: \
                     copyright.h\
                     ../include/dprec.fh\
+                    memory_module.SANDER.o\
                     pb_constants.h\
                     files.h\
                     box.h\
                     md.h\
-                    memory.h\
-                    parms.h\
                     decomp.o\
                     pb_force.SANDER.o\
                     np_force.SANDER.o\
@@ -464,12 +485,11 @@ pb_read.SANDER.o: \
 pb_read.LIBPBSA.o: \
                     copyright.h\
                     ../include/dprec.fh\
+                    memory_module.o\
                     pb_constants.h\
                     files.h\
                     box.h\
                     md.h\
-                    memory.h\
-                    parms.h\
                     decomp.o\
                     pb_force.LIBPBSA.o\
                     np_force.LIBPBSA.o\
@@ -518,16 +538,16 @@ pbsa.o: \
                     parallel.h\
                     timer.o\
                     decomp.o\
-                    memory.h\
+                    memory_module.o\
+                    parms.o\
                     box.h\
                     md.h\
-                    parms.h\
                     timer.h
 
 pbsaapi.o: \
                     copyright.h\
                     ../include/dprec.fh\
-                    parms.h\
+                    parms.o\
                     md.h\
                     pb_md.h\
                     flocntrl.h\
@@ -538,7 +558,7 @@ pbsaapi.o: \
 pbsaapi.LIBPBSA.o: \
                     copyright.h\
                     ../include/dprec.fh\
-                    parms.h\
+                    parms.LIBPBSA.o\
                     md.h\
                     pb_md.h\
                     flocntrl.h\
@@ -580,9 +600,9 @@ qld.o: \
 rdparm.o: \
                     copyright.h\
                     ../include/dprec.fh\
+                    memory_module.o\
+                    parms.o\
                     md.h\
-                    memory.h\
-                    parms.h\
                     files.h\
                     box.h
 
@@ -600,25 +620,24 @@ rgroup.o: \
 runmd.o: \
                     copyright.h\
                     ../include/dprec.fh\
+                    memory_module.o\
                     files.h\
                     md.h\
                     box.h\
-                    memory.h\
                     extra.h\
                     timer.h\
                     pb_constants.h\
                     pb_md.h\
-                    parms.h\
                     parallel.h
 
 runmin.o: \
                     copyright.h\
                     ../include/dprec.fh\
+                    memory_module.o\
                     pb_constants.h\
                     md.h\
                     box.h\
                     files.h\
-                    memory.h\
                     pb_md.h\
                     extra.h\
                     parallel.h
diff --git AmberTools/src/pbsa/force.F90 AmberTools/src/pbsa/force.F90
index e5d93d0..7f15ca0 100644
--- AmberTools/src/pbsa/force.F90
+++ AmberTools/src/pbsa/force.F90
@@ -11,6 +11,8 @@ subroutine force(xx,ix,ih,ipairs,x,f,ener,vir,r_stack,i_stack, &
    use poisson_boltzmann, only : pb_force
    use dispersion_cavity, only : npopt, np_force
    use pbtimer_module
+   use parms, only : cn1, cn2
+   use memory_module
 
    implicit none
    logical do_list_update
@@ -24,8 +26,6 @@ subroutine force(xx,ix,ih,ipairs,x,f,ener,vir,r_stack,i_stack, &
 #  include "timer.h"
 #  include "md.h"
 #  include "box.h"
-#  include "memory.h"
-#  include "parms.h"
 #  include "files.h"
 #  include "flocntrl.h"
 #  include "pb_md.h"
diff --git AmberTools/src/pbsa/locmem.F90 AmberTools/src/pbsa/locmem.F90
index f40d81d..257c1ad 100644
--- AmberTools/src/pbsa/locmem.F90
+++ AmberTools/src/pbsa/locmem.F90
@@ -5,12 +5,13 @@
 !+ Amber memory interface routine
 subroutine locmem
  
+   use memory_module
+
    implicit none
 
    ! included variables
  
 #  include "box.h"
-#  include "memory.h"
 #  include "md.h"
 #  include "dynph.h"
 
diff --git AmberTools/src/pbsa/makedepend AmberTools/src/pbsa/makedepend
index ac6ed8a..4010906 100755
--- AmberTools/src/pbsa/makedepend
+++ AmberTools/src/pbsa/makedepend
@@ -20,13 +20,14 @@ $SANDER{"sa_driver"} = $SANDER{"pb_force"} = $SANDER{"np_force"} =
 	$SANDER{"pb_exmol"} = $SANDER{"pb_mpfrc"} = $SANDER{"pb_direct"} =
 	$SANDER{"pb_list"} = $SANDER{"pb_read"} = $SANDER{"pb_write"} =
 	$SANDER{"pb_init"} = $SANDER{"timer"} = $SANDER{"problem"} =
-        $SANDER{"gen_dx_file"} = $SANDER{"membrane"} = 1;
+        $SANDER{"gen_dx_file"} = $SANDER{"membrane"} = $SANDER{memory_module} = 
+        $SANDER{"parms"} = 1;
 $LIBPBSA{"sa_driver"} = $LIBPBSA{"pb_force"} = $LIBPBSA{"np_force"} = 
 	$LIBPBSA{"pb_exmol"} = $LIBPBSA{"pb_fft"} = $LIBPBSA{"pb_direct"} =
 	$LIBPBSA{"pb_list"} = $LIBPBSA{"pb_read"} = $LIBPBSA{"pb_write"} =
 	$LIBPBSA{"pb_init"} = $LIBPBSA{"timer"} = $LIBPBSA{"problem"} =
         $LIBPBSA{"gen_dx_file"} = $LIBPBSA{"membrane"} = $LIBPBSA{"pbsaapi"} = 
-        $LIBPBSA{"pb_fftsolv"} = $LIBPBSA{"fftw3"} = 1;
+        $LIBPBSA{"pb_fftsolv"} = $LIBPBSA{"fftw3"} = $LIBPBSA{"parms"} = 1;
 
 #  in order to get a mapping between module names and file names, we have
 #  have to set up the following hash. 
diff --git AmberTools/src/pbsa/memory.h AmberTools/src/pbsa/memory.h
index 682d5ce..bc5afeb 100644
--- AmberTools/src/pbsa/memory.h
+++ AmberTools/src/pbsa/memory.h
@@ -2,7 +2,9 @@
 !  --- following should not need to be modified unless you are adding
 !      more variables to the "locmem" style of memory management
 
-!       BC_MEMORY is the size of the MEMORY common block:
+! NOTE: if you change this file, make sure you change the corresponding file
+! in both src/sander/memory.h and AmberTools/src/sqm/memory.h
+
 ! MFC changing indices into IX and X to more rational names
 !       I12 = Iibh
 !       I14 = Ijbh
@@ -12,48 +14,52 @@
 !       I22 = Iicba
 
 integer       natom,nres,nbonh,nbona,ntheth,ntheta,nphih, &
-      nphia,nnb,ntypes,nconp,maxmem,nwdvar,maxnb,nparm, &
-      natc,ibelly,natbel,ishake,nmxrs, &
+      nphia,nnb,ntypes,nconp,maxmem,nwdvar,nparm, &
+      natc,nattgtfit,nattgtrms,ibelly,natbel,ishake,nmxrs, &
       mxsub,natyp,npdec,i02,i04,i06,i08,i10, &
       iibh,ijbh,iicbh,iiba,ijba,iicba, &
       i24,i26,i28,i30,i32,i34,i36,i38,i40, &
       i42,i44,i46,i48,i50,i52,i54,i56,i58,ibellygp, &
-      icnstrgp,i64,i65,i66,i68, &
+      icnstrgp,itgtfitgp,itgtrmsgp,i64,i65,i66,i68, &
       i70,i72,i74,i76,i78,i79,i80,i82,i84,i86, &
-      icpstinf,icpresst,icptrsct, icpptcnt, &
-      l05,l10,l15,lwinv,lpol,lcrd,lforce,l36,lvel,lvel2,l45,l50, &
-      lcrdr,l60,l65,lmass,l75,l80,l85,l90,l95,l96,l97,l98,lfrctmp, &
+      i100, &
+      l15,lwinv,lpol,lcrd,lforce,l36,lvel,lvel2,l45,l50, &
+      lcrdr,l60,l65,lmass,l75,l80,l85,l90,l95,l96,l97,l98,l99,lfrctmp, &
       l105,l110,l115,l120,l125,l130,l135,l140,l145,l150, &
       l165,l170,l175,l180,l185,l186,l187,l188,l189,l190, &
-      lcpcrg,lcpene, &
       m02,m04,m06,m08,m10,m12,m14,m16,m18,i01, &
-      lastr,lasti,lasth,lastpr,lastrst,lastist,ncopy
-!     lastpr,lastrst,lastist,nbper,ngper,ndper,ifpert,lpolp, ncopy, &
-!     imask1,imask2,numadjst,mxadjmsk
+      iifstwt,iifstwr,nrealb,nintb,nholb,npairb,lastr,lasti,lasth, &
+      lastpr,nbper,ngper,ndper,ifpert,ncopy, &
+      imask1,imask2,numadjst,mxadjmsk,noshake, &
+! Modified by WJM, YD
+      l2402, l2403, l2404, ldf, lpol2  ! Hai Nguyen: add GB index here
 
-! 1     2      3      4      5       6       7      8      9      10
+!  1        2         3         4         5      6     7     8      9      10
 common/memory/ &
- natom ,nres  ,nbonh ,nbona ,ntheth ,ntheta ,nphih ,                       & ! 7
- nphia ,nnb   ,ntypes,nconp ,maxmem ,nwdvar ,maxnb ,nparm ,                & !15
- natc  ,ibelly,natbel,ishake,nmxrs  ,                                      & !20
- mxsub ,natyp ,npdec ,i02   ,i04    ,i06    ,i08   ,i10,                   & !28
- iibh  ,ijbh  ,iicbh ,iiba  ,ijba   ,iicba  ,                              & !34
- i24   ,i26   ,i28   ,i30   ,i32    ,i34    ,i36   ,i38   ,i40   ,         & !43
- i42   ,i44   ,i46   ,i48   ,i50    ,i52    ,i54   ,i56   ,i58   ,ibellygp,& !53
- icnstrgp,i64 ,i65   ,i66   ,i68    ,                                      & !58
- i70   ,i72   ,i74   ,i76   ,i78    ,i79    ,i80   ,i82   ,                & !66
- i84   ,i86   ,                                                            & !68
- icpstinf,icpresst,icptrsct, icpptcnt,                                     & !72
- l05   ,l10   ,l15   ,lwinv ,lpol   ,lcrd   ,lforce,l36   ,lvel  ,lvel2 ,  & !82
- l45   ,l50   ,                                                            & !84
- lcrdr ,l60   ,l65   ,lmass ,l75    ,l80    ,l85   ,l90   ,l95   ,l96   ,  & !94
- l97   ,l98   ,lfrctmp,                                                    & !97
- l105  ,l110  ,l115  ,l120  ,l125   ,l130   ,l135  ,l140  ,l145  ,l150  ,  & !107
- l165  ,l170  ,l175  ,l180  ,l185   ,l186   ,l187  ,l188  ,l189  ,l190  ,  & !117
- lcpcrg,lcpene,                                                            & !119
- m02   ,m04   ,m06   ,m08   ,m10    ,m12    ,m14   ,m16   ,m18   ,i01   ,  & !129
- lastr ,lasti ,lasth ,lastpr,lastrst,lastist,ncopy                           !136
-!iifstwt,iifstwr,nrealb,nintb,nholb,npairb,lastr ,lasti ,lasth ,         & !138
-!lastpr ,lastrst,lastist,nbper,ngper,ndper,ifpert,lpolp ,ncopy,          & !147
-!imask1 ,imask2 ,numadjst,mxadjmsk                                         !151
-#define BC_MEMORY 136
+ natom   ,nres     ,nbonh    ,nbona   ,ntheth,ntheta,nphih  ,                       & !  7
+ nphia   ,nnb      ,ntypes   ,nconp   ,maxmem,nwdvar,nparm  ,                       & ! 14
+ natc    ,nattgtfit,nattgtrms,ibelly  ,natbel,ishake,nmxrs  ,                       & ! 21
+ mxsub   ,natyp    ,npdec    ,i02     ,i04   ,i06   ,i08    ,i10   ,                & ! 29
+ iibh    ,ijbh     ,iicbh    ,iiba    ,ijba  ,iicba ,                               & ! 35
+ i24     ,i26      ,i28      ,i30     ,i32   ,i34   ,i36    ,i38   ,i40   ,         & ! 44
+ i42     ,i44      ,i46      ,i48     ,i50   ,i52   ,i54    ,i56   ,i58   ,ibellygp,& ! 54
+ icnstrgp,itgtfitgp,itgtrmsgp,i64     ,i65   ,i66   ,i68    ,                       & ! 61
+ i70     ,i72      ,i74      ,i76     ,i78   ,i79   ,i80    ,i82   ,                & ! 69
+ i84     ,i86      ,                                                                & ! 71
+ i100    ,                                                                          & ! 72
+ l15     ,lwinv    ,lpol     ,lcrd    ,lforce,l36   ,lvel   ,lvel2 ,                & ! 80
+ l45     ,l50      ,                                                                & ! 82
+ lcrdr   ,l60      ,l65      ,lmass   ,l75   ,l80   ,l85    ,l90   ,l95   ,l96     ,& ! 92
+ l97     ,l98      ,l99      ,lfrctmp  ,                                            & ! 96
+ l105    ,l110     ,l115     ,l120    ,l125  ,l130  ,l135   ,l140  ,l145  ,l150    ,& !106
+ l165    ,l170     ,l175     ,l180    ,l185  ,l186  ,l187   ,l188  ,l189  ,l190    ,& !116
+ m02     ,m04      ,m06      ,m08     ,m10   ,m12   ,m14    ,m16   ,m18   ,i01     ,& !126
+ iifstwt ,iifstwr  ,nrealb   ,nintb   ,nholb ,npairb,lastr  ,lasti ,lasth ,         & !135
+ lastpr  ,nbper    ,ngper    ,ndper   ,ifpert,ncopy ,                               & !141
+ imask1  ,imask2   ,numadjst ,mxadjmsk,noshake,                                     & !146
+ l2402   ,l2403    ,l2404    ,ldf     ,lpol2                                          !151
+! Modified by WJM
+ !Hai Nguyen: add GB arrays here
+
+! BC_MEMORY is the size of the MEMORY common block
+#define BC_MEMORY 151
diff --git AmberTools/src/pbsa/memory_module.F90 AmberTools/src/pbsa/memory_module.F90
new file mode 100644
index 0000000..a652a1a
--- /dev/null
+++ AmberTools/src/pbsa/memory_module.F90
@@ -0,0 +1,47 @@
+!<compile=optimized>
+
+module memory_module
+
+implicit none
+
+#include "memory.h"
+
+! Remove lastrst and lastist from the common block, since they're not in the
+! sander memory.h common block. Eventually I think everything should be moved
+! into the module (as in sander), but this is OK as a first step. Now,
+!
+! "use memory_module"
+!
+! has the same effect as
+!
+! #include "memory.h"
+!
+! and should be used instead.  It also has the upside of being able to use the
+! keyword "only".
+
+integer, save :: lastrst, lastist
+
+#ifdef MPI
+contains
+
+subroutine bcast_memory
+
+   implicit none
+
+   include 'mpif.h'
+#  include "parallel.h"
+   
+   integer ier
+
+   ! First broadcast the common block
+   call MPI_BCAST(natom, BC_MEMORY, MPI_INTEGER, 0, COMMSANDER, ier)
+
+   ! Now broadcast our 2 other integers
+   call MPI_BCAST(lastrst, 1, MPI_INTEGER, 0, COMMSANDER, ier)
+   call MPI_BCAST(lastist, 1, MPI_INTEGER, 0, COMMSANDER, ier)
+
+end subroutine bcast_memory
+
+#endif /* MPI */
+
+end module memory_module
diff --git AmberTools/src/pbsa/parms.F90 AmberTools/src/pbsa/parms.F90
new file mode 100644
index 0000000..c144038
--- /dev/null
+++ AmberTools/src/pbsa/parms.F90
@@ -0,0 +1,220 @@
+ !<compile=optimized>
+#include "copyright.h"
+#include "../include/dprec.fh"
+
+module parms
+
+_REAL_, allocatable, dimension(:) :: rk         ! bond force constant
+_REAL_, allocatable, dimension(:) :: req        ! bond equilibrium value
+_REAL_, allocatable, dimension(:) :: tk         ! angle force constant
+_REAL_, allocatable, dimension(:) :: teq        ! angle equilibrium value
+_REAL_, allocatable, dimension(:) :: pk         ! torsion barrier height
+_REAL_, allocatable, dimension(:) :: pn         ! torsion periodicity
+_REAL_, allocatable, dimension(:) :: phase      ! torsion phase
+_REAL_, allocatable, dimension(:) :: cn1        ! LJ A coefficient
+_REAL_, allocatable, dimension(:) :: cn2        ! LJ B coefficient
+_REAL_, allocatable, dimension(:) :: one_scnb   ! 1 / LJ scaling factor
+_REAL_, allocatable, dimension(:) :: one_scee   ! 1 / EEL scaling factor
+_REAL_, allocatable, dimension(:) :: solty      ! SOLTY parm section (unused)
+_REAL_, allocatable, dimension(:) :: gamc       ! cos(phase)*pk
+_REAL_, allocatable, dimension(:) :: gams       ! sin(phase)*pk
+_REAL_, allocatable, dimension(:) :: asol       ! 10-12 A coefficient
+_REAL_, allocatable, dimension(:) :: bsol       ! 10-12 B coefficient
+_REAL_, allocatable, dimension(:) :: hbcut      ! Hydrogen bond cutoff
+
+_REAL_, allocatable, dimension(:) :: cn3        !  v
+_REAL_, allocatable, dimension(:) :: cn4        ! mjhsieh: for another vdwmodel
+_REAL_, allocatable, dimension(:) :: cn5        !  ^
+
+integer, allocatable, dimension(:) :: ipn       ! integer torsion periodicities
+
+! NPHB is the number of h-bond parameters. NIMPRP is the number of
+! improper torsional parameters (NPTRA-NIMPRP is the number of regular
+! torsional parameters).
+
+! nttyp = ntypes*(ntypes+1)/2  (number of LJ type pairs)
+
+integer :: numbnd
+integer :: numang
+integer :: nptra
+integer :: nphb
+integer :: nimprp
+integer :: nttyp
+integer :: orig_numbnd ! necessary for QM/MM simulations with QM SHAKE
+
+contains
+!+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+!+ Allocate space for all of the parm arrays
+subroutine allocate_parms
+
+   use memory_module, only : natyp
+
+   implicit none
+
+   integer :: ierror
+
+   ! Do my memory allocation steps
+   allocate(rk(numbnd), req(numbnd),             & ! bond params
+            tk(numang), teq(numang),             & ! angle params
+            pk(nptra), pn(nptra), phase(nptra),  & ! dihedral params
+            one_scnb(nptra), one_scee(nptra),    & ! 1-4 scaling factors
+            gams(nptra), gamc(nptra),            & ! dihedral 'work' arrays
+            cn1(nttyp), cn2(nttyp), cn3(nttyp),  & ! vdw arrays
+            cn4(nttyp), cn5(nttyp),              & ! more vdw arrays
+            solty(natyp),                        & ! unused ??
+            asol(nphb), bsol(nphb), hbcut(nphb), & ! h-bond arrays
+            stat=ierror)
+
+   if (ierror /= 0) then
+      write(6,*) 'ERROR allocating parameter arrays!'
+      call mexit(6, 1)
+   end if
+
+   allocate(ipn(nptra), stat=ierror)
+
+   if (ierror /= 0) then
+      write(6,*) 'ERROR allocating ipn array!'
+      call mexit(6, 1)
+   end if
+
+   return
+
+end subroutine allocate_parms
+
+!+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+!+ Allocate space for all of the parm arrays
+subroutine add_qmmm_bonds(new_rk, new_req)
+
+   implicit none
+   
+   ! Formal arguments
+   _REAL_, dimension(*), intent(in) :: new_rk      ! New force constants
+   _REAL_, dimension(*), intent(in) :: new_req     ! New equilibrium values
+
+   ! Local arguments
+   _REAL_, dimension(orig_numbnd) :: rk_holder
+   _REAL_, dimension(orig_numbnd) :: req_holder
+
+   integer :: ierror, i
+
+   ! We only have something to do if numbnd > orig_numbnd
+   if (numbnd <= orig_numbnd) return
+
+   ! back up rk and req
+   rk_holder(1:orig_numbnd) = rk(1:orig_numbnd)
+   req_holder(1:orig_numbnd) = req(1:orig_numbnd)
+
+   ! Deallocate our rk/req
+   deallocate(rk, req)
+
+   ! Reallocate with the larger numbnd
+   allocate(rk(numbnd), req(numbnd), stat=ierror)
+   if (ierror /= 0) then
+      write(6, *) 'ERROR extending rk/req in add_qmmm_bonds (parms.F90)'
+      call mexit(6, 1)
+   end if
+
+   ! Restore our original rk, req and then extend it with our new values
+   rk(1:orig_numbnd) = rk_holder(1:orig_numbnd)
+   req(1:orig_numbnd) = req_holder(1:orig_numbnd)
+
+   ! Now add in our additional rk and req values
+   do i = 1, numbnd - orig_numbnd
+      rk(orig_numbnd + i) = new_rk(i)
+      req(orig_numbnd + i) = new_req(i)
+   end do
+
+   ! Now update orig_numbnd (allows us to use add_qmmm_bonds multiple times)
+   orig_numbnd = numbnd
+
+   return
+
+end subroutine add_qmmm_bonds
+
+!+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+!+ deallocates the various data structures
+subroutine clean_parms
+
+   implicit none
+
+   if (allocated(rk))      deallocate(rk)
+   if (allocated(req))     deallocate(req)
+   if (allocated(tk))      deallocate(tk)
+   if (allocated(teq))     deallocate(teq)
+   if (allocated(pk))      deallocate(pk)
+   if (allocated(pn))      deallocate(pn)
+   if (allocated(phase))   deallocate(phase)
+   if (allocated(cn1))     deallocate(cn1)
+   if (allocated(cn2))     deallocate(cn2)
+   if (allocated(cn3))     deallocate(cn3)
+   if (allocated(cn4))     deallocate(cn4)
+   if (allocated(cn5))     deallocate(cn5)
+   if (allocated(solty))   deallocate(solty)
+   if (allocated(one_scnb))deallocate(one_scnb)
+   if (allocated(one_scee))deallocate(one_scee)
+   if (allocated(gamc))    deallocate(gamc)
+   if (allocated(gams))    deallocate(gams)
+   if (allocated(asol))    deallocate(asol)
+   if (allocated(bsol))    deallocate(bsol)
+   if (allocated(hbcut))   deallocate(hbcut)
+   if (allocated(ipn))     deallocate(ipn)
+
+end subroutine clean_parms
+
+#if !defined SANDER  && !defined LIBPBSA && defined MPI
+!+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+!+ broadcast parm arrays
+subroutine bcast_parms
+
+   use memory_module, only : natyp
+
+   implicit none
+
+#  include "extra.h"
+   include 'mpif.h'
+#  include "parallel.h"
+
+   integer ierror
+
+   ! Broadcast the pointers
+   call mpi_bcast(numbnd, 1, MPI_INTEGER, 0, commsander, ierror)
+   call mpi_bcast(numang, 1, MPI_INTEGER, 0, commsander, ierror)
+   call mpi_bcast(nptra, 1, MPI_INTEGER, 0, commsander, ierror)
+   call mpi_bcast(nphb, 1, MPI_INTEGER, 0, commsander, ierror)
+   call mpi_bcast(nimprp, 1, MPI_INTEGER, 0, commsander, ierror)
+   call mpi_bcast(nttyp, 1, MPI_INTEGER, 0, commsander, ierror)
+
+   ! Our slave nodes have not yet allocated the arrays, so do that hee
+   if (.not. master) call allocate_parms()
+
+   ! Broadcast the real arrays
+   call mpi_bcast(rk, numbnd, MPI_DOUBLE_PRECISION, 0, commsander, ierror)
+   call mpi_bcast(req, numbnd, MPI_DOUBLE_PRECISION, 0, commsander, ierror)
+   call mpi_bcast(tk, numang, MPI_DOUBLE_PRECISION, 0, commsander, ierror)
+   call mpi_bcast(teq, numang, MPI_DOUBLE_PRECISION, 0, commsander, ierror)
+   call mpi_bcast(pk, nptra, MPI_DOUBLE_PRECISION, 0, commsander, ierror)
+   call mpi_bcast(pn, nptra, MPI_DOUBLE_PRECISION, 0, commsander, ierror)
+   call mpi_bcast(phase, nptra, MPI_DOUBLE_PRECISION, 0, commsander, ierror)
+   call mpi_bcast(one_scnb, nptra, MPI_DOUBLE_PRECISION, 0, commsander, ierror)
+   call mpi_bcast(one_scee, nptra, MPI_DOUBLE_PRECISION, 0, commsander, ierror)
+   call mpi_bcast(solty, natyp, MPI_DOUBLE_PRECISION, 0, commsander, ierror)
+   call mpi_bcast(gamc, nptra, MPI_DOUBLE_PRECISION, 0, commsander, ierror)
+   call mpi_bcast(gams, nptra, MPI_DOUBLE_PRECISION, 0, commsander, ierror)
+   call mpi_bcast(asol, nphb, MPI_DOUBLE_PRECISION, 0, commsander, ierror)
+   call mpi_bcast(bsol, nphb, MPI_DOUBLE_PRECISION, 0, commsander, ierror)
+   call mpi_bcast(hbcut, nphb, MPI_DOUBLE_PRECISION, 0, commsander, ierror)
+   call mpi_bcast(cn1, nttyp, MPI_DOUBLE_PRECISION, 0, commsander, ierror)
+   call mpi_bcast(cn2, nttyp, MPI_DOUBLE_PRECISION, 0, commsander, ierror)
+   call mpi_bcast(cn3, nttyp, MPI_DOUBLE_PRECISION, 0, commsander, ierror)
+   call mpi_bcast(cn4, nttyp, MPI_DOUBLE_PRECISION, 0, commsander, ierror)
+   call mpi_bcast(cn5, nttyp, MPI_DOUBLE_PRECISION, 0, commsander, ierror)
+
+   ! Broadcast the integer array
+   call mpi_bcast(ipn, nptra, MPI_INTEGER, 0, commsander, ierror)
+   
+   return
+
+end subroutine bcast_parms
+#endif /* !SANDER && !LIBPBSA && MPI */
+
+end module parms
diff --git AmberTools/src/pbsa/parms.h AmberTools/src/pbsa/parms.h
deleted file mode 100644
index 2eb7357..0000000
--- AmberTools/src/pbsa/parms.h
+++ /dev/null
@@ -1,31 +0,0 @@
-
-!    BC_PARMR is the number of reals in common RPARMS; BC_PARMI is the
-!    number of ints in IPARMS.  (Change these if you change the sizes below).
-
-#define BC_PARMR 23320
-#define BC_PARMI 1200
-
-_REAL_ rk(5000),req(5000),tk(900),teq(900),pk(1200),      &!13000
-      pn(1200),phase(1200),cn1(1830),cn2(1830),solty(60), &!19120
-      gamc(1200),gams(1200),fmn(1200),                    &!22720
-      asol(200),bsol(200),hbcut(200)                       !23320
-common/rparms/rk,req,tk,teq,pk, &
-      pn,phase,cn1,cn2,solty, &
-      gamc,gams,fmn, &
-      asol,bsol,hbcut
-
-integer ipn(1200)
-common/iparms/ipn
-
-#ifdef CHARMM
-_REAL_ cn114,cn214,rkub,rub
-common/p14/ cn114(1830),cn214(1830)
-common/ub/rkub(900),rub(900)
-#endif
-
-! NPHB is the number of h-bond parameters. NIMPRP is the number of
-! improper torsional parameters (NPTRA-NIMPRP is the number of regular
-! torsional parameters).
-
-integer       numbnd,numang,nptra,nphb,nimprp
-common/prmlim/numbnd,numang,nptra,nphb,nimprp
diff --git AmberTools/src/pbsa/pb_chkfrc.F90 AmberTools/src/pbsa/pb_chkfrc.F90
index c288b6e..2250340 100644
--- AmberTools/src/pbsa/pb_chkfrc.F90
+++ AmberTools/src/pbsa/pb_chkfrc.F90
@@ -4,6 +4,7 @@
 subroutine chkfrc(xx,ix,ih,ipairs,x,fg,ene,r_stack,i_stack, &
               atm1,atm2,ntrns,rotopt,nrotx,nsph,mrot,mrotx,msph,delta)
 
+   use memory_module
    use poisson_boltzmann, only: savh, nfocus
 
    implicit none
@@ -12,7 +13,6 @@ subroutine chkfrc(xx,ix,ih,ipairs,x,fg,ene,r_stack,i_stack, &
 #  include "../lib/random.h"
 #  include "md.h"
 #  include "pb_md.h"
-#  include "memory.h"
 
    ! Passed
    integer atm1, atm2, ntrns, rotopt, nrotx, nsph, mrot, mrotx, msph
diff --git AmberTools/src/pbsa/pb_init.F90 AmberTools/src/pbsa/pb_init.F90
index da96a71..3fdce3f 100644
--- AmberTools/src/pbsa/pb_init.F90
+++ AmberTools/src/pbsa/pb_init.F90
@@ -127,10 +127,13 @@ subroutine pb_free
 end subroutine pb_free
 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 !+ PBMD initialization routine
-subroutine pb_init(ifcap,natom,nres,ntypes,nbonh,nbona,ipres,iac,ico,numex,natex,ibh,jbh,iba,jba,ibel,lbres,igraph,isymbl,cg,rin)
+subroutine pb_init(ifcap, natom, nres, ntypes, nbonh, nbona, ipres, iac, ico, &
+                   numex, natex, ibh, jbh, iba, jba, ibel, lbres, igraph, &
+                   isymbl, cg, rin)
      
    ! Module variables
      
+   use parms, only : cn1, cn2
    use poisson_boltzmann
    use solvent_accessibility
    use dispersion_cavity
@@ -138,14 +141,8 @@ subroutine pb_init(ifcap,natom,nres,ntypes,nbonh,nbona,ipres,iac,ico,numex,natex
    implicit none
      
    ! Common variables
-   ! Currently _REAL_ is not defined
      
-#ifdef SANDER
-#  include "../../../src/sander/md.h"
-#else
 #  include "md.h"
-#endif
-#  include "parms.h"
 #  include "pb_md.h"
      
    ! Passed variables
diff --git AmberTools/src/pbsa/pb_read.F90 AmberTools/src/pbsa/pb_read.F90
index dcfba12..ed54930 100644
--- AmberTools/src/pbsa/pb_read.F90
+++ AmberTools/src/pbsa/pb_read.F90
@@ -7,14 +7,14 @@
 !+ Open input files and read cntrl namelist.
 subroutine mdread1()
    
+   use memory_module
+
    implicit none
 
 #  include "pb_constants.h"
 #  include "files.h"
 #  include "box.h"
 #  include "md.h"
-#  include "memory.h"
-#  include "parms.h"
 
    integer     ifind
    logical     mdin_cntrl  ! true if this namelist exists in mdin
@@ -201,6 +201,8 @@ subroutine mdread2(x,ix,ih)
 
    use decomp, only: jgroup, index, irespw
 
+   use memory_module
+
    implicit none
 
    _REAL_ x(*)
@@ -212,8 +214,6 @@ subroutine mdread2(x,ix,ih)
 
 #  include "pb_constants.h"
 #  include "files.h"
-#  include "parms.h"
-#  include "memory.h"
 #  include "box.h"
 #  include "md.h"
    
diff --git AmberTools/src/pbsa/pbsa.F90 AmberTools/src/pbsa/pbsa.F90
index eb500e4..cbd2d2f 100644
--- AmberTools/src/pbsa/pbsa.F90
+++ AmberTools/src/pbsa/pbsa.F90
@@ -83,14 +83,18 @@ subroutine pbsa()
    use pbtimer_module
    use decomp, only : allocate_int_decomp, allocate_real_decomp, &
                       deallocate_int_decomp, deallocate_real_decomp
+   use memory_module
+#ifdef MPI
+   use parms, only : allocate_parms, clean_parms, bcast_parms, cn1, cn2
+#else
+   use parms, only : allocate_parms, clean_parms, cn1, cn2
+#endif
 
    implicit none
 
 #  include "files.h"
-#  include "memory.h"
 #  include "box.h"
 #  include "md.h"
-#  include "parms.h"
 #  include "timer.h"
 #  include "extra.h"
 #ifdef MPI
@@ -134,7 +138,7 @@ subroutine pbsa()
    call pbtimer_start(PBTIME_TOTAL)
    if ( master ) then
 
-      !        --- first, initial reads to determine memry sizes:
+      !        --- first, initial reads to determine memory sizes:
 
       call pbtimer_start(PBTIME_READ)
       call mdread1()
@@ -146,9 +150,11 @@ subroutine pbsa()
       !        --- now, we can allocate memory:
 
       call locmem
+      call allocate_parms
    end if
 #ifdef MPI
-   call MPI_BCAST(    natom,       BC_MEMORY,         MPI_INTEGER,0,CommSANDER,ier); REQUIRE(ier==0)
+   ! Broadcast everything from memory_module
+   call bcast_memory
 #endif
 
    !        --- dynamic memory allocation:
@@ -225,10 +231,10 @@ subroutine pbsa()
    call MPI_BCAST(ipairs(1),          lastpr,         MPI_INTEGER,0,CommSANDER,ier); REQUIRE(ier==0)
    call MPI_BCAST(    ih(1),len(ih(1))*lasth,       MPI_CHARACTER,0,CommSANDER,ier); REQUIRE(ier==0)
    call MPI_BCAST(        t,          BC_MDR,MPI_DOUBLE_PRECISION,0,CommSANDER,ier); REQUIRE(ier==0)
-   call MPI_BCAST(    rk(1),        BC_PARMR,MPI_DOUBLE_PRECISION,0,CommSANDER,ier); REQUIRE(ier==0)
    call MPI_BCAST(     x(1),           lastr,MPI_DOUBLE_PRECISION,0,CommSANDER,ier); REQUIRE(ier==0)
 
    call MPI_BARRIER( CommSANDER, ier ); REQUIRE(ier==0)
+   call bcast_parms
 #endif /* MPI */
    
    call date_and_time( setup_end_date, setup_end_time )
@@ -331,6 +337,7 @@ subroutine pbsa()
    !     --- dynamic memory deallocation:
 
    call pb_free()
+   call clean_parms()
    deallocate(     ih, stat = ier ); REQUIRE(ier==0)
    deallocate( ipairs, stat = ier ); REQUIRE(ier==0)
    deallocate(     ix, stat = ier ); REQUIRE(ier==0)
diff --git AmberTools/src/pbsa/pbsaapi.F90 AmberTools/src/pbsa/pbsaapi.F90
index bc40085..ae37351 100644
--- AmberTools/src/pbsa/pbsaapi.F90
+++ AmberTools/src/pbsa/pbsaapi.F90
@@ -44,19 +44,21 @@ end subroutine private_getx
 
 subroutine prepb_read(passed_ipb,passed_inp,mycn1,mycn2,mynttyp)
 !  use pbtimer_module
+   use parms, only : cn1, cn2
    implicit none
-#  include "parms.h"
 #  include "md.h"
 #  include "pb_md.h"
 #  include "flocntrl.h"
    _REAL_ mycn1(*),mycn2(*)
-   integer passed_ipb,passed_inp,mynttyp
+   integer passed_ipb,passed_inp,mynttyp,ierror
 !  character(len=8) initial_date
 !  character(len=10) initial_time
 
    if ( passed_ipb /= 1 .and. passed_ipb /=2 ) then
       print *,"ipb should be either 1 or 2."; call mexit(6,1)
    endif
+   ! We need to allocate our CN1 and CN2 arrays here
+   allocate(cn1(mynttyp), cn2(mynttyp), stat=ierror)
    cn1(1:mynttyp)=mycn1(1:mynttyp)
    cn2(1:mynttyp)=mycn2(1:mynttyp)
    imin = 0
diff --git AmberTools/src/pbsa/rdparm.F90 AmberTools/src/pbsa/rdparm.F90
index 4d41bd4..9599a03 100644
--- AmberTools/src/pbsa/rdparm.F90
+++ AmberTools/src/pbsa/rdparm.F90
@@ -5,19 +5,19 @@
 !+ A lite version of Amber rdparm1
 subroutine rdparm1(nf)
    
+   use memory_module
+   use parms, only : numbnd, numang, nptra, nphb, nimprp, nttyp
+
    implicit none
    
 #  include "md.h"
-#  include "memory.h"
-#  include "parms.h"
 #  include "files.h"
 #  include "box.h"
    integer nf
-   integer iok!,nspsol
-   integer nhparm,nttyp!,idum
+   integer iok
+   integer nhparm
    integer mbper,mgper,mdper,mbona,mtheta,mphia ! read but ignored
    integer numextra
-   integer ifpert,nbper,ngper,ndper! local, not going anywhere
    character(len=80) fmt
    character(len=80) fmtin,ifmt,afmt,rfmt,type
    ifmt = '(12I6)'
@@ -83,20 +83,24 @@ end subroutine rdparm1
 !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 !+ A lite version of Amber rdparm2
 subroutine rdparm2(x,ix,ih,ipairs,nf,i_stack)
+
+   use memory_module
+   use parms, only : rk, req, tk, teq, pk, pn, phase, cn1, cn2, solty, asol, &
+                     bsol, hbcut, numbnd, numang, nptra, nphb, nimprp, nttyp
+
    implicit none
+
    integer nf
    _REAL_ x(*)
    integer ix(*),ipairs(*),i_stack(*)
    character(len=4) ih(*)
    
 #  include "md.h"
-#  include "memory.h"
-#  include "parms.h"
 #  include "files.h"
 #  include "box.h"
 
    ! Local variables
-   integer nttyp,ntype,i,iok
+   integer ntype,i,iok
    integer j,jj,k,l,n,nn
    integer iptres,nspsol,natsm!,idum,ip14
    _REAL_ dumd,oldbeta,duma,dumb,dumc
diff --git AmberTools/src/pbsa/runmd.F90 AmberTools/src/pbsa/runmd.F90
index 71b9c7d..4d933c9 100644
--- AmberTools/src/pbsa/runmd.F90
+++ AmberTools/src/pbsa/runmd.F90
@@ -7,6 +7,8 @@
 subroutine runmd(xx,ix,ih,ipairs,x,winv,amass,f, &
                  v,vold,xr,xc,conp,skip,nsp,tma,erstop,r_stack,i_stack)
    
+   use memory_module
+
    implicit none
 
 ! Passed variables
@@ -20,13 +22,11 @@ subroutine runmd(xx,ix,ih,ipairs,x,winv,amass,f, &
 #  include "files.h"
 #  include "md.h"
 #  include "box.h"
-#  include "memory.h"
 #  include "extra.h"
 #  include "timer.h"
 #  include "pb_constants.h"
 #  include "pb_md.h"
 !#  include "../lib/random.h"   
-#  include "parms.h"
 #ifdef MPI
 #  define REQUIRE(e) if(.not.(e)) call croak(__FILE__,__LINE__)
    include "mpif.h"
diff --git AmberTools/src/pbsa/runmin.F90 AmberTools/src/pbsa/runmin.F90
index df9b1a6..9312816 100644
--- AmberTools/src/pbsa/runmin.F90
+++ AmberTools/src/pbsa/runmin.F90
@@ -6,6 +6,8 @@
 subroutine runmin(xx,ix,ih,ipairs,x,fg,w,ib,jb,conp, &
                   winv,igrp,skips,ene,r_stack, i_stack,carrms)
 
+   use memory_module
+
    implicit none
 
    ! global variables
@@ -14,7 +16,6 @@ subroutine runmin(xx,ix,ih,ipairs,x,fg,w,ib,jb,conp, &
 #  include "md.h"
 #  include "box.h"
 #  include "files.h"
-#  include "memory.h"
 #  include "pb_md.h"
 #  include "extra.h"
 #ifdef MPI
diff --git AmberTools/src/sqm/memory.h AmberTools/src/sqm/memory.h
index 34d28b8..ff5d5f0 100644
--- AmberTools/src/sqm/memory.h
+++ AmberTools/src/sqm/memory.h
@@ -3,7 +3,7 @@
 !      more variables to the "locmem" style of memory management
 
 ! NOTE: if you change this file, make sure you change the corresponding file
-! in both src/sander/md.h and AmberTools/src/sqm/md.h
+! in both src/sander/memory.h and AmberTools/src/sqm/memory.h
 
 ! MFC changing indices into IX and X to more rational names
 !       I12 = Iibh
@@ -20,7 +20,7 @@ integer       natom,nres,nbonh,nbona,ntheth,ntheta,nphih, &
       iibh,ijbh,iicbh,iiba,ijba,iicba, &
       i24,i26,i28,i30,i32,i34,i36,i38,i40, &
       i42,i44,i46,i48,i50,i52,i54,i56,i58,ibellygp, &
-      icnstrgp,itgtfitgp,itgtrmsgp,i64,i65,i68, &
+      icnstrgp,itgtfitgp,itgtrmsgp,i64,i65,i66,i68, &
       i70,i72,i74,i76,i78,i79,i80,i82,i84,i86, &
       i100, &
       l15,lwinv,lpol,lcrd,lforce,l36,lvel,lvel2,l45,l50, &
@@ -29,37 +29,37 @@ integer       natom,nres,nbonh,nbona,ntheth,ntheta,nphih, &
       l165,l170,l175,l180,l185,l186,l187,l188,l189,l190, &
       m02,m04,m06,m08,m10,m12,m14,m16,m18,i01, &
       iifstwt,iifstwr,nrealb,nintb,nholb,npairb,lastr,lasti,lasth, &
-      lastpr,nbper,ngper,ndper,ifpert,ncopy, &
+      lastpr,lastrst,lastist,nbper,ngper,ndper,ifpert,ncopy, &
       imask1,imask2,numadjst,mxadjmsk,noshake, &
 ! Modified by WJM, YD
       l2402, l2403, l2404, ldf, lpol2  ! Hai Nguyen: add GB index here
 
 !  1        2         3         4         5      6     7     8      9      10
 common/memory/ &
- natom   ,nres     ,nbonh    ,nbona   ,ntheth,ntheta,nphih ,                       & ! 7
- nphia   ,nnb      ,ntypes   ,nconp   ,maxmem,nwdvar,nparm ,                       & !14
- natc    ,nattgtfit,nattgtrms,ibelly  ,natbel,ishake,nmxrs ,                       & !21
- mxsub   ,natyp    ,npdec    ,i02     ,i04   ,i06   ,i08   ,i10   ,                & !29
- iibh    ,ijbh     ,iicbh    ,iiba    ,ijba  ,iicba ,                              & !35
- i24     ,i26      ,i28      ,i30     ,i32   ,i34   ,i36   ,i38   ,i40   ,         & !44
- i42     ,i44      ,i46      ,i48     ,i50   ,i52   ,i54   ,i56   ,i58   ,ibellygp,& !54
- icnstrgp,itgtfitgp,itgtrmsgp,i64     ,i65   ,i68   ,                              & !60
- i70     ,i72      ,i74      ,i76     ,i78   ,i79   ,i80   ,i82   ,                & !68
- i84     ,i86      ,                                                               & !70
- i100    ,                                                                          & ! 71
- l15     ,lwinv    ,lpol     ,lcrd    ,lforce,l36   ,lvel   ,lvel2 ,                & ! 79
- l45     ,l50      ,                                                                & ! 81
- lcrdr   ,l60      ,l65      ,lmass   ,l75   ,l80   ,l85    ,l90   ,l95   ,l96     ,& ! 91
- l97     ,l98      ,l99      ,lfrctmp  ,                                            & ! 95
- l105    ,l110     ,l115     ,l120    ,l125  ,l130  ,l135   ,l140  ,l145  ,l150    ,& !105
- l165    ,l170     ,l175     ,l180    ,l185  ,l186  ,l187   ,l188  ,l189  ,l190    ,& !115
- m02     ,m04      ,m06      ,m08     ,m10   ,m12   ,m14    ,m16   ,m18   ,i01     ,& !125
- iifstwt ,iifstwr  ,nrealb   ,nintb   ,nholb ,npairb,lastr  ,lasti ,lasth ,         & !134
- lastpr  ,nbper    ,ngper    ,ndper   ,ifpert,ncopy ,                               & !140
- imask1  ,imask2   ,numadjst ,mxadjmsk,noshake,                                     & !145
- l2402   ,l2403    ,l2404    ,ldf     ,lpol2                                          !150
+ natom   ,nres     ,nbonh    ,nbona   ,ntheth,ntheta,nphih  ,                       & !  7
+ nphia   ,nnb      ,ntypes   ,nconp   ,maxmem,nwdvar,nparm  ,                       & ! 14
+ natc    ,nattgtfit,nattgtrms,ibelly  ,natbel,ishake,nmxrs  ,                       & ! 21
+ mxsub   ,natyp    ,npdec    ,i02     ,i04   ,i06   ,i08    ,i10   ,                & ! 29
+ iibh    ,ijbh     ,iicbh    ,iiba    ,ijba  ,iicba ,                               & ! 35
+ i24     ,i26      ,i28      ,i30     ,i32   ,i34   ,i36    ,i38   ,i40   ,         & ! 44
+ i42     ,i44      ,i46      ,i48     ,i50   ,i52   ,i54    ,i56   ,i58   ,ibellygp,& ! 54
+ icnstrgp,itgtfitgp,itgtrmsgp,i64     ,i65   ,i66   ,i68    ,                       & ! 61
+ i70     ,i72      ,i74      ,i76     ,i78   ,i79   ,i80    ,i82   ,                & ! 69
+ i84     ,i86      ,                                                                & ! 71
+ i100    ,                                                                          & ! 72
+ l15     ,lwinv    ,lpol     ,lcrd    ,lforce,l36   ,lvel   ,lvel2 ,                & ! 80
+ l45     ,l50      ,                                                                & ! 82
+ lcrdr   ,l60      ,l65      ,lmass   ,l75   ,l80   ,l85    ,l90   ,l95   ,l96     ,& ! 92
+ l97     ,l98      ,l99      ,lfrctmp  ,                                            & ! 96
+ l105    ,l110     ,l115     ,l120    ,l125  ,l130  ,l135   ,l140  ,l145  ,l150    ,& !106
+ l165    ,l170     ,l175     ,l180    ,l185  ,l186  ,l187   ,l188  ,l189  ,l190    ,& !116
+ m02     ,m04      ,m06      ,m08     ,m10   ,m12   ,m14    ,m16   ,m18   ,i01     ,& !126
+ iifstwt ,iifstwr  ,nrealb   ,nintb   ,nholb ,npairb,lastr  ,lasti ,lasth ,         & !135
+ lastpr  ,lastrst  ,lastist  ,nbper   ,ngper ,ndper ,ifpert ,ncopy ,                & !143
+ imask1  ,imask2   ,numadjst ,mxadjmsk,noshake,                                     & !148
+ l2402   ,l2403    ,l2404    ,ldf     ,lpol2                                          !153
 ! Modified by WJM
  !Hai Nguyen: add GB arrays here
 
 ! BC_MEMORY is the size of the MEMORY common block
-#define BC_MEMORY 150
+#define BC_MEMORY 153
