diff --git a/doc/.gitignore b/doc/.gitignore
index 35b5e99aee31762e1675c5a067f7628b7a191422..bcd8f6db717a6e3871380308172b0733b68951eb 100644
--- a/doc/.gitignore
+++ b/doc/.gitignore
@@ -1 +1,5 @@
 /html
+/LAMMPS.epub
+/LAMMPS.mobi
+/Manual.pdf
+/Developer.pdf
diff --git a/doc/Makefile b/doc/Makefile
index dfae774c61190864ed918b512421f6d12b4c481b..3da7239c5456038fc4e1b53a6a1727646a3f5eef 100644
--- a/doc/Makefile
+++ b/doc/Makefile
@@ -22,7 +22,7 @@ endif
 SOURCES=$(wildcard src/*.txt)
 OBJECTS=$(SOURCES:src/%.txt=$(RSTDIR)/%.rst)
 
-.PHONY: help clean-all clean html pdf old venv
+.PHONY: help clean-all clean epub html pdf old venv
 
 # ------------------------------------------
 
@@ -32,6 +32,7 @@ help:
 	@echo "  pdf        create Manual.pdf and Developer.pdf in this dir"
 	@echo "  old        create old-style HTML doc pages in old dir"
 	@echo "  fetch      fetch HTML and PDF files from LAMMPS web site"
+	@echo "  epub       create ePUB format manual for e-book readers"
 	@echo "  clean      remove all intermediate RST files"
 	@echo "  clean-all  reset the entire build environment"
 	@echo "  txt2html   build txt2html tool"
@@ -63,6 +64,20 @@ html: $(OBJECTS)
 	@rm -rf html/USER/*/*.[sg]*
 	@echo "Build finished. The HTML pages are in doc/html."
 
+epub: $(OBJECTS)
+	@mkdir -p epub
+	@rm -f LAMMPS.epub
+	@cp src/JPG/lammps-logo.png epub/
+	@(\
+		. $(VENV)/bin/activate ;\
+		cp -r src/* $(RSTDIR)/ ;\
+		sphinx-build -j 8 -b epub -c utils/sphinx-config -d $(BUILDDIR)/doctrees $(RSTDIR) epub ;\
+		deactivate ;\
+	)
+	@mv  epub/LAMMPS.epub .
+	@rm -rf epub
+	@echo "Build finished. The ePUB manual file is created."
+
 pdf: utils/txt2html/txt2html.exe
 	@(\
 		cd src; \
diff --git a/doc/README b/doc/README
index ea0edc0356e6ac4b145235dd03b897dddea77bc6..6db4ba3ca76d604a41a6d19097a91cc0d1ac3efd 100644
--- a/doc/README
+++ b/doc/README
@@ -1,13 +1,14 @@
 LAMMPS Documentation
 
 Depending on how you obtained LAMMPS, this directory has 2 or 3
-sub-directories and optionally 2 PDF files:
+sub-directories and optionally 2 PDF files and an ePUB file:
 
 src             content files for LAMMPS documentation
 html            HTML version of the LAMMPS manual (see html/Manual.html)
 tools           tools and settings for building the documentation
 Manual.pdf      large PDF version of entire manual
 Developer.pdf   small PDF with info about how LAMMPS is structured
+LAMMPS.epub     Manual in ePUB format
 
 If you downloaded LAMMPS as a tarball from the web site, all these
 directories and files should be included.
@@ -49,6 +50,7 @@ make pdf          # generate 2 PDF files (Manual.pdf,Developer.pdf)
 make old          # generate old-style HTML pages in old dir via txt2html
 make fetch        # fetch HTML doc pages and 2 PDF files from web site
                   #   as a tarball and unpack into html dir and 2 PDFs
+make epub         # generate LAMMPS.epub in ePUB format using Sphinx 
 make clean        # remove intermediate RST files created by HTML build
 make clean-all    # remove entire build folder and any cached data
 
@@ -91,3 +93,23 @@ This will install virtualenv from the Python Package Index.
 ----------------
 
 Installing prerequisites for PDF build
+
+[TBA]
+
+----------------
+
+Installing prerequisites for epub build
+
+## ePUB
+
+Same as for HTML. This uses the same tools and configuration
+files as the HTML tree.
+
+For converting the generated ePUB file to a mobi format file
+(for e-book readers like Kindle, that cannot read ePUB), you
+also need to have the 'ebook-convert' tool from the "calibre"
+software installed. http://calibre-ebook.com/
+You first create the ePUB file with 'make epub' and then do:
+
+ebook-convert LAMMPS.epub LAMMPS.mobi
+
diff --git a/doc/src/JPG/lammps-logo.png b/doc/src/JPG/lammps-logo.png
new file mode 100644
index 0000000000000000000000000000000000000000..ae5ba2d8ad56ec55dc7a54ee8be0a21d44003b30
Binary files /dev/null and b/doc/src/JPG/lammps-logo.png differ
diff --git a/doc/src/Section_packages.txt b/doc/src/Section_packages.txt
index 27ab64d50bf0544ef74d31b6e69b4642285abc93..341483d7a7231ef39ca2595ce5d2c4aa6d3d4ac7 100644
--- a/doc/src/Section_packages.txt
+++ b/doc/src/Section_packages.txt
@@ -1153,6 +1153,7 @@ Package, Description, Author(s), Doc page, Example, Pic/movie, Library
 "USER-MISC"_#USER-MISC, single-file contributions, USER-MISC/README, USER-MISC/README, -, -, -
 "USER-MANIFOLD"_#USER-MANIFOLD, motion on 2d surface, Stefan Paquay (Eindhoven U of Technology), "fix manifoldforce"_fix_manifoldforce.html, USER/manifold, "manifold"_manifold, -
 "USER-MOLFILE"_#USER-MOLFILE, "VMD"_VMD molfile plug-ins, Axel Kohlmeyer (Temple U), "dump molfile"_dump_molfile.html, -, -, VMD-MOLFILE
+"USER-NC-DUMP"_#USER-NC-DUMP, dump output via NetCDF, Lars Pastewka (Karlsruhe Institute of Technology, KIT), "dump nc, dump nc/mpiio"_dump_nc.html, -, -, lib/netcdf
 "USER-OMP"_#USER-OMP, OpenMP threaded styles, Axel Kohlmeyer (Temple U), "Section 5.3.4"_accelerate_omp.html, -, -, -
 "USER-PHONON"_#USER-PHONON, phonon dynamical matrix, Ling-Ti Kong (Shanghai Jiao Tong U), "fix phonon"_fix_phonon.html, USER/phonon, -, -
 "USER-QMMM"_#USER-QMMM, QM/MM coupling, Axel Kohlmeyer (Temple U), "fix qmmm"_fix_qmmm.html, USER/qmmm, -, lib/qmmm
@@ -1598,6 +1599,29 @@ The person who created this package is Axel Kohlmeyer at Temple U
 
 :line
 
+USER-NC-DUMP package :link(USER-NC-DUMP),h5
+
+Contents: Dump styles for writing NetCDF format files.  NetCDF is a binary,
+portable, self-describing file format on top of HDF5. The file format
+contents follow the AMBER NetCDF trajectory conventions
+(http://ambermd.org/netcdf/nctraj.xhtml), but include extensions to this
+convention. This package implements a "dump nc"_dump_nc.html command
+and a "dump nc/mpiio"_dump_nc.html command to output LAMMPS snapshots
+in this format.  See src/USER-NC-DUMP/README for more details.
+
+NetCDF files can be directly visualized with the following tools:
+Ovito (http://www.ovito.org/). Ovito supports the AMBER convention
+  and all of the above extensions. :ulb,l
+VMD (http://www.ks.uiuc.edu/Research/vmd/) :l
+AtomEye (http://www.libatoms.org/). The libAtoms version of AtomEye contains
+  a NetCDF reader that is not present in the standard distribution of AtomEye :l,ule
+
+The person who created these files is Lars Pastewka at
+Karlsruhe Institute of Technology (lars.pastewka at kit.edu).
+Contact him directly if you have questions.
+
+:line
+
 USER-OMP package :link(USER-OMP),h5
 
 Supporting info:
diff --git a/doc/src/write_dump.txt b/doc/src/write_dump.txt
index cf8302121c71efe321b3010f635f7db02a517f5b..ae32a94e840d32d0c25bd384bcca70a4fc51e596 100644
--- a/doc/src/write_dump.txt
+++ b/doc/src/write_dump.txt
@@ -26,7 +26,7 @@ write_dump all atom dump.atom
 write_dump subgroup atom dump.run.bin
 write_dump all custom dump.myforce.* id type x y vx fx
 write_dump flow custom dump.%.myforce id type c_myF\[3\] v_ke modify sort id
-write_dump all xyz system.xyz modify sort id elements O H
+write_dump all xyz system.xyz modify sort id element O H
 write_dump all image snap*.jpg type type size 960 960 modify backcolor white
 write_dump all image snap*.jpg element element &
    bond atom 0.3 shiny 0.1 ssao yes 6345 0.2 size 1600 1600  &
diff --git a/doc/utils/sphinx-config/conf.py b/doc/utils/sphinx-config/conf.py
index d89217834623a5791559c07bc95407f9c2f68af8..2b4950519a44d41d10501e5a0683242442cec09b 100644
--- a/doc/utils/sphinx-config/conf.py
+++ b/doc/utils/sphinx-config/conf.py
@@ -276,4 +276,27 @@ texinfo_documents = [
 # If true, do not generate a @detailmenu in the "Top" node's menu.
 #texinfo_no_detailmenu = False
 
+# -- Options for ePUB output ----------------------------------------------
+
+epub_title = 'LAMMPS Documentation - ' + get_lammps_version()
+
+epub_cover = ('lammps-logo.png', '')
+
+epub_description = """
+This is the Manual for the LAMMPS software package.
+
+LAMMPS stands for Large-scale Atomic/Molecular Massively Parallel
+Simulator and is a classical molecular dynamics simulation code
+designed to run efficiently on parallel computers.  It was developed
+at Sandia National Laboratories, a US Department of Energy facility,
+with funding from the DOE.  It is an open-source code, distributed
+freely under the terms of the GNU Public License (GPL).
+
+The primary author of the code is Steve Plimpton, who can be emailed
+at sjplimp@sandia.gov.  The LAMMPS WWW Site at lammps.sandia.gov has
+more information about the code and its uses.
+"""
+
+epub_author = 'The LAMMPS Developers'
+
 
diff --git a/src/MOLECULE/bond_table.cpp b/src/MOLECULE/bond_table.cpp
index 3a9f7cc4d02a85b867aa69ff818fef5f186110a9..858bc83a3665fb0b324221b80b99034e91430efa 100644
--- a/src/MOLECULE/bond_table.cpp
+++ b/src/MOLECULE/bond_table.cpp
@@ -585,17 +585,26 @@ double BondTable::splint(double *xa, double *ya, double *y2a, int n, double x)
 
 /* ----------------------------------------------------------------------
    calculate potential u and force f at distance x
-   insure x is between bond min/max
+   insure x is between bond min/max, exit with error if not
 ------------------------------------------------------------------------- */
 
 void BondTable::uf_lookup(int type, double x, double &u, double &f)
 {
   int itable;
   double fraction,a,b;
+  char estr[128];
 
   Table *tb = &tables[tabindex[type]];
-  x = MAX(x,tb->lo);
-  x = MIN(x,tb->hi);
+  if (x < tb->lo) {
+    sprintf(estr,"Bond length < table inner cutoff: "
+            "type %d length %g",type,x);
+    error->one(FLERR,estr);
+  }
+  if (x > tb->hi) {
+    sprintf(estr,"Bond length > table outer cutoff: "
+            "type %d length %g",type,x);
+    error->one(FLERR,estr);
+  }
 
   if (tabstyle == LINEAR) {
     itable = static_cast<int> ((x - tb->lo) * tb->invdelta);
diff --git a/src/create_box.cpp b/src/create_box.cpp
index c7fd98b2b2898cb3b208c3dc7353f7408a82831c..3a131099813e086d1dd961a28748824959cfe50e 100644
--- a/src/create_box.cpp
+++ b/src/create_box.cpp
@@ -159,6 +159,7 @@ void CreateBox::command(int narg, char **arg)
     } else if (strcmp(arg[iarg],"extra/special/per/atom") == 0) {
       if (iarg+2 > narg) error->all(FLERR,"Illegal create_box command");
       force->special_extra = force->inumeric(FLERR,arg[iarg+1]);
+      atom->maxspecial += force->special_extra;
       iarg += 2;
     } else error->all(FLERR,"Illegal create_box command");
   }
diff --git a/src/molecule.cpp b/src/molecule.cpp
index 5e9aa292d0072bca21f8bbccc36e29b22a520217..0febb784c84566c0298c00d78d3d2bca2e5ccc08 100644
--- a/src/molecule.cpp
+++ b/src/molecule.cpp
@@ -595,6 +595,10 @@ void Molecule::read(int flag)
   // set maxspecial on first pass, so allocate() has a size
 
   if (bondflag && specialflag == 0) {
+    if (domain->box_exist == 0)
+      error->all(FLERR,"Cannot auto-generate special bonds before "
+                       "simulation box is defined");
+
     maxspecial = atom->maxspecial;
     if (flag) {
       special_generate();