diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index af007259420189de595538d71a69c4e3aea0bde0..c5ae5d2a49de307843bd31c986b7bab853c880dd 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -1,5 +1,10 @@
-Changes in Release 1.2.2
+Changes In Release 1.2.3
+--------------------------------------------------------------------------------
+
+  * PDBWriter: Prevent writing of out-of-bounds atom coordinates.
 
+Changes in Release 1.2.2
+--------------------------------------------------------------------------------
   * Fixed loop indentation in the PDBize function for bio units, leading to
     exponential running time/ memory consumption. This problem only affected a
     fraction of PDB entries.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5e2de9e91baf2f3d894cc86338d9a50e4b0a98ad..cd028753ee9ac355e387072e00ab6c8505975efe 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -6,7 +6,7 @@ cmake_minimum_required(VERSION 2.6.4 FATAL_ERROR)
 project(OpenStructure CXX C)
 set (OST_VERSION_MAJOR 1)
 set (OST_VERSION_MINOR 2)
-set (OST_VERSION_PATCH 2)
+set (OST_VERSION_PATCH 3)
 set (OST_VERSION_STRING ${OST_VERSION_MAJOR}.${OST_VERSION_MINOR}.${OST_VERSION_PATCH} )
 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake_support)
 include(OST)
diff --git a/modules/bindings/pymod/naccess.py b/modules/bindings/pymod/naccess.py
index f9f2e5703e99cf9a12740c89a192ce95119338a3..b02aeab7a02fff665d7217be36db95e438839657 100644
--- a/modules/bindings/pymod/naccess.py
+++ b/modules/bindings/pymod/naccess.py
@@ -205,7 +205,7 @@ def CalculateSurfaceArea(entity,  radius=1.4,
   # parse selection
   
   # setup files for msms
-  (naccess_data_dir, naccess_data_file,naccess_data_base )=_SetupFiles(entity, selection, scratch_dir)
+  (naccess_data_dir, naccess_data_file,naccess_data_base )=_SetupFiles(entity, selection, scratch_dir, max_number_of_atoms)
 
   # set command line
   command="%s %s -p %f " % \
diff --git a/modules/io/src/mol/pdb_writer.cc b/modules/io/src/mol/pdb_writer.cc
index d06a5228c5890f593c40c86ac9ceb4617f6ee379..6ce7df41b732ebfa883c357ad771f0dc5b055676 100644
--- a/modules/io/src/mol/pdb_writer.cc
+++ b/modules/io/src/mol/pdb_writer.cc
@@ -67,6 +67,15 @@ bool shift_left(const String& atom_name, bool is_hetatm,
           element=="MG" || element=="LI");
 }
 
+
+bool atom_pos_ok(geom::Vec3 p) {
+  for (int i=0; i<3; ++i) {
+    if (p[i]<=-1000 || p[i] >= 10000) {
+      return false;
+    }
+  }
+  return true;
+}
 void write_atom(std::ostream& ostr, FormattedLine& line, 
                 const mol::AtomHandle& atom, int atomnum, 
                 bool is_pqr, bool charmm_style)
@@ -130,6 +139,9 @@ void write_atom(std::ostream& ostr, FormattedLine& line,
   
   // deal with alternative atom locations
   if (names.empty()) {
+    if (!atom_pos_ok(p)) {
+      throw IOException("Atom position outside of bounds supported by PDB format");
+    }
     line(30, 8)=fmt::LPaddedFloat(p[0],  3);
     line(38, 8)=fmt::LPaddedFloat(p[1],  3);
     line(46, 8)=fmt::LPaddedFloat(p[2],  3);
@@ -158,6 +170,9 @@ void write_atom(std::ostream& ostr, FormattedLine& line,
       p=geom::Vec3(tf*geom::Vec4(atom.GetAltPos(*i)));
       line(30, 50).Clear();
 
+      if (!atom_pos_ok(p)) {
+        throw IOException("Atom position outside of bounds supported by PDB format");
+      }
       if (i->size()>1) {
         throw IOException("Alternative atom indicator '"+atom.GetQualifiedName()+
                           "("+*i+")' too long for PDB output. At most 1 "
diff --git a/modules/io/tests/test_io_pdb.cc b/modules/io/tests/test_io_pdb.cc
index b0e54cdc37dacf167da076cc78b813c2ee7b4fab..f2aa055fbe397295fa6bd5449ea16dd351482573 100644
--- a/modules/io/tests/test_io_pdb.cc
+++ b/modules/io/tests/test_io_pdb.cc
@@ -1029,6 +1029,24 @@ BOOST_AUTO_TEST_CASE(test_pqr_read_atom)
   BOOST_CHECK_CLOSE(a2.GetRadius(), Real(1.7503), Real(1e-4));
 }
 
+BOOST_AUTO_TEST_CASE(checks_for_atom_pos_overflow)
+{
+  std::stringstream out;
+  PDBWriter writer(out, IOProfile());
+  writer.SetIsPQR(true);
+
+  mol::EntityHandle ent=mol::CreateEntity();
+  mol::XCSEditor edi=ent.EditXCS();
+  mol::ChainHandle ch=edi.InsertChain("A");
+  mol::ResidueHandle r=edi.AppendResidue(ch, "GLY");
+
+  mol::AtomHandle a=edi.InsertAtom(r, "CA", geom::Vec3(0, -1000,0), "C");
+  
+  BOOST_CHECK_THROW(writer.Write(ent), IOException);
+  edi.SetAtomPos(a, geom::Vec3(10000,0,0));
+  BOOST_CHECK_THROW(writer.Write(ent), IOException);
+}
+
 BOOST_AUTO_TEST_CASE(test_pqr_write_atom)
 {
   std::stringstream out;