diff --git a/CMakeLists.txt b/CMakeLists.txt
index b349ffa27c485d901818dd14ba184824fca0a1a3..3cb9804b9c9f81868e163d793afcde0b7bc6b499 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -29,7 +29,7 @@ option(ENABLE_SPNAV "whether 3DConnexion devices should be supported"
 option(STATIC_PROPERTY_WORKAROUND "workaround for static property bug with some boost/boost_python combinations" OFF)
 option(DEPLOYMENT "switch on deployment settings" OFF)
 option(COMPILE_TESTS "wheter unit tests should be compiled by default" OFF)
-
+option(ENABLE_STATIC "whether static libraries should be compiled" OFF)
 if (CXX)
   set(CMAKE_CXX_COMPILER ${CXX})
 endif()
@@ -187,6 +187,17 @@ endif()
 
 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY)
 set(_BOOST_MIN_VERSION 1.37)
+
+find_package(Boost ${_BOOST_MIN_VERSION} COMPONENTS python REQUIRED)
+set(BOOST_PYTHON_LIBRARIES ${Boost_LIBRARIES})
+set(Boost_LIBRARIES)
+find_package(Boost ${_BOOST_MIN_VERSION} 
+             COMPONENTS unit_test_framework REQUIRED)
+set(BOOST_UNIT_TEST_LIBRARIES ${Boost_LIBRARIES})
+set(Boost_LIBRARIES)
+if (ENABLE_STATIC)
+  set(Boost_USE_STATIC_LIBS ON)
+endif()
 find_package(Boost ${_BOOST_MIN_VERSION} 
              COMPONENTS filesystem system REQUIRED)
 set(BOOST_LIBRARIES ${Boost_LIBRARIES})
@@ -194,21 +205,12 @@ set(Boost_LIBRARIES)
 find_package(Boost ${_BOOST_MIN_VERSION} COMPONENTS iostreams REQUIRED)
 set(BOOST_IOSTREAM_LIBRARIES ${Boost_LIBRARIES})
 set(Boost_LIBRARIES)
-find_package(Boost ${_BOOST_MIN_VERSION} 
-             COMPONENTS unit_test_framework REQUIRED)
-set(BOOST_UNIT_TEST_LIBRARIES ${Boost_LIBRARIES})
-set(Boost_LIBRARIES)
-find_package(Boost ${_BOOST_MIN_VERSION} COMPONENTS python REQUIRED)
-set(BOOST_PYTHON_LIBRARIES ${Boost_LIBRARIES})
-set(Boost_LIBRARIES)
 find_package(Boost ${_BOOST_MIN_VERSION} COMPONENTS program_options REQUIRED)
-set(BOOST_PROGRAM_OPTIONS_LIBRARIES ${Boost_LIBRARIES})
 set(Boost_LIBRARIES)
 find_package(Boost ${_BOOST_MIN_VERSION} COMPONENTS regex REQUIRED)
 set(BOOST_REGEX_LIBRARIES ${Boost_LIBRARIES})
-#find_package(Boost ${_BOOST_MIN_VERSION} COMPONENTS math REQUIRED)
-#set(BOOST_MATH_LIBRARIES ${Boost_LIBRARIES})
 
+        
 find_package(Qt4 4.5.0 REQUIRED)
 find_package(OpenGL REQUIRED)
 find_package(PNG REQUIRED)
@@ -220,6 +222,18 @@ if (ENABLE_IMG)
   find_package(TIFF REQUIRED)
 endif()
 
+
+if (ENABLE_STATIC)
+  set(Boost_LIBRARIES)
+  set(Boost_USE_STATIC_LIBS ON)
+  find_package(Boost ${_BOOST_MIN_VERSION} 
+               COMPONENTS filesystem system iostreams regex REQUIRED)
+  message(${Boost_LIBRARIES})
+  find_package(ZLIB REQUIRED)
+  set(STATIC_LIBRARIES ${Boost_LIBRARIES} ${FFTW_LIBRARIES} ${TIFF_LIBRARIES} 
+      ${PNG_LIBRARIES} ${ZLIB_LIBRARIES})
+endif()
+
 if (ENABLE_GUI)
   ost_find_python_module(sip)
   ost_find_python_module(PyQt4)
@@ -272,11 +286,5 @@ message(STATUS
         "   Profiling support             (-DPROFILE) : ${_PROFILE}\n"
         "   Double Precision (-DUSE_DOUBLE_PRECISION) : ${_DOUBLE_PREC}\n"
         "   Compound Lib             (-DCOMPOUND_LIB) : ${_COMP_LIB}\n"
-        "   TMAlign and TMScore   (-DCOMPILE_TMTOOLS) : ${_TM_TOOLS}")
-        
-# doc target to create HTML documentation
-#set(SPHINX sphinx-build)
-#set(SPHINX_OPTIONS -c doc/conf -b html -d doc/html/doctrees)
-#add_custom_target(doc COMMAND 
-#                  ${SPHINX} ${SPHINX_OPTIONS} modules doc/html
-#                  VERBATIM)
+        "   TMAlign and TMScore   (-DCOMPILE_TMTOOLS) : ${_TM_TOOLS}\n"
+        "   Static Libraries       (-DENABLE_STATIC)  : ${ENABLE_STATIC}")
diff --git a/cmake_support/OST.cmake b/cmake_support/OST.cmake
index 9d928f6c946de5ce7a3c3f1d64991a98b2392d02..ed57c7400d716f16d804090eae93d3c9c0ae0c64 100644
--- a/cmake_support/OST.cmake
+++ b/cmake_support/OST.cmake
@@ -136,7 +136,7 @@ macro(module)
   #-----------------------------------------------------------------------------
   set(_ARGS "NAME;SOURCES;HEADERS;DEPENDS_ON;LINK;HEADER_OUTPUT_DIR;PREFIX")
   set(_ARG_PREFIX ost)  
-  parse_argument_list(_ARG "${_ARGS}" "" ${ARGN})  
+  parse_argument_list(_ARG "${_ARGS}" "NO_STATIC" ${ARGN})  
   if (NOT _ARG_NAME)
     message(FATAL_ERROR 
             "invalid use of module(): a module name must be provided")
@@ -178,7 +178,7 @@ macro(module)
       endif()
     endforeach()
     add_library(${_LIB_NAME} SHARED ${_ABS_SOURCE_NAMES})
-    
+
     set_target_properties(${_LIB_NAME} 
                           PROPERTIES OUTPUT_NAME ${_LIB_NAME}
                                      PROJECT_LABEL ${_ARG_NAME}
@@ -191,6 +191,25 @@ macro(module)
                           LIBRARY_OUTPUT_DIRECTORY ${LIB_STAGE_PATH}
                           ARCHIVE_OUTPUT_DIRECTORY ${LIB_STAGE_PATH}
                           RUNTIME_OUTPUT_DIRECTORY ${LIB_STAGE_PATH})
+    if (ENABLE_STATIC AND NOT _ARG_NO_STATIC)
+      add_library(${_LIB_NAME}_static STATIC ${_ABS_SOURCE_NAMES})
+      set_target_properties(${_LIB_NAME}_static
+                            PROPERTIES OUTPUT_NAME ${_LIB_NAME}
+                                       PROJECT_LABEL ${_ARG_NAME}
+                                       EchoString   ${_ARG_NAME}
+                                       MODULE_DEPS "${_ARG_DEPENDS_ON}")
+      get_target_property(_DEFS ${_LIB_NAME}_static COMPILE_DEFINITIONS)
+      set_target_properties(${_LIB_NAME}_static PROPERTIES
+                            COMPILE_DEFINITIONS OST_MODULE_${_UPPER_LIB_NAME})
+      set_target_properties(${_LIB_NAME}_static PROPERTIES
+                            LIBRARY_OUTPUT_DIRECTORY ${LIB_STAGE_PATH}
+                            ARCHIVE_OUTPUT_DIRECTORY ${LIB_STAGE_PATH}
+                            RUNTIME_OUTPUT_DIRECTORY ${LIB_STAGE_PATH})
+      foreach(_DEPENDENCY ${_ARG_DEPENDS_ON})
+        target_link_libraries(${_LIB_NAME}_static ost_${_DEPENDENCY}_static)
+      endforeach()
+      target_link_libraries(${_LIB_NAME} ${ZLIB_LIBRARIES})
+    endif()
     if (APPLE)
       set_target_properties(${_LIB_NAME} PROPERTIES
                             LINK_FLAGS "-Wl,-rpath,."
@@ -268,20 +287,24 @@ endmacro()
 #-------------------------------------------------------------------------------
 macro(executable)
   parse_argument_list(_ARG 
-                      "NAME;SOURCES;LINK;DEPENDS_ON" "NO_RPATH" ${ARGN})
+                      "NAME;SOURCES;LINK;DEPENDS_ON" "NO_RPATH;STATIC" ${ARGN})
   if (NOT _ARG_NAME)
     message(FATAL_ERROR "invalid use of executable(): a name must be provided")
   endif()
   add_executable(${_ARG_NAME} ${_ARG_SOURCES})
-  if (APPLE AND NOT _ARG_NO_RPATH)
+  if (APPLE AND NOT _ARG_NO_RPATH AND NOT _ARG_STATIC)
     set_target_properties(${_ARG_NAME} PROPERTIES
                           LINK_FLAGS "-Wl,-rpath,@loader_path/../lib")
   endif()
   if (_ARG_LINK)
     target_link_libraries(${_ARG_NAME} ${_ARG_LINK})
   endif()
+  if (ENABLE_STATIC AND _ARG_STATIC)
+    set(TARGET_SUFFIX _static)
+    target_link_libraries(${_ARG_NAME} ${STATIC_LIBRARIES})
+  endif()
   foreach(_DEP ${_ARG_DEPENDS_ON})
-    target_link_libraries(${_ARG_NAME} ost_${_DEP})
+    target_link_libraries(${_ARG_NAME} ost_${_DEP}${TARGET_SUFFIX})
   endforeach()
   install(TARGETS ${_ARG_NAME} DESTINATION bin)
 endmacro()
diff --git a/deployment/macos/deps.py b/deployment/macos/deps.py
index 460071d1b7effb0eb7477549f9495699891729da..b74fd30ef929f8ca4c371aca8504cf09c0465a68 100644
--- a/deployment/macos/deps.py
+++ b/deployment/macos/deps.py
@@ -50,9 +50,10 @@ def collect_deps(stage_dir, components, binaries, site_packages,
     if bin_name not in pool:
       _deps_for_lib(bin_name, pool)
   for site_package in site_packages:
-    full_path=os.path.join(site_packages_dir, site_package)
+    full_path=get_python_module_path(site_package)
+    print full_path
     if not os.path.exists(full_path):
-      print 'WARNING', site_package, 'does not exists'
+      print 'WARNING:', site_package, 'does not exists'
       continue
     if os.path.isdir(full_path):
       for so_file in glob.glob(os.path.join(full_path, '*.so')):
@@ -202,6 +203,14 @@ def get_site_package_dir():
       return p[:index+len(pattern)]
   raise RuntimeError("Couldn't determine site-packages location")
 
+def get_python_module_path(module):
+  for path in sys.path:
+    full_path=os.path.join(path, module)
+    if os.path.exists(full_path):
+      return full_path
+  return None
+  
+  
 def get_python_home():
   """
   Derive Python home by looking at the location of the os module
@@ -300,7 +309,7 @@ def make_standalone(stage_dir, outdir, no_includes, force_no_rpath=False,
     open(ost_script, 'w').write(script)
     os.chmod(ost_script, 0555)
   elif use_rpath==False:
-    print 'BIG FAT WARNING: Creation bundle with @executable_path and default'
+    print 'BIG FAT WARNING: Creating bundle with @executable_path and default'
     print 'Python might not work. Test carefully before deploying.'
 
   if no_includes:
@@ -308,7 +317,7 @@ def make_standalone(stage_dir, outdir, no_includes, force_no_rpath=False,
     os.system(REMOVE_CURRENT % outdir)  
   print 'copying site-packages'
   for sp in SITE_PACKAGES:
-    src=os.path.join(site_packages, sp)  
+    src=get_python_module_path(sp)
     if os.path.isdir(src):
       shutil.copytree(src, os.path.join(outdir, 'lib/openstructure', sp))
     else:
diff --git a/doc/conf/conf.py b/doc/conf/conf.py
index e37ac88a4dba6c8b16869ba1964cb688104aa527..c99ef1783eb0c53305d4dc96d925f1a93314d499 100644
--- a/doc/conf/conf.py
+++ b/doc/conf/conf.py
@@ -49,9 +49,9 @@ copyright = u'2010, OpenStructure authors'
 # built documents.
 #
 # The short X.Y version.
-version = '1.0'
+version = '1.1'
 # The full version, including alpha/beta/rc tags.
-release = '1.0'
+release = '1.1'
 
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.
diff --git a/examples/demos/the_hammer.py b/examples/demos/the_hammer.py
index f6c77ebca38b663fd03b5e922604ccb3a3ef73e8..48970cefb16a8b9bee9a70395b2d5555f86e82cb 100644
--- a/examples/demos/the_hammer.py
+++ b/examples/demos/the_hammer.py
@@ -12,7 +12,7 @@ class Anim(QtCore.QTimer):
         self.b=b
         self.angle=0.0
         self.dir=0.01
-        self.edi=self.a.view.handle.RequestXCSEditor(mol.EditMode.UNBUFFERED_EDIT)
+        self.edi=self.a.view.handle.EditXCS(mol.UNBUFFERED_EDIT)
         QtCore.QObject.connect(self, QtCore.SIGNAL("timeout()"), self.OnTimer)
 
         
@@ -34,17 +34,15 @@ class Anim(QtCore.QTimer):
 
 def Hammer(off=geom.Vec3()):
   ent=mol.CreateEntity()
-  edi=ent.RequestXCSEditor(mol.EditMode.BUFFERED_EDIT)
+  edi=ent.EditXCS(mol.BUFFERED_EDIT)
   chain=edi.InsertChain("A")
   res=edi.AppendResidue(chain, "QUAD")
-  prop=mol.AtomProp()
-  prop.radius=1.0
-  a=edi.InsertAtom(res, "A", off+geom.Vec3(0.0, 0.0, 0.0), prop)
-  b=edi.InsertAtom(res, "B", off+geom.Vec3(0.0, 4.0, 0.0), prop)  
-  c=edi.InsertAtom(res, "C", off+geom.Vec3(2.0, 4.0, 0.0), prop)  
-  d=edi.InsertAtom(res, "D", off+geom.Vec3(2.0, 5.0, 0.0), prop)    
-  e=edi.InsertAtom(res, "E", off+geom.Vec3(-2.0, 5.0, 0.0), prop)      
-  f=edi.InsertAtom(res, "F", off+geom.Vec3(-2.0, 4.0, 0.0), prop)        
+  a=edi.InsertAtom(res, "A", off+geom.Vec3(0.0, 0.0, 0.0), "H")
+  b=edi.InsertAtom(res, "B", off+geom.Vec3(0.0, 4.0, 0.0), "H")
+  c=edi.InsertAtom(res, "C", off+geom.Vec3(2.0, 4.0, 0.0), "H")
+  d=edi.InsertAtom(res, "D", off+geom.Vec3(2.0, 5.0, 0.0), "H")
+  e=edi.InsertAtom(res, "E", off+geom.Vec3(-2.0, 5.0, 0.0), "H")
+  f=edi.InsertAtom(res, "F", off+geom.Vec3(-2.0, 4.0, 0.0), "H")
   edi.Connect(a, b)
   edi.Connect(b, c)
   edi.Connect(c, d)
@@ -55,17 +53,17 @@ def Hammer(off=geom.Vec3()):
 
 def TheWall():
   ent=mol.CreateEntity()
-  edi=ent.RequestXCSEditor(mol.EditMode.BUFFERED_EDIT)
+  edi=ent.EditXCS(mol.BUFFERED_EDIT)
   chain=edi.InsertChain("A")
   res=edi.AppendResidue(chain, "QUAD")
-  prop=mol.AtomProp()
-  prop.radius=0.25
   index=0
   for i in range(-10, 10):
     for j in range(-10, 10):
       index+=1
-      edi.InsertAtom(res, "A%d" % index, geom.Vec3(4.0, -2.0, 0.0)+
-                     geom.Vec3(i, 0, j)*0.25, prop)
+      atom=edi.InsertAtom(res, "A%d" % index, geom.Vec3(4.0, -2.0, 0.0)+
+                          geom.Vec3(i, 0, j)*0.25)
+      atom.radius=0.25
+                     
   return ent
 
 a=Hammer()
diff --git a/modules/base/tests/test_generic_property.cc b/modules/base/tests/test_generic_property.cc
index 9fad50c49e5e876868e995518cf8419975987120..8b946685cbb0da482e024adf87c0901a09217119 100644
--- a/modules/base/tests/test_generic_property.cc
+++ b/modules/base/tests/test_generic_property.cc
@@ -29,7 +29,7 @@ BOOST_AUTO_TEST_SUITE( base )
 BOOST_AUTO_TEST_CASE( test_generic_property )
 {
   EntityHandle eh=CreateEntity();
-  XCSEditor editor=eh.RequestXCSEditor();  
+  XCSEditor editor=eh.EditXCS();  
   ChainHandle ch=editor.InsertChain("A");
   ResidueHandle res = editor.AppendResidue(ch, "X");
   AtomHandle atom = editor.InsertAtom(res, "Y",geom::Vec3());
diff --git a/modules/bindings/pymod/CMakeLists.txt b/modules/bindings/pymod/CMakeLists.txt
index 86fad8a9300c311676602725b8674ae305da63b3..f91dc53d8e46178f80f41f6140a3fdcc8424ee01 100644
--- a/modules/bindings/pymod/CMakeLists.txt
+++ b/modules/bindings/pymod/CMakeLists.txt
@@ -1,2 +1,2 @@
 pymod(NAME bindings PY __init__.py lga.py hbplus.py msms.py tmtools.py 
-                       dssp.py clustalw.py utils.py)
+                       dssp.py clustalw.py utils.py naccess.py)
diff --git a/modules/bindings/pymod/clustalw.py b/modules/bindings/pymod/clustalw.py
index e737cea57baf6c7d19bd6b04874f640d379989d0..2c2fd6ebac5cf580dd1a259cb087a0ada9a127c4 100644
--- a/modules/bindings/pymod/clustalw.py
+++ b/modules/bindings/pymod/clustalw.py
@@ -3,7 +3,8 @@ from ost import settings, io, seq, LogError
 import os
 import subprocess
 
-def ClustalW(seq1, seq2=None, clustalw=None, keep_files=False, nopgap=False):
+def ClustalW(seq1, seq2=None, clustalw=None, keep_files=False, nopgap=False, 
+             clustalw_option_string=False):
   clustalw_path=settings.Locate(('clustalw', 'clustalw2'), 
                                 explicit_file_name=clustalw)
   
@@ -13,8 +14,8 @@ def ClustalW(seq1, seq2=None, clustalw=None, keep_files=False, nopgap=False):
       seq_list.AddSequence(seq1)
       seq_list.AddSequence(seq2)
     elif isinstance(seq1, str) and isinstance(seq2, str):
-      seqh1=CreateSequence("seq1", seq1)
-      seqh2=CreateSequence("seq2", seq2)
+      seqh1=seq.CreateSequence("seq1", seq1)
+      seqh2=seq.CreateSequence("seq2", seq2)
       seq_list=seq.CreateSequenceList()
       seq_list.AddSequence(seqh1)
       seq_list.AddSequence(seqh2)
@@ -34,6 +35,9 @@ def ClustalW(seq1, seq2=None, clustalw=None, keep_files=False, nopgap=False):
                                                            out)
   if nopgap:
     command+=" -nopgap"
+  if clustalw_option_string!=False:
+    command=command+" "+clustalw_option_string  #see useful flags: http://toolkit.tuebingen.mpg.de/clustalw/help_params
+
   ps=subprocess.Popen(command, shell=True, stdout=subprocess.PIPE)
   ps.stdout.readlines()
   aln=io.LoadAlignment(out)
diff --git a/modules/bindings/pymod/tmtools.py b/modules/bindings/pymod/tmtools.py
index 9405a31df86e42656ac449db07679968af097928..04db235931de9885850cc2c412cb8ed7038c6399 100644
--- a/modules/bindings/pymod/tmtools.py
+++ b/modules/bindings/pymod/tmtools.py
@@ -120,10 +120,12 @@ def _RunTmScore(tmscore, tmp_dir):
   model2_filename=os.path.join(tmp_dir, 'model02.pdb')  
   if platform.system() == "Windows":
     tmscore_path=settings.Locate('tmscore.exe', explicit_file_name=tmscore)
-    command="\"%s\" %s %s" %(os.path.normpath(tmscore_path), model1_filename, model2_filename)
+    command="\"%s\" %s %s" %(os.path.normpath(tmscore_path), model1_filename, 
+                             model2_filename)
   else:
     tmscore_path=settings.Locate('tmscore', explicit_file_name=tmscore)
-    command="\"%s\" \"%s\" \"%s\"" %(tmscore_path, model1_filename, model2_filename)
+    command="\"%s\" \"%s\" \"%s\"" % (tmscore_path, model1_filename, 
+                                      model2_filename)
   ps=subprocess.Popen(command, shell=True, stdout=subprocess.PIPE)
   ps.wait()
   lines=ps.stdout.readlines()
@@ -137,7 +139,7 @@ def TMAlign(model1, model2, tmalign=None):
   """
   tmp_dir_name=_SetupFiles((model1, model2))
   result=_RunTmAlign(tmalign, tmp_dir_name)
-  model1.handle.RequestXCSEditor().ApplyTransform(result.transform)
+  model1.handle.EditXCS().ApplyTransform(result.transform)
   _CleanupFiles(tmp_dir_name)
   return result
 def TMScore(model1, model2, tmscore=None):
@@ -146,6 +148,6 @@ def TMScore(model1, model2, tmscore=None):
   """
   tmp_dir_name=_SetupFiles((model1, model2))
   result=_RunTmScore(tmscore, tmp_dir_name)
-  model1.handle.RequestXCSEditor().ApplyTransform(result.transform)  
+  model1.handle.EditXCS().ApplyTransform(result.transform)  
   _CleanupFiles(tmp_dir_name)
   return result
diff --git a/modules/bindings/tests/test_clustalw.py b/modules/bindings/tests/test_clustalw.py
index cf8b2753ee13f39603ba05f86e55be43708cacb0..0536df8f77f868c27b93edbf92fd37a5f9a3d31d 100644
--- a/modules/bindings/tests/test_clustalw.py
+++ b/modules/bindings/tests/test_clustalw.py
@@ -15,7 +15,15 @@ class TestClustalWBindings(unittest.TestCase):
     self.pw_alignment = io.LoadAlignment("testfiles/pairwise_aln.fasta")
     self.nopgap_pw_alignment = io.LoadAlignment("testfiles/nopgap_pairwise_aln.fasta")
     self.mult_alignment = io.LoadAlignment("testfiles/multiple_aln.fasta")
-    
+
+    self.strseq1 = self.targetseq.GetGaplessString()
+    self.strseq2 = self.templseq.GetGaplessString()
+
+    self.seq1 = io.LoadSequence("testfiles/seq1.fasta")
+    self.seq2 = io.LoadSequence("testfiles/seq2.fasta")
+    self.seq1_seq2_alignment = io.LoadAlignment("testfiles/seq1_seq2_aln.fasta")
+    self.seq1_seq2_alignment_options_changed = io.LoadAlignment("testfiles/seq1_seq2_aln_options_changed.fasta")
+
   def testPairwiseClustalW(self):
     aln=clustalw.ClustalW(self.targetseq, self.templseq)
     assert self.pw_alignment.ToString(80) == aln.ToString(80), \
@@ -36,6 +44,22 @@ class TestClustalWBindings(unittest.TestCase):
     assert self.mult_alignment.ToString(80) == aln.ToString(80), \
            "Multiple alignment differs from precomputed one"
 
+  def testStringClustalW(self):
+    aln=clustalw.ClustalW(self.strseq1, self.strseq2)
+    aln.SetSequenceName(0,self.targetseq.GetName())
+    aln.SetSequenceName(1,self.templseq.GetName())
+    assert self.pw_alignment.ToString(80) == aln.ToString(80), \
+           "Pairwise alignment using two strings differs from precomputed one \n%s \n%s" \
+           %(self.pw_alignment.ToString(80),aln.ToString(80))
+
+  def testPairwiseClustalWChangedOptions(self):
+    # five residues removed two positions before the end of seq2
+    aln=clustalw.ClustalW(self.seq1,self.seq2)
+    assert self.seq1_seq2_alignment.ToString(80) == aln.ToString(80), \
+           "Pairwise alignment with default gap penalties differs from precomputed one"
+    aln=clustalw.ClustalW(self.seq1,self.seq2,clustalw_option_string="-GAPOPEN=2 -GAPEXT=0")
+    assert self.seq1_seq2_alignment_options_changed.ToString(80) == aln.ToString(80), \
+           "Pairwise alignment with modified gap penalties differs from precomputed one"
 
 if __name__ == "__main__":
   # test if clustalw package is available on system, otherwise ignore tests
diff --git a/modules/bindings/tests/testfiles/seq1.fasta b/modules/bindings/tests/testfiles/seq1.fasta
new file mode 100644
index 0000000000000000000000000000000000000000..7aa326305015b25f0416e416fe14afe19984e29a
--- /dev/null
+++ b/modules/bindings/tests/testfiles/seq1.fasta
@@ -0,0 +1,2 @@
+>target
+MAETLIKVDLNQSPYDNPQVHNRWHPDIPMAVWVEPGAEFKLETYDWTGGAIKNDDSAEDVRDVDLSTVHFLSGPVGVKGAEPGDLLVVDLLDIGARDDSLWGFNGFFSKQNGGGFLDEHFPLAQKSIWDFHGMFTKSRHIPGVNFAGLIHPGLIGCLPDPKMLASWNERETGLIATDPDRIPGLANPPNATTAHMGQMQGEARDKAAAEGARTVPPREHGGNCDIKDLSRGSRVFFPVYVDGAGLSVGDLHFSQGDGEITFCGAIEMAGWVHMKVSLIKGGMAKYGIKNPIFKPSPMTPNYKDYLIFEGISVDEKGKQHYLDVTVAYRQACLNAIEYLKKFGYSGAQAYSLLGTAPVQGHISGVVDVPNACATLWLPTEIFDFDINPTAEGPQKIITGGVDLPIAQDK
\ No newline at end of file
diff --git a/modules/bindings/tests/testfiles/seq1_seq2_aln.fasta b/modules/bindings/tests/testfiles/seq1_seq2_aln.fasta
new file mode 100644
index 0000000000000000000000000000000000000000..e735762a95916b563ad735f89eaa3c22376fd505
--- /dev/null
+++ b/modules/bindings/tests/testfiles/seq1_seq2_aln.fasta
@@ -0,0 +1,4 @@
+>target
+MAETLIKVDLNQSPYDNPQVHNRWHPDIPMAVWVEPGAEFKLETYDWTGGAIKNDDSAEDVRDVDLSTVHFLSGPVGVKGAEPGDLLVVDLLDIGARDDSLWGFNGFFSKQNGGGFLDEHFPLAQKSIWDFHGMFTKSRHIPGVNFAGLIHPGLIGCLPDPKMLASWNERETGLIATDPDRIPGLANPPNATTAHMGQMQGEARDKAAAEGARTVPPREHGGNCDIKDLSRGSRVFFPVYVDGAGLSVGDLHFSQGDGEITFCGAIEMAGWVHMKVSLIKGGMAKYGIKNPIFKPSPMTPNYKDYLIFEGISVDEKGKQHYLDVTVAYRQACLNAIEYLKKFGYSGAQAYSLLGTAPVQGHISGVVDVPNACATLWLPTEIFDFDINPTAEGPQKIITGGVDLPIAQDK
+>model
+---------------------------------VEPGAEFKLETYDWTGGAIKNDDSAEDVRDVDLSTVHFLSGPVGVKGAEPGDLLVVDLLDIGARDDSLWGFNGFFSKQNGGGFLDEHFPLAQKSIWDFHGMFTKSRHIPGVNFAGLIHPGLIGCLPDPKMLASWNERETGLIATDPDRIPGLANPPNATTAHMGQMQGEARDKAAAEGARTVPPREHGGNCDIKDLSRGSRVFFPVYVDGAGLSVGDLHFSQGDGEITFCGAIEMAGWVIK---------------------------------------------------------------------------------------------------------------------------------------
\ No newline at end of file
diff --git a/modules/bindings/tests/testfiles/seq1_seq2_aln_options_changed.fasta b/modules/bindings/tests/testfiles/seq1_seq2_aln_options_changed.fasta
new file mode 100644
index 0000000000000000000000000000000000000000..3efdc6cd889b07a900a1f63e6d5e8f1d13552af9
--- /dev/null
+++ b/modules/bindings/tests/testfiles/seq1_seq2_aln_options_changed.fasta
@@ -0,0 +1,4 @@
+>target
+MAETLIKVDLNQSPYDNPQVHNRWHPDIPMAVWVEPGAEFKLETYDWTGGAIKNDDSAEDVRDVDLSTVHFLSGPVGVKGAEPGDLLVVDLLDIGARDDSLWGFNGFFSKQNGGGFLDEHFPLAQKSIWDFHGMFTKSRHIPGVNFAGLIHPGLIGCLPDPKMLASWNERETGLIATDPDRIPGLANPPNATTAHMGQMQGEARDKAAAEGARTVPPREHGGNCDIKDLSRGSRVFFPVYVDGAGLSVGDLHFSQGDGEITFCGAIEMAGWVHMKVSLIKGGMAKYGIKNPIFKPSPMTPNYKDYLIFEGISVDEKGKQHYLDVTVAYRQACLNAIEYLKKFGYSGAQAYSLLGTAPVQGHISGVVDVPNACATLWLPTEIFDFDINPTAEGPQKIITGGVDLPIAQDK
+>model
+---------------------------------VEPGAEFKLETYDWTGGAIKNDDSAEDVRDVDLSTVHFLSGPVGVKGAEPGDLLVVDLLDIGARDDSLWGFNGFFSKQNGGGFLDEHFPLAQKSIWDFHGMFTKSRHIPGVNFAGLIHPGLIGCLPDPKMLASWNERETGLIATDPDRIPGLANPPNATTAHMGQMQGEARDKAAAEGARTVPPREHGGNCDIKDLSRGSRVFFPVYVDGAGLSVGDLHFSQGDGEITFCGAIEMAGWV------IK---------------------------------------------------------------------------------------------------------------------------------
\ No newline at end of file
diff --git a/modules/bindings/tests/testfiles/seq2.fasta b/modules/bindings/tests/testfiles/seq2.fasta
new file mode 100644
index 0000000000000000000000000000000000000000..72a58bd2acab10c6be354a59e75b28eea045a906
--- /dev/null
+++ b/modules/bindings/tests/testfiles/seq2.fasta
@@ -0,0 +1,2 @@
+>model
+VEPGAEFKLETYDWTGGAIKNDDSAEDVRDVDLSTVHFLSGPVGVKGAEPGDLLVVDLLDIGARDDSLWGFNGFFSKQNGGGFLDEHFPLAQKSIWDFHGMFTKSRHIPGVNFAGLIHPGLIGCLPDPKMLASWNERETGLIATDPDRIPGLANPPNATTAHMGQMQGEARDKAAAEGARTVPPREHGGNCDIKDLSRGSRVFFPVYVDGAGLSVGDLHFSQGDGEITFCGAIEMAGWVIK
\ No newline at end of file
diff --git a/modules/conop/src/CMakeLists.txt b/modules/conop/src/CMakeLists.txt
index 4d0840ea34d18bbe4f983c24f17d8ad8603769fd..e69c45689648a82ad4d086eb9e1657fa639d1131 100644
--- a/modules/conop/src/CMakeLists.txt
+++ b/modules/conop/src/CMakeLists.txt
@@ -23,7 +23,7 @@ ring_finder.cc
 module(NAME conop SOURCES ${OST_CONOP_SOURCES}
        HEADERS ${OST_CONOP_HEADERS} DEPENDS_ON mol geom db)
 
-executable(NAME chemdict_tool SOURCES chemdict_tool.cc DEPENDS_ON io)
+executable(NAME chemdict_tool SOURCES chemdict_tool.cc DEPENDS_ON io STATIC)
 
 if (COMPOUND_LIB)
   if (EXISTS "${COMPOUND_LIB}")
diff --git a/modules/conop/src/builder.cc b/modules/conop/src/builder.cc
index 50b7d54f0b8d9ecc5882b706f79c3760bb54fe17..60bf273a5d08b374707c93afdbaccb84741364d9 100644
--- a/modules/conop/src/builder.cc
+++ b/modules/conop/src/builder.cc
@@ -147,7 +147,11 @@ String Builder::GuessAtomElement(const String& aname, bool hetatm)
       if(ele==l3[i]) return ele;
     }
   }
-  return String(1, aname[0]);
+  size_t i=0;
+  while (i<aname.size() && isdigit(aname[i])) {
+    ++i;
+  }
+  return i<aname.size() ? String(1, aname[i]) : "";
 }
 
 bool Builder::AreResiduesConsecutive(const mol::ResidueHandle& r1, 
@@ -164,7 +168,7 @@ void Builder::AssignBackBoneTorsionsToResidue(mol::ResidueHandle res)
 
   mol::ResidueHandle prev=res.GetPrev();
   mol::ResidueHandle next=res.GetNext();
-  mol::XCSEditor e=res.GetEntity().RequestXCSEditor(mol::BUFFERED_EDIT);
+  mol::XCSEditor e=res.GetEntity().EditXCS(mol::BUFFERED_EDIT);
   //psi
   if (next.IsValid() && next.IsPeptideLinking()){
     mol::AtomHandle ca_this=res.FindAtom("CA");
@@ -205,7 +209,7 @@ void Builder::AssignBackBoneTorsionsToResidue(mol::ResidueHandle res)
 void Builder::DistanceBasedConnect(mol::AtomHandle atom)
 {
   mol::EntityHandle ent=atom.GetEntity();
-  mol::XCSEditor editor=ent.RequestXCSEditor(mol::BUFFERED_EDIT);
+  mol::XCSEditor editor=ent.EditXCS(mol::BUFFERED_EDIT);
   mol::AtomHandleList alist = ent.FindWithin(atom.GetPos(),4.0);
   mol::ResidueHandle res_a=atom.GetResidue();
   for (mol::AtomHandleList::const_iterator it=alist.begin(),
diff --git a/modules/conop/src/conop.cc b/modules/conop/src/conop.cc
index e992fd7d5ca8667afe8b2738e25173e0c120119b..f546f520459dc072f1095fabd2d484da7d1e0b9a 100644
--- a/modules/conop/src/conop.cc
+++ b/modules/conop/src/conop.cc
@@ -262,7 +262,7 @@ void Conopology::ConnectAll(const BuilderP& b, mol::EntityHandle eh, int flag)
 {
   Profile profile_connect("ConnectAll");
   LOG_DEBUG("Conopology: ConnectAll: building internal coordinate system");
-  mol::XCSEditor xcs_e=eh.RequestXCSEditor(mol::BUFFERED_EDIT);
+  mol::XCSEditor xcs_e=eh.EditXCS(mol::BUFFERED_EDIT);
   PropAssigner a(b);
   eh.Apply(a);
   LOG_DEBUG("Conopology: ConnectAll: connecting all bonds");
diff --git a/modules/conop/src/heuristic_builder.cc b/modules/conop/src/heuristic_builder.cc
index 55f548ae37b97fa43eb564d8a1f93cec8d1da5d7..c808dbd083f43204855c10c9dd24ff768d312508 100644
--- a/modules/conop/src/heuristic_builder.cc
+++ b/modules/conop/src/heuristic_builder.cc
@@ -195,7 +195,7 @@ void HeuristicBuilder::ConnectivityFromAtomNames(const mol::ResidueHandle& res,
                                                  mol::AtomHandleList& unknown_atoms) {
  unknown_atoms.clear();
  mol::AtomHandleList atomlist=res.GetAtomList();
- mol::XCSEditor editor=res.GetEntity().RequestXCSEditor(mol::BUFFERED_EDIT);
+ mol::XCSEditor editor=res.GetEntity().EditXCS(mol::BUFFERED_EDIT);
  for (mol::AtomHandleList::iterator it1=atomlist.begin();it1!=atomlist.end();++it1) {
    if (centry.HasAtom(it1->GetName())) {
      mol::AtomHandleList::iterator it2=it1;
@@ -265,7 +265,7 @@ void ConnectPrevNext(HeuristicBuilder* builder,mol::ResidueHandle res0,
 {
   static String fname=flag ? "HeuristicBuilder: ConnectNextXCS" : "HeuristicBuilder: ConnectPrevXCS";
   if(!res0) return; // return if invalid
-  mol::XCSEditor editor=res0.GetEntity().RequestXCSEditor(mol::BUFFERED_EDIT);
+  mol::XCSEditor editor=res0.GetEntity().EditXCS(mol::BUFFERED_EDIT);
   LOG_DEBUG(fname << " on " << res0.GetKey() << " " << res0.GetNumber());
 
   if(!res1) {
@@ -333,7 +333,7 @@ void ConnectPrevNext(HeuristicBuilder* builder,mol::ResidueHandle res0,
 void HeuristicBuilder::AssignTorsionsToResidue(mol::ResidueHandle res)
 {
 
-  mol::XCSEditor editor=res.GetEntity().RequestXCSEditor(mol::BUFFERED_EDIT);
+  mol::XCSEditor editor=res.GetEntity().EditXCS(mol::BUFFERED_EDIT);
   mol::ChainHandle chain=res.GetChain();
   std::pair<detail::ConnResEntry,bool> centry2 = LookupResEntry(res.GetKey());
   if (centry2.second) {
diff --git a/modules/conop/src/rule_based_builder.cc b/modules/conop/src/rule_based_builder.cc
index bd7b5cfcade5f2b814f0f5fc4da5bd3e9a399660..03bfb13a25deba48e28b5f24aa46a44a7954b757 100644
--- a/modules/conop/src/rule_based_builder.cc
+++ b/modules/conop/src/rule_based_builder.cc
@@ -202,7 +202,7 @@ void RuleBasedBuilder::ConnectAtomsOfResidue(mol::ResidueHandle rh)
     dist_connect(this, rh.GetAtomList());
     return;
   }
-  mol::XCSEditor e=rh.GetEntity().RequestXCSEditor(mol::BUFFERED_EDIT);
+  mol::XCSEditor e=rh.GetEntity().EditXCS(mol::BUFFERED_EDIT);
   BondSpecList::const_iterator j=last_compound_->GetBondSpecs().begin();
   mol::AtomHandleList atoms=rh.GetAtomList();
   for(; j!=last_compound_->GetBondSpecs().end(); ++j) {
@@ -232,7 +232,7 @@ void RuleBasedBuilder::ConnectResidueToNext(mol::ResidueHandle rh,
     return;
   }
   Compound::Dialect dialect=this->GetDialect()==PDB_DIALECT ? Compound::PDB : Compound::CHARMM;
-  mol::XCSEditor e=rh.GetEntity().RequestXCSEditor(mol::BUFFERED_EDIT);
+  mol::XCSEditor e=rh.GetEntity().EditXCS(mol::BUFFERED_EDIT);
   CompoundPtr mc=compound_lib_->FindCompound(rh.GetName(), dialect);
   CompoundPtr nc=compound_lib_->FindCompound(next.GetName(), dialect);
   if (!(mc && nc))
diff --git a/modules/conop/tests/test_builder.cc b/modules/conop/tests/test_builder.cc
index 0c0c54cf0357931f674235d381a627404c709406..4ba860bb1ecad1c498a7b7a42caba41138d3df03 100644
--- a/modules/conop/tests/test_builder.cc
+++ b/modules/conop/tests/test_builder.cc
@@ -34,14 +34,23 @@ BOOST_AUTO_TEST_CASE( test_builder )
 {
   BOOST_CHECK_EQUAL(Builder::GuessAtomElement("CA", false), "C");
   BOOST_CHECK_EQUAL(Builder::GuessAtomElement("CB", false), "C");
-  BOOST_CHECK_EQUAL(Builder::GuessAtomElement("N", false), "N");  
+  BOOST_CHECK_EQUAL(Builder::GuessAtomElement("N", false), "N");
   BOOST_CHECK_EQUAL(Builder::GuessAtomElement("O", false), "O");
   BOOST_CHECK_EQUAL(Builder::GuessAtomElement("CG1", false), "C");
   BOOST_CHECK_EQUAL(Builder::GuessAtomElement("CG2", false), "C");
-  BOOST_CHECK_EQUAL(Builder::GuessAtomElement("OG1", false), "O");  
+  BOOST_CHECK_EQUAL(Builder::GuessAtomElement("OG1", false), "O");
   BOOST_CHECK_EQUAL(Builder::GuessAtomElement("SG", false), "S");
-  
+  BOOST_CHECK_EQUAL(Builder::GuessAtomElement("1HA", false), "H");
+  BOOST_CHECK_EQUAL(Builder::GuessAtomElement("1HB", false), "H");
+  BOOST_CHECK_EQUAL(Builder::GuessAtomElement("1DA", false), "D");
+  BOOST_CHECK_EQUAL(Builder::GuessAtomElement("1DB", false), "D");
+  BOOST_CHECK_EQUAL(Builder::GuessAtomElement("1HA", true), "H");
+  BOOST_CHECK_EQUAL(Builder::GuessAtomElement("1HB", true), "H");
+  BOOST_CHECK_EQUAL(Builder::GuessAtomElement("1DA", true), "D");
+  BOOST_CHECK_EQUAL(Builder::GuessAtomElement("1DB", true), "D");  
   BOOST_CHECK_EQUAL(Builder::GuessAtomElement("CA", true), "CA");
+  BOOST_CHECK_EQUAL(Builder::GuessAtomElement("11", true), "");
+  BOOST_CHECK_EQUAL(Builder::GuessAtomElement("11", false), "");  
 }
 
 BOOST_AUTO_TEST_SUITE_END()
diff --git a/modules/conop/tests/test_heuristic_builder.cc b/modules/conop/tests/test_heuristic_builder.cc
index 473ff46dd7c1addd82403eeebdfd09e15793ccdb..33a1aaa7606a8fcfce335c28102293b83f98b48e 100644
--- a/modules/conop/tests/test_heuristic_builder.cc
+++ b/modules/conop/tests/test_heuristic_builder.cc
@@ -33,7 +33,7 @@ namespace {
 
 ResidueHandle make_arg(ChainHandle chain) 
 {
-  XCSEditor e=chain.GetEntity().RequestXCSEditor();
+  XCSEditor e=chain.GetEntity().EditXCS();
   ResidueHandle res = e.AppendResidue(chain, "ARG");
   e.InsertAtom(res, "N",geom::Vec3(20.202,33.112,58.011));
   e.InsertAtom(res, "CA",geom::Vec3(19.396,31.903,58.033));
@@ -51,7 +51,7 @@ ResidueHandle make_arg(ChainHandle chain)
 
 ResidueHandle make_leu(ChainHandle chain) 
 {
-  XCSEditor e=chain.GetEntity().RequestXCSEditor();  
+  XCSEditor e=chain.GetEntity().EditXCS();  
   ResidueHandle res=e.AppendResidue(chain, "LEU");
 
   e.InsertAtom(res, "N", geom::Vec3(19.003,32.473,60.366));
@@ -146,7 +146,7 @@ BOOST_AUTO_TEST_SUITE( conop )
 BOOST_AUTO_TEST_CASE(name_based_connect) 
 {
   EntityHandle e=CreateEntity();
-  ChainHandle c=e.RequestXCSEditor().InsertChain("A");
+  ChainHandle c=e.EditXCS().InsertChain("A");
   ResidueHandle ile=make_leu(c);
   ResidueHandle arg=make_arg(c);
   HeuristicBuilder heuristic_builder;  
@@ -164,7 +164,7 @@ BOOST_AUTO_TEST_CASE(name_based_connect)
 
 BOOST_AUTO_TEST_CASE(test_assign_torsions){
   EntityHandle e=CreateEntity();
-  ChainHandle c=e.RequestXCSEditor().InsertChain("A");
+  ChainHandle c=e.EditXCS().InsertChain("A");
   ResidueHandle l1=make_leu(c);
   ResidueHandle a2=make_arg(c);
   ResidueHandle l3=make_leu(c);
@@ -178,7 +178,7 @@ BOOST_AUTO_TEST_CASE(test_assign_torsions){
   heuristic_builder.ConnectAtomsOfResidue(l1);
   heuristic_builder.ConnectAtomsOfResidue(a2);
   heuristic_builder.ConnectAtomsOfResidue(l3);
-  XCSEditor edi=e.RequestXCSEditor();
+  XCSEditor edi=e.EditXCS();
   edi.Connect(l1.FindAtom("C"), a2.FindAtom("N"));
   edi.Connect(a2.FindAtom("C"), l3.FindAtom("N"));  
   heuristic_builder.AssignTorsions(c);
diff --git a/modules/doc/contributing.rst b/modules/doc/contributing.rst
index 6338ff5c467310e8e83098b1fc358b3d3f7a2582..a698032336c1157391ed64abbe726d4959bbbcc8 100644
--- a/modules/doc/contributing.rst
+++ b/modules/doc/contributing.rst
@@ -14,7 +14,7 @@ Even though, technically, there is no such a thing as a central repository in gi
 
 .. code-block:: bash
 
-  git clone https:/dng.biozentrum.unibas.ch/git/ost.git
+  git clone https://dng.biozentrum.unibas.ch/git/ost.git
 
 
 For information on how to install OpenStructure from source, refer to :doc:`install`. 
@@ -38,6 +38,34 @@ Even though it is not neccessary, it is advised to carry out your changes in a s
 
 From now on, all your work will be carried out in my_branch. Make your changes and once you are happy, commit them to your repository.
 
+
+Writing Good Commit Messages
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Your commit message should have a one-line description that summarize the change and optionally a more detailed description of what the changes imply. An example from the commit history. The one-liner and the detailed description are separated by an empty line. The reason for this format is that the one-line description will be used as the subject line for the patches generated by format-patch and the ones sent to the commit mailing lists. People can quickly see if the change is of interest to that they can savely ignore the e-mail. 
+
+Additionally, they also come in handy when using the --online option of ``git log``.
+
+Writing Documentation
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+OpenStructure uses `sphinx <http://sphinx.pocoo.org>`_ as the documentation generator. The main part of the documentation  each module resides in files with the ``.rst`` extension in a sub-folder called doc.
+
+To convert the .rst files to html use the doc/make.py script:
+
+.. code-block:: bash
+
+  ost doc/make.py
+
+The script first recursively searches for modified ``.rst`` files, starting at the modules directory and copies the files that have changed to ``doc/source``. It also copies images to the source directory. Then it runs sphinx to convert the documentation to html. If no further options are given to the script, the html documentation is generated. The HTML, CSS and static media files will be put into ``doc/html/build``.
+
+For classes and functions written in Python, it is possible to tell sphinx to  extract the documentation directly from the doc-string. For example, to get the documentation for :func:`~ost.io.LoadPDB`, you can use:
+
+.. code-block:: rest
+
+  .. autofunction:: ost.io.LoadPDB
+
+
 Synchronizing with upstream changes
 --------------------------------------------------------------------------------
 
diff --git a/modules/doc/intro-01.rst b/modules/doc/intro-01.rst
index da448f8c3e05e5c03572377bf31e52af81df0c84..087a80949e252d10f680461b9a5cdf265340bf30 100644
--- a/modules/doc/intro-01.rst
+++ b/modules/doc/intro-01.rst
@@ -1,7 +1,7 @@
 Introduction to the :mod:`~ost.mol` Module
 ================================================================================
 
-For the course of this tutorial, we assume that you have :ref:`DNG up and running<start-dng>`.
+For the course of this tutorial, we assume that you have :ref:`DNG up and running <start-dng>`.
 
 Loading and inspecting a protein structure
 --------------------------------------------------------------------------------
@@ -21,7 +21,7 @@ To load a PDB file, simply type
 
 .. code-block:: python
 
-   fragment=io.LoadPDB('/path/to/examples/entity/fragment.pdb')
+   fragment=io.LoadPDB('/path/to/examples/code_fragments/entity/fragment.pdb')
 
 This will load the fragment from the specified file 'fragment.pdb' and store the 
 result in fragment.  The :func:`~ost.io.LoadPDB` has many option, which, for 
@@ -58,7 +58,7 @@ This will group the atoms by residue. And, for completeness, we will first group
 
 .. code-block:: python
 
-  for chain in fragments.chains:
+  for chain in fragment.chains:
     print 'chain', chain.name, 'has', len(chain.residues), 'residue(s)'
     for residue in chain.residues:
       print ' ', residue, 'has', len(residue.atoms), 'atom(s).'
@@ -75,17 +75,16 @@ what bonds we have in there:
     
 From these short code examples we already see how the entity is structured: On 
 one hand we have a hierarchy of chains, residues and atoms. On the other hand, 
-we have bonds that form a network overlayed on the hierarchy. This is 
-illustrated in the picture on the left. An important feature of entities is that 
-we can always assume that the hierarchy is intact. You will never find an atom 
-without residues, no residue can exist without a parent chain and chains belong 
-always to an entity. 
+we have bonds that form a network overlayed on the hierarchy. An important 
+feature of entities is that we can always assume that the hierarchy is intact. 
+You will never find an atom without residues, no residue can exist without a 
+parent chain and chains belong always to an entity. 
 
 Let There Be Shiny Graphics
 --------------------------------------------------------------------------------
 
 For visually inspecting the fragment, we now create a graphical representation 
-of the entity. The graphical representation os completely separate from the :class:`~ost.mol.EntityHandle` class. This is on purpose. When writing processing scripts, usually no graphical representation is required and things would be slowed down without any reason. The following code will take our fragment and initialise a :class:`gfx.Entity<ost.gfx.Entity>`, add it to the scene, and center the camera on it.
+of the entity. The graphical representation is completely separate from the :class:`~ost.mol.EntityHandle` class. This is on purpose. When writing processing scripts, usually no graphical representation is required and things would be slowed down without any reason. The following code will take our fragment and initialise a :class:`gfx.Entity<ost.gfx.Entity>`, add it to the scene, and center the camera on it.
 
 .. code-block:: python
   
@@ -96,8 +95,8 @@ of the entity. The graphical representation os completely separate from the :cla
 
 Now you will see the fragment in the 3D window.
 
-Use the mouse to rotate, zoom in an shift the camera. Double clicking on an atom 
-will center the camera on that atom. If you want to learn more about the 
+Use the mouse to rotate, zoom in an shift the camera. Double clicking on an 
+atom will center the camera on that atom. If you want to learn more about the 
 :mod:`~ost.gfx` module, you are encouraged to read :doc:`the gfx 
 intro<intro-03>` and the :mod:`gfx documentation<ost.gfx`.
 
diff --git a/modules/geom/pymod/export_mat3.cc b/modules/geom/pymod/export_mat3.cc
index ee66e38d6439c54dab43058f9e2d73d1cca3a56b..9f9e245324622d47862239fe3b26ea90f1183cd2 100644
--- a/modules/geom/pymod/export_mat3.cc
+++ b/modules/geom/pymod/export_mat3.cc
@@ -58,6 +58,7 @@ void export_Mat3()
   class_<Mat3>("Mat3",init<>())
     .def(init<Real,Real,Real,Real,Real,Real,Real,Real,Real>())
     .def(init<const Mat2&>())
+    .def(init<Real,Real,Real>())
     .def(self += self)
     .def(self -= self)
     .def(self + self)
diff --git a/modules/geom/src/mat3.hh b/modules/geom/src/mat3.hh
index 15815863328fe4ca1039ced2b5d48250eef952cd..d16a14f5569eaa6c84504dda1facba0a3aaf8991 100644
--- a/modules/geom/src/mat3.hh
+++ b/modules/geom/src/mat3.hh
@@ -27,10 +27,8 @@
 
 #include <ost/geom/module_config.hh>
 #include <ost/geom/mat2.hh>
-
 namespace geom {
 
-class Mat2;
 class Vec3;
 
 class DLLEXPORT_OST_GEOM Mat3:
@@ -76,8 +74,12 @@ public:
   explicit Mat3(const Real arr[9])
   {
     this->set(arr[0],arr[1],arr[2],arr[3],arr[4],arr[5],arr[6],arr[7],arr[8]);
-  }  
+  }
 
+  explicit Mat3(Real x, Real y, Real z)
+  {
+    this->set(x, 0.0, 0.0, 0.0, y, 0.0, 0.0, 0.0, z);
+  }
   //! element access
   Real& operator()(std::size_t r, std::size_t c)
   {
diff --git a/modules/gui/src/CMakeLists.txt b/modules/gui/src/CMakeLists.txt
index 1a5104a0ae28d8670eb8887fa8c3c85f4567c1ae..9ec4e834bd6b27991a71da94ca7e61d439ccfa44 100644
--- a/modules/gui/src/CMakeLists.txt
+++ b/modules/gui/src/CMakeLists.txt
@@ -453,7 +453,8 @@ module(NAME gui SOURCES ${OST_GUI_MOCS} ${OST_GUI_SOURCES}
                ${OST_GUI_HEADERS}
        DEPENDS_ON gfx io mol_alg seq_alg
        LINK ${QT_LIBRARIES} ${PYTHON_LIBRARIES} ${BOOST_PYTHON_LIBRARIES}
-            ${SPNAV_LIBRARIES})
+            ${SPNAV_LIBRARIES}
+        NO_STATIC)
             
 if (ADDITIONAL_LIBRARIES)
   target_link_libraries(ost_gui "${ADDITIONAL_LIBRARIES}")
diff --git a/modules/gui/src/file_loader.cc b/modules/gui/src/file_loader.cc
index a874742bce365399da8a5c89328fd2d19436a1e3..ac35f1a6a0bc03873dc1bdcebbdcde023b4df2eb 100644
--- a/modules/gui/src/file_loader.cc
+++ b/modules/gui/src/file_loader.cc
@@ -245,7 +245,7 @@ gfx::GfxObjP FileLoader::TryLoadEntity(const QString& filename, io::EntityIOHand
     else{
       QFileInfo file_info(filename);
       mol::EntityHandle eh=mol::CreateEntity();
-      mol::XCSEditor xcs_lock=eh.RequestXCSEditor(mol::BUFFERED_EDIT);
+      mol::XCSEditor xcs_lock=eh.EditXCS(mol::BUFFERED_EDIT);
       handler->Import(eh,filename.toStdString());
       if(handler->RequiresBuilder()) {
           conop::BuilderP builder = conop::Conopology::Instance().GetBuilder();
diff --git a/modules/gui/src/scene_selection.cc b/modules/gui/src/scene_selection.cc
index 1ef2ee7ce38eab22a77ef5e9501b349c62150b73..1a57947757e1ab0392e87936dc9774f46392b44f 100644
--- a/modules/gui/src/scene_selection.cc
+++ b/modules/gui/src/scene_selection.cc
@@ -55,7 +55,7 @@ void SceneSelection::SetActiveNodes(gfx::NodePtrList nodes, gfx::EntityP entity,
 }
 
 gfx::GfxNodeP SceneSelection::GetActiveNode(unsigned int pos) const{
-  if(pos >= 0 && pos < nodes_.size()){
+  if(pos < nodes_.size()){
     return nodes_[pos];
   }
   else{
@@ -72,7 +72,7 @@ int SceneSelection::GetActiveViewCount() const{
 }
 
 mol::EntityView SceneSelection::GetActiveView(unsigned int pos) const{
-  if(pos >=0 && pos < views_.size()){
+  if(pos < views_.size()){
     return views_[pos].GetEntityView();
   }
   else{
diff --git a/modules/gui/src/sequence_viewer/alignment_view_object.cc b/modules/gui/src/sequence_viewer/alignment_view_object.cc
index f5a08689be49aed7959370840aa7f2ce89dc79c2..1ba35dae8e5537ee4a4149f22293f3e476af3077 100644
--- a/modules/gui/src/sequence_viewer/alignment_view_object.cc
+++ b/modules/gui/src/sequence_viewer/alignment_view_object.cc
@@ -69,19 +69,6 @@ QMap<QString,int> GetGroupMap(){
   return map;
 }
 
-QColor GetColor(int cons){
-  int color = 255 - int((float(cons) / 100) * 200);
-  return QColor(color,color,color);
-}
-
-QColor GetForeGroundColor(QColor background){
-  if(background == Qt::transparent){
-    return Qt::black;
-  }
-  int gray = 255 - background.red();
-  return QColor(gray,gray,gray);
-}
-
 }
 
 QMap<QString,int> AlignmentViewObject::group_map_ = GetGroupMap();
diff --git a/modules/gui/src/tools/measure_tool.cc b/modules/gui/src/tools/measure_tool.cc
index 4247e2f830d7f859a03666693c522e530cfc88ae..fb12cad505e4f7bcbb9923e1cff3e9f5d2f6b1a4 100644
--- a/modules/gui/src/tools/measure_tool.cc
+++ b/modules/gui/src/tools/measure_tool.cc
@@ -205,12 +205,17 @@ Measurement::Measurement(mol::AtomHandleList ahl, gfx::Color col, Real line_widt
       type_=DIHE;
       name_=ahl_[0].GetQualifiedName()+" - "+ahl_[1].GetQualifiedName()+" - "
              +ahl_[2].GetQualifiedName()+" - "+ahl_[3].GetQualifiedName();
-      measurement_=57.2958*geom::Angle(geom::Plane(ahl_[0].GetPos(),
-                                                   ahl_[1].GetPos(),
-                                                   ahl_[2].GetPos()),
-                                       geom::Plane(ahl_[1].GetPos(),
-                                                   ahl_[2].GetPos(),
-                                                   ahl_[3].GetPos()));
+      geom::Plane pl1 = geom::Plane(ahl_[0].GetPos(),
+                                    ahl_[1].GetPos(),
+                                    ahl_[2].GetPos());
+      geom::Plane pl2 = geom::Plane(ahl_[1].GetPos(),
+                                    ahl_[2].GetPos(),
+                                    ahl_[3].GetPos());
+      measurement_=57.2958*geom::Angle(pl1, pl2);
+      geom::Vec3 v = geom::Vec3(ahl_[2].GetPos()-ahl_[3].GetPos());
+      if (geom::Dot(v, pl1.GetNormal())>0) {
+        measurement_*=-1;
+      }
       valid_=true;
       break;
     }
diff --git a/modules/img/base/src/CMakeLists.txt b/modules/img/base/src/CMakeLists.txt
index 97ea2ed0b32297cf7e5298ec975d221a956da806..eba4707b0b6bb048b07a6422ced7d98c772feb38 100644
--- a/modules/img/base/src/CMakeLists.txt
+++ b/modules/img/base/src/CMakeLists.txt
@@ -76,7 +76,6 @@ util.cc
 module_config.hh
 value_util.hh
 vecmat.hh
-version.hh
 mask_base_fw.hh
 mask_base.hh
 composite_mask.hh
diff --git a/modules/img/base/src/version.cc b/modules/img/base/src/version.cc
deleted file mode 100644
index 7bd94775b32dee1c47cedd763638311515f37c2f..0000000000000000000000000000000000000000
--- a/modules/img/base/src/version.cc
+++ /dev/null
@@ -1,40 +0,0 @@
-//------------------------------------------------------------------------------
-// This file is part of the OpenStructure project <www.openstructure.org>
-//
-// Copyright (C) 2008-2010 by the OpenStructure authors
-// Copyright (C) 2003-2010 by the IPLT authors
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License as published by the Free
-// Software Foundation; either version 3.0 of the License, or (at your option)
-// any later version.
-// This library is distributed in the hope that it will be useful, but WITHOUT
-// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-// FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
-// details.
-//
-// You should have received a copy of the GNU Lesser General Public License
-// along with this library; if not, write to the Free Software Foundation, Inc.,
-// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
-//------------------------------------------------------------------------------
-
-/*
-  versioning info
-
-  Author: Ansgar Philippsen
-*/
-
-#include "version.hh"
-
-#include <sstream>
-
-namespace ost { namespace img {
-
-String GetVersion()
-{
-  std::ostringstream str;
-  str << VERSION ;
-  return str.str();
-}
-
-}} // ns
diff --git a/modules/img/base/src/version.hh b/modules/img/base/src/version.hh
deleted file mode 100644
index f893148f7ffa6f0ba61657238373a869178a6b56..0000000000000000000000000000000000000000
--- a/modules/img/base/src/version.hh
+++ /dev/null
@@ -1,39 +0,0 @@
-//------------------------------------------------------------------------------
-// This file is part of the OpenStructure project <www.openstructure.org>
-//
-// Copyright (C) 2008-2010 by the OpenStructure authors
-// Copyright (C) 2003-2010 by the IPLT authors
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License as published by the Free
-// Software Foundation; either version 3.0 of the License, or (at your option)
-// any later version.
-// This library is distributed in the hope that it will be useful, but WITHOUT
-// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-// FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
-// details.
-//
-// You should have received a copy of the GNU Lesser General Public License
-// along with this library; if not, write to the Free Software Foundation, Inc.,
-// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
-//------------------------------------------------------------------------------
-
-/*
-  versioning info
-
-  Author: Ansgar Philippsen
-*/
-
-#ifndef IMG_VERSION_H
-#define IMG_VERSION_H
-
-#include <ost/img/module_config.hh>
-
-namespace ost { namespace img {
-
-DLLEXPORT_OST_IMG_BASE String GetVersion();
-
-}} // namespace img
-
-
-#endif
diff --git a/modules/index.rst b/modules/index.rst
index a23c7ecb2ef11618aac5cc099a8545451052f51d..b2f5bc3fb85ae35f058f08ee1213537d1dfe896f 100644
--- a/modules/index.rst
+++ b/modules/index.rst
@@ -28,7 +28,7 @@ For Starters
 
 **Installation**: `install from binary <http://www.openstructure.org/download/>`_ | :doc:`install from source <install>`
 
-**Tutorial Style**: :doc:`introduction <intro>` | :doc:`molecules intro <intro-01>` | :doc:`images intro <intro-02>` | :doc:`graphics intro <intro-03>`
+**Tutorial Style**: :doc:`introduction <intro>` | :doc:`molecules intro <intro-01>` | :doc:`images intro <intro-02>` | :doc:`graphics intro <intro-03>` 
 
 
 
@@ -36,7 +36,7 @@ For Starters
 Molecules
 --------------------------------------------------------------------------------
 
-**Overview**: :doc:`molecules intro <intro-01>` | :doc:`mol overview <mol/base/mol>` | :doc:`graphical entity<gfx/entity>` | :doc:`entity <mol/base/entity>`
+**Overview**: :doc:`molecules intro <intro-01>` | :doc:`mol overview <mol/base/mol>` | :doc:`graphical entity<gfx/entity>` | :doc:`entity <mol/base/entity>` | :doc:`queries <mol/base/query>`
 
 **Input/Output**: :ref:`loading and saving molecules <mol-io>`
 
diff --git a/modules/io/pymod/__init__.py b/modules/io/pymod/__init__.py
index 265f868f24815905318db728434bfcd4c3008bb5..6b4d05b816fbda4db340a72bf4faabb46b937e17 100644
--- a/modules/io/pymod/__init__.py
+++ b/modules/io/pymod/__init__.py
@@ -52,6 +52,8 @@ def LoadPDB(filename, restrict_chains="", no_hetatms=False,
   """
   Load PDB file from disk and returns one or more entities. Several options 
   allow to customize the exact behaviour of the PDB import.
+  
+  Residues are flagged as ligand if they are mentioned in a HET record.
 
   :param restrict_chains: If not an empty string, only chains listed in the
      string will be imported.
diff --git a/modules/io/pymod/export_pdb_io.cc b/modules/io/pymod/export_pdb_io.cc
index 27e62dc1c5f02cb3e8fd71c73660903823b98618..78b9652f8d3e4f33ddf4c359aa99b56e2fedce23 100644
--- a/modules/io/pymod/export_pdb_io.cc
+++ b/modules/io/pymod/export_pdb_io.cc
@@ -32,12 +32,6 @@ BOOST_PYTHON_FUNCTION_OVERLOADS(load_PDB_ov, LoadPDB, 1, 2)
 void (PDBWriter::*write_a)(const mol::EntityHandle&)=&PDBWriter::Write;
 void (PDBWriter::*write_b)(const mol::EntityView&)=&PDBWriter::Write;
 
-namespace {
-  void push_flags(unsigned int x) {PDB::PushFlags(x);}
-  unsigned int flags() {return PDB::Flags();}
-  void pop_flags() {PDB::PopFlags();}
-}
-
 void export_pdb_io()
 {
   {
diff --git a/modules/io/src/img/map_io_spi_handler.cc b/modules/io/src/img/map_io_spi_handler.cc
index 6b308f91218053490d1c9c1254ccc3cf5cf1b257..85a68a978724fc6c8d8c299ff90f7659b4d16000 100644
--- a/modules/io/src/img/map_io_spi_handler.cc
+++ b/modules/io/src/img/map_io_spi_handler.cc
@@ -152,7 +152,7 @@ void prep_header(spider_header& header, const img::Size& size, const geom::Vec3&
   String date_for_header=time_string.substr(8,2) + "-" + time_string.substr(4,3) + "-" +
                          time_string.substr(22,4) + " ";
   String time_for_header=time_string.substr(11,8);
-  String title_for_header = "Generated by OST (www.img.org)";
+  String title_for_header = "Generated by OST (www.openstructure.org)";
 
   header.fNslice = nslice;
   header.fNrow = nrow;
@@ -274,8 +274,8 @@ void header_filler(std::istream& in,  spider_header& header)
   f.read(header.szITit,160);  
 
 
-  if(header.fIform!=3.0) {
-  throw(ost::io::IOException("spiderRead: can only read 3 (3D volume)\n"));
+  if(header.fIform!=3.0  && header.fIform!=1.0) {
+  throw(ost::io::IOException("spiderRead: can only read modes 1 (2D image) or 3 (3D volume)\n"));
   }
 
 }
diff --git a/modules/io/src/mol/dcd_io.cc b/modules/io/src/mol/dcd_io.cc
index b7723de0aabe173fe750774d1aa28e23a2bbc7db..bc36cb93f9237ba3494266cb4adbe97d39c9df48 100644
--- a/modules/io/src/mol/dcd_io.cc
+++ b/modules/io/src/mol/dcd_io.cc
@@ -286,7 +286,7 @@ void DCDCoordSource::FetchFrame(uint frame)
     read_dcd_header(stream_, header_, swap_flag_, skip_flag_, gap_flag_);
     frame_start_=stream_.tellg();
     loaded_=true;
-    frame_count_=header_.num;
+    frame_count_=header_.num/stride_;
   }
   size_t frame_size=calc_frame_size(skip_flag_, gap_flag_, 
                                     header_.t_atom_count);  
diff --git a/modules/io/src/mol/entity_io_crd_handler.cc b/modules/io/src/mol/entity_io_crd_handler.cc
index 88286b78e628d869a96ee89456c8070374545c53..9f646861c1671cc85cb5167c098639def16c4838 100644
--- a/modules/io/src/mol/entity_io_crd_handler.cc
+++ b/modules/io/src/mol/entity_io_crd_handler.cc
@@ -74,20 +74,29 @@ void CRDReader::Import(mol::EntityHandle& ent)
   while(std::getline(in_,line)) {
     if(line[0]!='*') break;
   }
+
   // line contains atom count
+  std::vector<String> line_content;
   boost::trim(line);
-  //int acount = boost::lexical_cast<int>(line);
-
-  while(std::getline(in_,line)) {
-    ParseAndAddAtom(line,ent);
-  }
+  boost::split(line_content,line,boost::is_any_of(" "));
+  
+  // expanded charmm CARD format check
+  if (line_content.size() > 1 || boost::lexical_cast<int>(line_content[0]) > 99999)
+    while(std::getline(in_,line)) {
+      ParseAndAddAtomExpanded(line,ent);
+    }
+  else
+    while(std::getline(in_,line)) {
+      ParseAndAddAtom(line,ent);
+    }
+  
   LOG_INFO("imported " << chain_count_ << " chains, " << residue_count_
                 << " residues, " << atom_count_ << " atoms");  
 }
 
 void CRDReader::ParseAndAddAtom(const String& line, mol::EntityHandle& ent)
 {
-  mol::XCSEditor editor=ent.RequestXCSEditor(mol::BUFFERED_EDIT);
+  mol::XCSEditor editor=ent.EditXCS(mol::BUFFERED_EDIT);
 
   LOG_TRACE( "line: [" << line << "]" );
 
@@ -146,6 +155,68 @@ void CRDReader::ParseAndAddAtom(const String& line, mol::EntityHandle& ent)
   sequential_atom_list_.push_back(ah);
   ++atom_count_;
 }
+	
+void CRDReader::ParseAndAddAtomExpanded(const String& line, mol::EntityHandle& ent)
+{
+  mol::XCSEditor editor=ent.EditXCS(mol::BUFFERED_EDIT);
+  
+  LOG_TRACE( "line: [" << line << "]" );
+    
+  //int anum = boost::lexical_cast<int>(boost::trim_copy(line.substr(0,5)));
+  String aname = boost::trim_copy(line.substr(32,8));
+  String ele = aname.substr(0,1);
+  String rname = boost::trim_copy(line.substr(22,8));
+  int irnum = boost::lexical_cast<int>(boost::trim_copy(line.substr(112,8)));
+  String s_chain = boost::trim_copy(line.substr(102.8,8));
+  geom::Vec3 apos(boost::lexical_cast<Real>(boost::trim_copy(line.substr(40,20))),
+                  boost::lexical_cast<Real>(boost::trim_copy(line.substr(60,20))),
+                  boost::lexical_cast<Real>(boost::trim_copy(line.substr(80,20))));
+    
+  mol::ResidueKey rkey(rname);
+    
+  // some postprocessing
+  LOG_TRACE( "s_chain: [" << s_chain << "]" );
+    
+  mol::ResNum rnum(irnum);
+  
+  // determine chain and residue update
+  bool update_chain=false;
+  bool update_residue=false;
+  if(!curr_chain_) {
+    update_chain=true;
+    update_residue=true;
+  } else if(curr_chain_.GetName()!=s_chain) {
+    update_chain=true;
+    update_residue=true;
+  }
+    
+  if(!curr_residue_) {
+    update_residue=true;
+  } else if(curr_residue_.GetNumber()!=rnum) {
+    update_residue=true;
+  }
+    
+  if(update_chain) {  
+    if (!(curr_chain_=ent.FindChain(s_chain))) {
+      LOG_DEBUG("new chain " << s_chain);      
+      curr_chain_=editor.InsertChain(s_chain);
+      ++chain_count_;      
+    }
+  }
+    
+  if(update_residue) {
+    LOG_DEBUG("new residue " << rkey << " " << rnum);
+    curr_residue_=editor.AppendResidue(curr_chain_, rkey, rnum);
+    assert(curr_residue_.IsValid());
+    ++residue_count_;
+  }
+    
+  // finally add atom
+  LOG_DEBUG("adding atom " << aname << " (" << ele << ") @" << apos);
+  mol::AtomHandle ah = editor.InsertAtom(curr_residue_, aname, apos, ele);
+  sequential_atom_list_.push_back(ah);
+  ++atom_count_;
+}
 
 CRDWriter::CRDWriter(std::ostream& ostream) :
      outfile_(), outstream_(ostream), atom_count_(0)
@@ -164,7 +235,15 @@ void CRDWriter::WriteHeader(const mol::EntityView& ent)
 {
   outstream_  << "* COOR FILE CREATED BY OPENSTRUCTURE" << std::endl;
   outstream_  << "*" << std::endl;
-  outstream_  << ent.GetAtomCount() << std::endl;
+  
+  atom_total_ = ent.GetAtomCount();
+	
+  if (atom_total_ > 99999) {
+    outstream_  << format("%10i") % ent.GetAtomCount() << "  EXT" << std::endl;
+  }
+  else {
+    outstream_  << format("%5i") % ent.GetAtomCount() << std::endl;
+  }
 }
 
 bool CRDWriter::VisitAtom(const mol::AtomHandle& atom)
@@ -174,19 +253,34 @@ bool CRDWriter::VisitAtom(const mol::AtomHandle& atom)
   if (e_name=="") {
     e_name="MOL";
   }
+	
   mol::ResidueHandle res=atom.GetResidue();
-  outstream_  << format("%5i") % atom_count_
-              << format("%5i") % res.GetNumber() << " "
-              << format("%4s") % res.GetKey() << " "
-              << format("%-4s") % atom.GetName()
-              << format("%10.5f") % atom.GetPos().x
-              << format("%10.5f") % atom.GetPos().y
-              << format("%10.5f") % atom.GetPos().z << " "
-              << format("%-4s") % e_name << " "
-              << format("%-5i") % res.GetNumber() << " "
-              << format("%8.5f") % atom.GetBFactor()
-              << std::endl;
 
+  if (atom_total_ > 99999) {
+    outstream_  << format("%10i") % atom_count_
+                << format("%10i") % res.GetNumber() << "  "
+          	    << format("%-8s") % res.GetKey() << "  "
+                << format("%-8s") % atom.GetName()
+                << format("%20.10f") % atom.GetPos().x
+                << format("%20.10f") % atom.GetPos().y
+                << format("%20.10f") % atom.GetPos().z << "  "
+                << format("%-8s") % e_name << "  "
+                << format("%-8i") % res.GetNumber()
+                << format("%20.10f") % atom.GetBFactor()
+                << std::endl;
+  } else {
+    outstream_  << format("%5i") % atom_count_
+                << format("%5i") % res.GetNumber() << " "
+			    << format("%4s") % res.GetKey() << " "
+                << format("%-4s") % atom.GetName()
+                << format("%10.5f") % atom.GetPos().x
+                << format("%10.5f") % atom.GetPos().y
+                << format("%10.5f") % atom.GetPos().z << " "
+                << format("%-4s") % e_name << " "
+                << format("%-5i") % res.GetNumber() << " "
+                << format("%8.5f") % atom.GetBFactor()
+                << std::endl;
+  }
   return true;
 }
 
@@ -257,7 +351,7 @@ mol::EntityHandle LoadCRD(const String& file_name)
   conop::BuilderP builder = conop::Conopology::Instance().GetBuilder();  
   CRDReader reader(file_name);
   mol::EntityHandle ent=mol::CreateEntity();
-  mol::XCSEditor editor=ent.RequestXCSEditor(mol::BUFFERED_EDIT);
+  mol::XCSEditor editor=ent.EditXCS(mol::BUFFERED_EDIT);
   reader.Import(ent);
   conop::Conopology::Instance().ConnectAll(builder,ent);    
   return ent;
diff --git a/modules/io/src/mol/entity_io_crd_handler.hh b/modules/io/src/mol/entity_io_crd_handler.hh
index 29ffa6705e78e7b3b0fcd768bba00a13435843cd..f32693025458919f459644fc5fe1fd30ef1eeb97 100644
--- a/modules/io/src/mol/entity_io_crd_handler.hh
+++ b/modules/io/src/mol/entity_io_crd_handler.hh
@@ -41,6 +41,7 @@ public:
 private:
 
   void ParseAndAddAtom(const String& line, mol::EntityHandle& h);
+  void ParseAndAddAtomExpanded(const String& line, mol::EntityHandle& h);
 
   std::vector<mol::AtomHandle> sequential_atom_list_;
   mol::ChainHandle curr_chain_;
@@ -67,6 +68,7 @@ private:
   std::ofstream   outfile_;
   std::ostream&   outstream_;
   int atom_count_;
+  int atom_total_;
 };
 
 class DLLEXPORT_OST_IO EntityIOCRDHandler: public EntityIOHandler {
diff --git a/modules/io/src/mol/entity_io_mae_handler.cc b/modules/io/src/mol/entity_io_mae_handler.cc
index f5def7a3e0e6c944fd3bd8652fc376d4e8f9fd0b..b48cdd551bc4279f02668ab682e90a6f346f2f04 100644
--- a/modules/io/src/mol/entity_io_mae_handler.cc
+++ b/modules/io/src/mol/entity_io_mae_handler.cc
@@ -119,7 +119,7 @@ void MAEReader::Import(mol::EntityHandle& ent)
   int i_res_num=-1;
   int i_chain_name=-1;
 
-  mol::XCSEditor editor=ent.RequestXCSEditor(mol::BUFFERED_EDIT);
+  mol::XCSEditor editor=ent.EditXCS(mol::BUFFERED_EDIT);
 
   while(std::getline(in_,line)) {
     line = boost::trim_copy(line);
@@ -325,7 +325,7 @@ mol::EntityHandle LoadMAE(const String& file_name)
   conop::BuilderP builder = conop::Conopology::Instance().GetBuilder();  
   MAEReader reader(file_name);
   mol::EntityHandle ent=mol::CreateEntity();
-  mol::XCSEditor editor=ent.RequestXCSEditor(mol::BUFFERED_EDIT);
+  mol::XCSEditor editor=ent.EditXCS(mol::BUFFERED_EDIT);
   reader.Import(ent);
   conop::Conopology::Instance().ConnectAll(builder,ent);    
   return ent;
diff --git a/modules/io/src/mol/load_entity.cc b/modules/io/src/mol/load_entity.cc
index 4eda99b4a01acb435819e0a9f3905e5e01db9a39..f35178546f766148e7d5317a1c1286969ca90198 100644
--- a/modules/io/src/mol/load_entity.cc
+++ b/modules/io/src/mol/load_entity.cc
@@ -60,7 +60,7 @@ mol::EntityHandle LoadEntity(const String& filename, int flag)
 {
   LOG_DEBUG("creating emtpy entity");
   mol::EntityHandle eh=mol::CreateEntity();
-  mol::XCSEditor xcs_lock=eh.RequestXCSEditor(mol::BUFFERED_EDIT);
+  mol::XCSEditor xcs_lock=eh.EditXCS(mol::BUFFERED_EDIT);
   Import(eh,filename,flag);
   return eh;
 }
diff --git a/modules/io/src/mol/pdb_reader.cc b/modules/io/src/mol/pdb_reader.cc
index 969d9ffa158269e26a8e885b64d3b37121b4fbc3..6712019c326bba5beceb15318f51170d29d584c3 100644
--- a/modules/io/src/mol/pdb_reader.cc
+++ b/modules/io/src/mol/pdb_reader.cc
@@ -47,7 +47,7 @@ bool IEquals(const StringRef& a, const StringRef& b)
     return false;
   }
   for (size_t i=0; i<a.size(); ++i) {
-    if (toupper(a[i])!=toupper(b[i])) {
+    if (toupper(a[i])!=b[i]) {
       return false;
     }
   }
@@ -113,7 +113,8 @@ bool PDBReader::HasNext()
           IEquals(curr_line.substr(0, 6),StringRef("ANISOU ", 6)) ||
          IEquals(curr_line.substr(0, 6), StringRef("SHEET ", 6)) ||
          IEquals(curr_line.substr(0, 6), StringRef("HELIX ", 6)) ||
-         IEquals(curr_line.substr(0, 6), StringRef("MODEL ", 6)))) {
+         IEquals(curr_line.substr(0, 6), StringRef("MODEL ", 6)) ||
+         IEquals(curr_line.substr(0, 6), StringRef("HET   ", 6)))) {
        return true;
      } else if (IEquals(curr_line.rtrim(), StringRef("END", 3))) {
        hard_end_=true;
@@ -188,6 +189,21 @@ void PDBReader::Import(mol::EntityHandle& ent,
           if (!(PDB::Flags() & PDB::CHARMM_FORMAT)) {
             this->ParseHelixEntry(curr_line);            
           }
+        } else if (IEquals(curr_line.substr(0, 6), StringRef("HET   ", 6))) {
+          // remember het entry to mark the residues as ligand during ATOM import
+          char chain=curr_line[12];
+          std::pair<bool, int> num=curr_line.substr(13, 4).ltrim().to_int();
+          if (!num.first) {
+            if (PDB::Flags() && PDB::SKIP_FAULTY_RECORDS) {
+              LOG_WARNING("Invalid HET entry on line " << line_num_);
+              continue;
+            } else {
+              String msg=str(format("Invalid HET entry on line %d")%line_num_);
+              throw IOException(msg);
+            }
+          }
+          hets_.push_back(HetEntry(chain, to_res_num(num.second,
+                                   curr_line[17])));
         }
         break;
       case 'M':
@@ -231,6 +247,12 @@ void PDBReader::Import(mol::EntityHandle& ent,
                << helix_list_.size() << " helices and "
                << strand_list_.size() << " strands");
   this->AssignSecStructure(ent);
+  for (HetList::const_iterator i=hets_.begin(), e=hets_.end(); i!=e; ++i) {
+    mol::ResidueHandle res=ent.FindResidue(String(1, i->chain), i->num);
+    if (res.IsValid()) {
+      res.SetIsLigand(true);
+    }      
+  }
 }
 
 
@@ -285,6 +307,7 @@ void PDBReader::ClearState()
   hard_end_=false;
   helix_list_.clear();
   strand_list_.clear();
+  hets_.clear();
 }
 
 bool PDBReader::EnsureLineLength(const StringRef& line, size_t size)
@@ -306,6 +329,12 @@ bool PDBReader::ParseAtomIdent(const StringRef& line, int line_num,
   if (!this->EnsureLineLength(line, 27)) {
     return false;
   }
+  atom_name=line.substr(12, 4).trim();
+  if (PDB::Flags() & PDB::CALPHA_ONLY) {
+    if (atom_name!=StringRef("CA", 2)) {
+      return false;
+    }
+  }
   if (PDB::Flags() & PDB::CHARMM_FORMAT) {
     if (line.size()>73) {
       size_t width=std::min(line.size()-72, size_t(4));
@@ -326,7 +355,7 @@ bool PDBReader::ParseAtomIdent(const StringRef& line, int line_num,
     }
     LOG_WARNING("invalid atom number on line " << line_num);
   }
-  atom_name=line.substr(12, 4).trim();
+
   alt_loc=line[16];
   res_name=line.substr(17, (PDB::Flags() & PDB::CHARMM_FORMAT) ? 4 : 3).trim();
   std::pair<bool, int> res_num=line.substr(22, 4).ltrim().to_int();;
@@ -339,15 +368,6 @@ bool PDBReader::ParseAtomIdent(const StringRef& line, int line_num,
 
   char  ins_c=line[26];  
   resnum=to_res_num(res_num.second, ins_c);
-  if (PDB::Flags() & PDB::CALPHA_ONLY) {
-    if (record_type[0]=='H' || record_type[0]=='h') {
-      return false;
-    } 
-    if (atom_name!=StringRef("CA", 2)) {
-      return false;
-    }
-    return true;
-  }
   return true;
 }
 
@@ -411,7 +431,7 @@ void PDBReader::ParseAndAddAtom(const StringRef& line, int line_num,
   if (!this->EnsureLineLength(line, 54)) {
     return;
   }
-  mol::XCSEditor editor=ent.RequestXCSEditor(mol::BUFFERED_EDIT);
+  mol::XCSEditor editor=ent.EditXCS(mol::BUFFERED_EDIT);
   char alt_loc=0;
   String chain_name;
   StringRef res_name, atom_name;
diff --git a/modules/io/src/mol/pdb_reader.hh b/modules/io/src/mol/pdb_reader.hh
index 2c2ca2c1a16eadd110ad79aca78dcf31e8afc06b..f18258a73b03c3dfb6ea2b92ebace31154d89075 100644
--- a/modules/io/src/mol/pdb_reader.hh
+++ b/modules/io/src/mol/pdb_reader.hh
@@ -38,7 +38,13 @@ class DLLEXPORT_OST_IO PDBReader {
     mol::ResNum end;
     String chain;
   };
+  struct HetEntry {
+    HetEntry(char c, mol::ResNum n): chain(c), num(n) {}
+    char        chain;
+    mol::ResNum num;
+  };
   typedef std::vector<HSEntry> HSList;
+  typedef std::vector<HetEntry>  HetList;
 public:
   PDBReader(const String& filename);
   PDBReader(const boost::filesystem::path& loc);
@@ -77,12 +83,11 @@ private:
   String restrict_chains_;
   HSList helix_list_;
   HSList strand_list_;
-
   boost::filesystem::ifstream infile_;
   std::istream& instream_;
   boost::iostreams::filtering_stream<boost::iostreams::input>  in_;
   String curr_line_;
-  
+  HetList  hets_;
   // this needs to be set to true for reading pqr
   // file (i.e. pdb formatted file with charges in occupacy
   // column, and radii in b-factor column)
diff --git a/modules/io/src/mol/pdb_writer.cc b/modules/io/src/mol/pdb_writer.cc
index 8ab50da6428a8193bf420f8021d6bbea27a35f3b..e38545430ec656b1b8216b428684ac7c4d72a198 100644
--- a/modules/io/src/mol/pdb_writer.cc
+++ b/modules/io/src/mol/pdb_writer.cc
@@ -126,7 +126,12 @@ void write_atom(std::ostream& ostr, FormattedLine& line,
       line(60, 6)=fmt::LPaddedFloat(atom.GetRadius(), 2);
     } else {
       line(54, 6)=fmt::LPaddedFloat(atom.GetOccupancy(), 2);
-      line(60, 6)=fmt::LPaddedFloat(atom.GetBFactor(), 2);
+      Real bfac=atom.GetBFactor();
+      if (bfac>999.99) {
+        line(60, 6)=fmt::LPaddedFloat(999.99, 2);
+      } else {
+        line(60, 6)=fmt::LPaddedFloat(bfac, 2);
+      }
     }
     if (charmm_style) {
       line(72, 4)=fmt::RPadded(chain_name);
@@ -136,7 +141,8 @@ void write_atom(std::ostream& ostr, FormattedLine& line,
   } else {
     for (std::vector<String>::const_iterator
          i=names.begin(), e=names.end(); i!=e; ++i) {
-      p=atom.GetAltPos(*i);
+      geom::Mat4 tf=atom.GetEntity().GetTransformationMatrix();
+      p=geom::Vec3(tf*geom::Vec4(atom.GetAltPos(*i)));
       line(30, 50).Clear();
 
       if (i->size()>1) {
@@ -154,7 +160,12 @@ void write_atom(std::ostream& ostr, FormattedLine& line,
        line(60, 6)=fmt::LPaddedFloat(atom.GetRadius(), 2);
       } else {
        line(54, 6)=fmt::LPaddedFloat(atom.GetOccupancy(), 2);
-       line(60, 6)=fmt::LPaddedFloat(atom.GetBFactor(), 2);
+       Real bfac=atom.GetBFactor();
+       if (bfac>999.99) {
+         line(60, 6)=fmt::LPaddedFloat(999.99, 2);
+       } else {
+         line(60, 6)=fmt::LPaddedFloat(bfac, 2);
+       }
       }
       if (charmm_style) {
         line(72, 4)=fmt::RPadded(chain_name);
@@ -236,7 +247,10 @@ public:
     line_(0, 6)=StringRef("TER   ", 6);
     line_( 6, 5)=fmt::LPaddedInt(counter_);
     line_(17, 3)=fmt::LPadded(res.GetKey());
-    line_[21]=res.GetChain().GetName()[0];
+    if (!res.GetChain().GetName().empty()) {
+      line_[21]=res.GetChain().GetName()[0];
+    }
+
     line_(22, 4)=fmt::LPaddedInt(res.GetNumber().GetNum());
     char ins_code=res.GetNumber().GetInsCode();
     if (ins_code!=0) {
diff --git a/modules/io/src/mol/sdf_reader.cc b/modules/io/src/mol/sdf_reader.cc
index a7f70c916adf46b04133aca145d0809b721c3836..09dea4696191fd9e0c7878b20776d3ba8aaf6cfa 100644
--- a/modules/io/src/mol/sdf_reader.cc
+++ b/modules/io/src/mol/sdf_reader.cc
@@ -54,7 +54,7 @@ SDFReader::SDFReader(std::istream& instream)
 void SDFReader::Import(mol::EntityHandle& ent)
 {
   String line;
-  mol::XCSEditor editor=ent.RequestXCSEditor(mol::BUFFERED_EDIT);
+  mol::XCSEditor editor=ent.EditXCS(mol::BUFFERED_EDIT);
   while (std::getline(instream_,line)) {
     ++line_num;
 
diff --git a/modules/io/tests/test_io_pdb.cc b/modules/io/tests/test_io_pdb.cc
index fe1abe329fcb5b408dbcc397583cd462ff119a88..5f8f6598137f6f4a1d451c67a894cf40a44cb370 100644
--- a/modules/io/tests/test_io_pdb.cc
+++ b/modules/io/tests/test_io_pdb.cc
@@ -139,8 +139,17 @@ BOOST_AUTO_TEST_CASE(calpha_only_import_on)
   mol::EntityHandle ent=mol::CreateEntity();
   reader.Import(ent);
   PDB::PopFlags();
-  BOOST_CHECK_EQUAL(ent.GetResidueCount(), 1);
-  BOOST_CHECK_EQUAL(ent.GetAtomCount(), 1);
+  BOOST_CHECK_EQUAL(ent.GetResidueCount(), 2);
+  BOOST_CHECK_EQUAL(ent.GetAtomCount(), 2);
+}
+
+BOOST_AUTO_TEST_CASE(het_import)
+{
+  String fname("testfiles/pdb/het.pdb");
+  PDBReader reader(fname);
+  mol::EntityHandle ent=mol::CreateEntity();
+  reader.Import(ent);
+  BOOST_CHECK_EQUAL(ent.Select("ligand=true").GetResidueCount(), 1);
 }
 
 BOOST_AUTO_TEST_CASE(calpha_only_import_off)
@@ -221,7 +230,7 @@ BOOST_AUTO_TEST_CASE(write_atom)
   PDBWriter writer(out);
   
   mol::EntityHandle ent=mol::CreateEntity();
-  mol::XCSEditor edi=ent.RequestXCSEditor();
+  mol::XCSEditor edi=ent.EditXCS();
   mol::ChainHandle ch=edi.InsertChain("A");
   mol::ResidueHandle r=edi.AppendResidue(ch, "GLY");
 
@@ -242,7 +251,7 @@ BOOST_AUTO_TEST_CASE(write_hetatom)
   PDBWriter writer(out);
   
   mol::EntityHandle ent=mol::CreateEntity();
-  mol::XCSEditor edi=ent.RequestXCSEditor();
+  mol::XCSEditor edi=ent.EditXCS();
   mol::ChainHandle ch=edi.InsertChain("A");
   mol::ResidueHandle r=edi.AppendResidue(ch, "CA");
   mol::AtomHandle a=edi.InsertAtom(r, "CA", geom::Vec3(32.0, -128.0, -2.5), 
@@ -374,13 +383,38 @@ BOOST_AUTO_TEST_CASE(write_conect)
                             "testfiles/pdb/conect-out.pdb"));
 }
 
+BOOST_AUTO_TEST_CASE(alt_loc_tf)
+{
+  String fname("testfiles/pdb/alt-loc.pdb");  
+  // this scope is required to force the writer stream to be closed before 
+  // opening the file again in compare_files. Avoids a race condition.
+  mol::EntityHandle ent=mol::CreateEntity();  
+  PDBReader reader(fname);
+  reader.Import(ent);
+  String out_name("testfiles/pdb/alt-loc-tf-out.pdb");
+  {
+    PDBWriter writer(out_name);
+    geom::Mat4 shift;
+    shift.PasteTranslation(geom::Vec3(10,20,30));
+    ent.EditXCS().ApplyTransform(shift);
+    writer.Write(ent);
+  }
+  PDBReader r2(out_name);
+  mol::EntityHandle ent2=mol::CreateEntity();
+  r2.Import(ent2);
+  mol::ResidueHandle res1=ent2.FindResidue("A", mol::ResNum(1));
+  mol::AtomHandle a1=res1.FindAtom("N");
+  BOOST_CHECK_EQUAL(res1.GetAltAtomPos(a1, "A"), geom::Vec3(26,84,30));
+  BOOST_CHECK_EQUAL(res1.GetAltAtomPos(a1, "B"), geom::Vec3(18,-108,30));  
+}
+
 BOOST_AUTO_TEST_CASE(res_name_too_long)
 {
   std::stringstream out;
   PDBWriter writer(out);
   
   mol::EntityHandle ent=mol::CreateEntity();
-  mol::XCSEditor edi=ent.RequestXCSEditor();
+  mol::XCSEditor edi=ent.EditXCS();
   mol::ChainHandle ch=edi.InsertChain("A");
   mol::ResidueHandle r=edi.AppendResidue(ch, "CALCIUM");
   mol::AtomHandle a=edi.InsertAtom(r, "CA", geom::Vec3(32.0, -128.0, -2.5));
@@ -393,7 +427,7 @@ BOOST_AUTO_TEST_CASE(chain_name_too_long)
   PDBWriter writer(out);
   
   mol::EntityHandle ent=mol::CreateEntity();
-  mol::XCSEditor edi=ent.RequestXCSEditor();
+  mol::XCSEditor edi=ent.EditXCS();
   mol::ChainHandle ch=edi.InsertChain("AB");
   mol::ResidueHandle r=edi.AppendResidue(ch, "CA");
   mol::AtomHandle a=edi.InsertAtom(r, "CA", geom::Vec3(32.0, -128.0, -2.5));
@@ -406,7 +440,7 @@ BOOST_AUTO_TEST_CASE(atom_name_too_long)
   PDBWriter writer(out);
   
   mol::EntityHandle ent=mol::CreateEntity();
-  mol::XCSEditor edi=ent.RequestXCSEditor();
+  mol::XCSEditor edi=ent.EditXCS();
   mol::ChainHandle ch=edi.InsertChain("A");
   mol::ResidueHandle r=edi.AppendResidue(ch, "CA");
   mol::AtomHandle a=edi.InsertAtom(r, "CALCIUM", geom::Vec3(32.0, -128.0, -2.5));
diff --git a/modules/io/tests/testfiles/pdb/het.pdb b/modules/io/tests/testfiles/pdb/het.pdb
new file mode 100644
index 0000000000000000000000000000000000000000..f8fa944aa32acf2922dab16061d777d3a0ef42ce
--- /dev/null
+++ b/modules/io/tests/testfiles/pdb/het.pdb
@@ -0,0 +1,13 @@
+HET    AP5  A1215C     64                                                       
+ATOM     20  N   ILE A   3      26.039  48.836  36.139  1.00 21.59           N  
+ATOM     21  CA  ILE A   3      24.961  47.988  35.671  1.00 23.90           C  
+ATOM     22  C   ILE A   3      25.374  47.080  34.537  1.00 21.12           C  
+ATOM     23  O   ILE A   3      26.029  47.614  33.642  1.00 24.59           O  
+ATOM     24  CB  ILE A   3      23.802  48.880  35.202  1.00 23.84           C  
+ATOM     25  CG1 ILE A   3      23.317  49.724  36.378  1.00 26.14           C  
+ATOM     26  CG2 ILE A   3      22.660  48.010  34.642  1.00 19.29           C  
+ATOM     27  CD1 ILE A   3      22.436  50.890  35.992  1.00 24.97           C  
+HETATM 3320  PA  AP5 A1215C     18.089  46.955  20.531  1.00 17.77           P  
+HETATM 3321  O1A AP5 A1215C     17.885  47.954  21.576  1.00 16.47           O  
+HETATM 3322  O2A AP5 A1215C     18.847  47.325  19.359  1.00 15.16           O  
+END                                                                             
diff --git a/modules/mol/alg/pymod/wrap_mol_alg.cc b/modules/mol/alg/pymod/wrap_mol_alg.cc
index 67f4fbf9e13454d105b0f69844297b06a1508309..91a9a0904041a90bf502a8c4ecb00e7cbe99c7c0 100644
--- a/modules/mol/alg/pymod/wrap_mol_alg.cc
+++ b/modules/mol/alg/pymod/wrap_mol_alg.cc
@@ -17,14 +17,12 @@
 // 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 //------------------------------------------------------------------------------
 
-/*
- * Author Juergen Haas
- */
 #include <boost/python.hpp>
 #include <ost/config.hh>
 #include <ost/mol/alg/local_dist_test.hh>
 #include <ost/mol/alg/superpose_frames.hh>
 using namespace boost::python;
+using namespace ost;
 
 void export_svdSuperPose();
 
@@ -32,6 +30,12 @@ void export_svdSuperPose();
 void export_entity_to_density();
 #endif
 
+namespace {
+  
+Real (*ldt_a)(const mol::EntityView&, const mol::EntityView& ref, Real, Real)=&mol::alg::LocalDistTest;
+Real (*ldt_b)(const seq::AlignmentHandle&,Real, Real, int, int)=&mol::alg::LocalDistTest;
+}
+
 BOOST_PYTHON_MODULE(_mol_alg)
 {
   export_svdSuperPose();
@@ -39,8 +43,9 @@ BOOST_PYTHON_MODULE(_mol_alg)
   export_entity_to_density();
   #endif
   
-  def("LocalDistTest", &ost::mol::alg::LocalDistTest);
+  def("LocalDistTest", ldt_a);
+  def("LocalDistTest", ldt_b, (arg("ref_index")=0, arg("mdl_index")=1));
   def("SuperposeFrames", &ost::mol::alg::SuperposeFrames, 
       (arg("source"), arg("sel")=ost::mol::EntityView(), arg("begin")=0, 
-       arg("end")=-1, arg("ref")=-1));  
+       arg("end")=-1, arg("ref")=-1));
 }
diff --git a/modules/mol/alg/src/CMakeLists.txt b/modules/mol/alg/src/CMakeLists.txt
index e613a9c735cff3588598ae612eec5ff0ce805202..15e93c0e72ade2450464aaa55551828073dc1ce3 100644
--- a/modules/mol/alg/src/CMakeLists.txt
+++ b/modules/mol/alg/src/CMakeLists.txt
@@ -13,7 +13,7 @@ set(OST_MOL_ALG_SOURCES
   superpose_frames.cc
 )
 
-set(MOL_ALG_DEPS mol)
+set(MOL_ALG_DEPS mol seq)
 
 if (ENABLE_IMG)
   set(OST_MOL_ALG_HEADERS
@@ -29,6 +29,9 @@ if (ENABLE_IMG)
   set(MOL_ALG_DEPS ${MOL_ALG_DEPS} img img_alg)
 endif()
 
+executable(NAME ldt SOURCES ldt.cc 
+           DEPENDS_ON io mol_alg STATIC)
+
 module(NAME mol_alg SOURCES ${OST_MOL_ALG_SOURCES}
        HEADERS ${OST_MOL_ALG_HEADERS}
        HEADER_OUTPUT_DIR ost/mol/alg
diff --git a/modules/mol/alg/src/ldt.cc b/modules/mol/alg/src/ldt.cc
new file mode 100644
index 0000000000000000000000000000000000000000..589bd125f72b2abbba2921877a8b7b64618a3417
--- /dev/null
+++ b/modules/mol/alg/src/ldt.cc
@@ -0,0 +1,94 @@
+#include <ost/mol/alg/local_dist_test.hh>
+#include <ost/io/mol/pdb_reader.hh>
+#include <ost/io/io_exception.hh>
+using namespace ost;
+using namespace ost::io;
+using namespace ost::mol;
+
+EntityHandle load(const String& file)
+{
+  try {
+    PDBReader reader(file);
+    if (reader.HasNext()) {
+      EntityHandle ent=CreateEntity();
+      reader.Import(ent);
+      return ent;
+    }
+    std::cerr << "ERROR: '" << file << "' does not contain any ATOM records. " 
+              << "Are you sure this is a PDB file?" << std::endl;
+    return EntityHandle();
+  } catch (io::IOException& e) {
+    std::cerr << "ERROR: " << e.what() << std::endl;
+    return EntityHandle();
+  }
+}
+
+void usage()
+{
+  std::cerr << "usage: ldt [options] <mod1> [mod1 [mod2]] <ref>" << std::endl;
+  std::cerr << "   -s        selection performed on ref" << std::endl;
+  std::cerr << "   -c        use Calphas only" << std::endl;
+  std::cerr << "   -f        filter clashes (not implemented yet)" << std::endl;
+  std::cerr << "   -t        fault tolerant parsing" << std::endl;  
+}
+
+int main (int argc, char* const *argv)
+{
+  // parse options
+  String sel;
+  int flags=0;
+  bool filter_clashes=false;
+  char ch=0;
+  while((ch=getopt(argc, argv, "ftcs:"))!=-1) {
+    switch (ch) {
+      case 'c':
+        flags|=PDB::CALPHA_ONLY;
+        break;
+      case 't':
+        flags|=PDB::SKIP_FAULTY_RECORDS;
+        break;
+      case 'f':
+        filter_clashes=true;
+        break;
+      case 's':
+        sel=optarg;
+        break;
+      case '?':
+      default:
+        usage();
+        return -1;
+    }
+  }
+  argc-=optind;
+  argv+=optind;
+  if (argc<2) {
+    usage();
+    return -1;
+  }  
+  PDB::PushFlags(flags);
+
+  String ref_file=argv[argc-1];
+  EntityHandle ref=load(ref_file);
+  if (!ref) {
+    return -1;
+  }
+  EntityView ref_view=ref.Select(sel);
+  for (int i=0; i<argc-1; ++i) {
+    EntityHandle model=load(argv[i]);
+    if (!model) {
+      if (!(flags&PDB::SKIP_FAULTY_RECORDS)) {
+        return -1;
+      }
+      continue;
+    }
+    EntityView v=model.CreateFullView();
+    float cutoffs[]={0.5,1,2,4};
+    float ldt=0.0;
+    for (int n=0; n<4; ++n) {
+      ldt+=alg::LocalDistTest(v, ref_view, cutoffs[n], 8.0);
+    }
+    ldt/=4.0;
+    std::cout << argv[i] << " " << ldt << std::endl;
+  }
+  return 0;
+}
\ No newline at end of file
diff --git a/modules/mol/alg/src/local_dist_test.cc b/modules/mol/alg/src/local_dist_test.cc
index bd88902b0e181bb29f62da86ae41367137b23ded..de78df711c03dcfaf619de243c193b0bd70576f8 100644
--- a/modules/mol/alg/src/local_dist_test.cc
+++ b/modules/mol/alg/src/local_dist_test.cc
@@ -1,3 +1,4 @@
+#include <ost/log.hh>
 #include <ost/mol/mol.hh>
 #include "local_dist_test.hh"
 
@@ -48,11 +49,11 @@ bool swappable(const String& rname, const String& aname)
   return false;
 }
 
-std::pair<Real, Real> calc_overlap(ResidueView ref_res, 
-                                   EntityView ref,
-                                   ChainView mdl_chain, 
-                                   Real tol, Real max_dist, bool only_fixed, 
-                                   bool swap)
+std::pair<Real, Real> calc_overlap1(ResidueView ref_res, 
+                                    EntityView ref,
+                                    ChainView mdl_chain, 
+                                    Real tol, Real max_dist, bool only_fixed, 
+                                    bool swap)
 {
   std::pair<Real, Real> overlap(0.0, 0.0);
   AtomViewList ref_atoms=ref_res.GetAtomList();
@@ -81,7 +82,7 @@ std::pair<Real, Real> calc_overlap(ResidueView ref_res,
           continue;
         }
         AtomView av2=mdl_chain.FindAtom(aj->GetResidue().GetNumber(), 
-                                             aj->GetName());
+                                        aj->GetName());
         overlap.second+=1.0;
         if (!(av1 && av2)) {
           continue;
@@ -111,17 +112,106 @@ std::pair<Real, Real> calc_overlap(ResidueView ref_res,
   return overlap;
 }
 
+std::pair<Real, Real> calc_overlap2(const seq::ConstSequenceHandle& ref_seq,
+                                    const seq::ConstSequenceHandle& mdl_seq,
+                                    int pos, Real tol, Real max_dist, 
+                                    bool only_fixed, bool swap)
+{
+  std::pair<Real, Real> overlap(0.0, 0.0);
+  EntityView ref=ref_seq.GetAttachedView();
+  ResidueView ref_res=ref_seq.GetResidue(pos);
+  if (!ref_res.IsValid()) {
+    return std::pair<Real,Real>(0.0, 0.0);
+  }
+  AtomViewList ref_atoms=ref_res.GetAtomList();
+  ResidueView mdl_res=mdl_seq.GetResidue(pos);
+  AtomViewList within;
+  if (max_dist<0) {
+    within=ref.GetAtomList();
+  }  
+  for (AtomViewList::iterator ai=ref_atoms.begin(),
+       ae=ref_atoms.end(); ai!=ae; ++ai) {
+    if (ai->GetElement()=="H") { continue; }
+    String name=swap ? swapped_name(ai->GetName()) : ai->GetName();
+    AtomView av1=mdl_res ? mdl_res.FindAtom(name) : AtomView();
+    if (max_dist>=0){ 
+      within=ref.FindWithin(ai->GetPos(), max_dist);
+    }
+    for (AtomViewList::iterator aj=within.begin(),
+         ae2=within.end(); aj!=ae2; ++aj) {
+      if (aj->GetElement()=="H") { continue; }
+      if (only_fixed) {
+        if (aj->GetResidue().GetNumber()==ref_res.GetNumber()) {
+          continue;
+        }
+        if (swappable(aj->GetResidue().GetName(), aj->GetName())) {
+          continue;
+        }
+        overlap.second+=1.0;
+        // map from residue index to position in alignment
+        try {
+          int aln_pos=ref_seq.GetPos(aj->GetResidue().GetIndex());
+          ResidueView r2=mdl_seq.GetResidue(aln_pos);
+          if (!r2.IsValid()) {
+            continue;
+          }
+          AtomView av2=r2.FindAtom(aj->GetName());
+          if (!(av1 && av2)) {
+            continue;
+          }
+          Real mdl_dist=geom::Length(av1.GetPos()-av2.GetPos());
+          Real ref_dist=geom::Length(ai->GetPos()-aj->GetPos());
+          if (std::abs(mdl_dist-ref_dist)<tol) {
+            overlap.first+=1;
+          }
+        } catch(...) { }
+        continue;
+      } else {
+        if (aj->GetResidue().GetNumber()>ref_res.GetNumber()) {
+          overlap.second+=1.0;
+          try {
+           int aln_pos=ref_seq.GetPos(aj->GetResidue().GetIndex());
+            ResidueView r2=mdl_seq.GetResidue(aln_pos);
+            if (!r2.IsValid()) {
+              continue;
+            }
+            AtomView av2=r2.FindAtom(aj->GetName());
+            if (!(av1 && av2)) {
+              continue;
+            }
+            Real mdl_dist=geom::Length(av1.GetPos()-av2.GetPos());
+            Real ref_dist=geom::Length(ai->GetPos()-aj->GetPos());
+            if (std::abs(mdl_dist-ref_dist)<tol) {
+              overlap.first+=1;
+            }
+          } catch (...) { }
+        }  
+      }
+    }      
+  }
+  return overlap;
+}
+
 }
 
 Real LocalDistTest(const EntityView& mdl, const EntityView& ref,
                    Real cutoff, Real max_dist)
 {
-  ResidueViewList ref_residues=ref.GetResidueList();
+  if (!mdl.GetResidueCount()) {
+    LOG_WARNING("model structures doesn't contain any residues");
+    return 0.0;
+  }
+
+  if (!ref.GetResidueCount()) {
+    LOG_WARNING("reference structures doesn't contain any residues");
+    return 0.0;
+  }
+  ResidueViewList ref_residues=ref.GetResidueList();  
   ChainView mdl_chain=mdl.GetChainList()[0];  
   // Residues with symmetric side-chains require special treatment as there are 
   // two possible ways to name the atoms. We calculate the overlap with the 
   // fixed atoms and take the solution that gives bigger scores.
-  XCSEditor edi=ref.GetHandle().RequestXCSEditor(BUFFERED_EDIT);
+  XCSEditor edi=ref.GetHandle().EditXCS(BUFFERED_EDIT);
   for (ResidueViewList::iterator
        i=ref_residues.begin(), e=ref_residues.end(); i!=e; ++i) {
     const String rname=i->GetName();
@@ -134,10 +224,10 @@ Real LocalDistTest(const EntityView& mdl, const EntityView& ref,
       continue;
     }
 
-    std::pair<Real, Real> ov1=calc_overlap(*i, ref, mdl_chain, 
+    std::pair<Real, Real> ov1=calc_overlap1(*i, ref, mdl_chain, 
                                           cutoff, max_dist, true, 
                                           false);
-    std::pair<Real, Real> ov2=calc_overlap(*i, ref, mdl_chain, 
+    std::pair<Real, Real> ov2=calc_overlap1(*i, ref, mdl_chain, 
                                           cutoff, max_dist, true, 
                                           true); 
     if (ov1.first/ov1.second<ov2.first/ov2.second) {
@@ -148,18 +238,68 @@ Real LocalDistTest(const EntityView& mdl, const EntityView& ref,
          edi.RenameAtom(j->GetHandle(), swapped_name(j->GetName()));
        }
      }
-
     }
   }
   std::pair<Real, Real> total_ov(0.0, 0.0);
   for (ResidueViewList::iterator
        i=ref_residues.begin(), e=ref_residues.end(); i!=e; ++i) {
-     std::pair<Real, Real> ov1=calc_overlap(*i, ref, mdl_chain, cutoff, 
+     std::pair<Real, Real> ov1=calc_overlap1(*i, ref, mdl_chain, cutoff, 
                                             max_dist, false, false);
      total_ov.first+=ov1.first;
      total_ov.second+=ov1.second;
   }
-  return total_ov.first/total_ov.second;
+  return total_ov.first/(total_ov.second ? total_ov.second : 1);
+}
+
+Real LocalDistTest(const ost::seq::AlignmentHandle& aln,
+                   Real cutoff, Real max_dist, int ref_index, int mdl_index)
+{
+  seq::ConstSequenceHandle ref_seq=aln.GetSequence(ref_index);
+  seq::ConstSequenceHandle mdl_seq=aln.GetSequence(mdl_index);  
+  if (!ref_seq.HasAttachedView()) {
+    LOG_ERROR("reference sequence doesn't have a view attached.");
+    return 0.0;
+  }
+  if (!mdl_seq.HasAttachedView()) {
+    LOG_ERROR("model sequence doesn't have a view attached");
+    return 0.0;
+  }
+  XCSEditor edi=ref_seq.GetAttachedView().GetHandle().EditXCS(BUFFERED_EDIT);
+  for (int i=0; i<aln.GetLength(); ++i) {
+    ResidueView mdl_res=mdl_seq.GetResidue(i);
+    if (!mdl_res) {
+      continue;
+    }
+    String rname=mdl_res.GetName();
+    if (!(rname=="GLU" || rname=="ASP" || rname=="VAL" || rname=="TYR" || 
+         rname=="PHE" || rname=="LYS" || rname=="ARG")) {
+      continue;
+    }
+    std::pair<Real, Real> ov1=calc_overlap2(ref_seq, mdl_seq, i,
+                                            cutoff, max_dist, true, 
+                                            false);
+    std::pair<Real, Real> ov2=calc_overlap2(ref_seq, mdl_seq, i,
+                                            cutoff, max_dist, true, 
+                                            true);
+    if (ov1.first/ov1.second<ov2.first/ov2.second) {
+     AtomViewList atoms=mdl_res.GetAtomList();
+     for (AtomViewList::iterator j=atoms.begin(), 
+          e2=atoms.end(); j!=e2; ++j) {
+       if (swappable(rname, j->GetName())) {
+         edi.RenameAtom(j->GetHandle(), swapped_name(j->GetName()));
+       }
+     }
+    }
+  }
+  std::pair<Real, Real> total_ov(0.0, 0.0);
+  for (int i=0; i<aln.GetLength(); ++i) {
+     std::pair<Real, Real> ov1=calc_overlap2(ref_seq, mdl_seq, i, cutoff, 
+                                             max_dist, false, false);
+     total_ov.first+=ov1.first;
+     total_ov.second+=ov1.second;
+  }
+  return total_ov.first/(total_ov.second ? total_ov.second : 1);
+  return 0.0;
 }
 
 }}}
diff --git a/modules/mol/alg/src/local_dist_test.hh b/modules/mol/alg/src/local_dist_test.hh
index f0ba3ebea20a6138a0cf14f2a34d24839abe3ef4..ab7588cdf84d401aaee052bcfe2b390da8174b15 100644
--- a/modules/mol/alg/src/local_dist_test.hh
+++ b/modules/mol/alg/src/local_dist_test.hh
@@ -3,12 +3,17 @@
 
 #include <ost/mol/entity_view.hh>
 #include <ost/mol/alg/module_config.hh>
+#include <ost/seq/alignment_handle.hh>
 
 namespace ost { namespace mol { namespace alg {
   
 Real DLLEXPORT_OST_MOL_ALG LocalDistTest(const EntityView& mdl,
                                          const EntityView& ref,
                                          Real cutoff, Real max_dist);
+
+Real DLLEXPORT_OST_MOL_ALG LocalDistTest(const ost::seq::AlignmentHandle& aln,
+                                         Real cutoff, Real max_dist, 
+                                         int ref_index=0, int mdl_index=1);
 }}}
 
 #endif
diff --git a/modules/mol/alg/src/svd_superpose.cc b/modules/mol/alg/src/svd_superpose.cc
index 191871a9c888eca76ef2672def7d08e71281523c..90b6a8c04a6adbddbcd63cc9859ea579ad95d374 100644
--- a/modules/mol/alg/src/svd_superpose.cc
+++ b/modules/mol/alg/src/svd_superpose.cc
@@ -354,7 +354,7 @@ SuperpositionResult SuperposeAtoms(const mol::AtomViewList& atoms1,
   res.ncycles=1;
   mol::AtomView jv=atoms1.front();
   if (apply_transform){
-    mol::XCSEditor ed=jv.GetResidue().GetChain().GetEntity().GetHandle().RequestXCSEditor();
+    mol::XCSEditor ed=jv.GetResidue().GetChain().GetEntity().GetHandle().EditXCS();
     ed.ApplyTransform(res.transformation);
   }
   return res;
@@ -381,7 +381,7 @@ SuperpositionResult SuperposeSVD(const mol::EntityView& ev1,
   //save rmsd info
   res.rmsd=CalculateRMSD(ev1, ev2, res.transformation);
   if (apply_transform){
-    mol::XCSEditor ed=ev1.GetHandle().RequestXCSEditor();
+    mol::XCSEditor ed=ev1.GetHandle().EditXCS();
     ed.ApplyTransform(res.transformation);
   }
   return res;
@@ -457,7 +457,7 @@ SuperpositionResult IterativeSuperposition(mol::EntityView& ev1,
   result.entity_view2=CreateViewFromAtomList(atoms_b);
 
   if (apply_transform){
-    mol::XCSEditor ed=ev1.GetHandle().RequestXCSEditor();
+    mol::XCSEditor ed=ev1.GetHandle().EditXCS();
     ed.ApplyTransform(result.transformation);
   }
   return result;
diff --git a/modules/mol/alg/tests/test_superposition.cc b/modules/mol/alg/tests/test_superposition.cc
index 599e0e31ca8461a1302b6f9ec8b77131a66cbcb6..0d18b1aa8cb623655c332a7305de485307112d5a 100644
--- a/modules/mol/alg/tests/test_superposition.cc
+++ b/modules/mol/alg/tests/test_superposition.cc
@@ -34,7 +34,7 @@ struct Fixture {
   Fixture() {
 
     e=CreateEntity();
-    XCSEditor ed=e.RequestXCSEditor();
+    XCSEditor ed=e.EditXCS();
     c=ed.InsertChain("A");
     r=ed.AppendResidue(c, "XXX");
     ab=ed.InsertAtom(r, "A", geom::Vec3(-5,-5,-5), "C");
@@ -84,7 +84,7 @@ BOOST_AUTO_TEST_CASE(superposition_svd)
 {
   Fixture f1, f2;
   EntityView ev1 = f1.e.CreateFullView();
-  XCSEditor ed=f1.e.RequestXCSEditor();
+  XCSEditor ed=f1.e.EditXCS();
   EntityView ev2 = f2.e.CreateFullView();
   ChainHandle ch1=f1.e.GetChainList()[0];
   ResidueHandleIter rit=ch1.ResiduesBegin();
diff --git a/modules/mol/base/doc/editors.rst b/modules/mol/base/doc/editors.rst
index f224b2e1fd2290db8be073dda9d18fc36bf052db..90fff6941a7063e5a869ce437ee0e863b7e25fea 100644
--- a/modules/mol/base/doc/editors.rst
+++ b/modules/mol/base/doc/editors.rst
@@ -64,10 +64,14 @@ The basic functionality of editors is implemented in the EditorBase class.
      :type  residue_name: string
      :returns:     :class:`ResidueHandle`
   
-  .. method:: InsertAtom(residue, atom_name, pos, [prop=mol.AtomProp()])
+  .. method:: InsertAtom(residue, atom_name, pos, element="", occupancy=1.0, b_factor=0.0, is_hetatm=False)
   
     Insert new atom and add it to residue. For atoms with alternative atom
-    locations use :meth:`InsertAltAtom`.
+    locations use :meth:`InsertAltAtom`. If the element parameter is a valid 
+    element, the atom properties mass, charge, and radius are set to default 
+    values for that element. If element is an empty string (or an invalid 
+    element), the properties are set to rather meaningless default values. You 
+    may later set any of the properties manually.
     
     :param residue:   is the parent residue and must be valid
     :type residue:    :class:`ResidueHandle`
@@ -79,10 +83,18 @@ The basic functionality of editors is implemented in the EditorBase class.
     :type atom_name:  string
     :param pos:       is the position of the atom in global coordinates
     :type pos:        :class:`geom.Vec3`
-    :param prop:      are the atom's properties such as element, van der Waals 
-                      radius charge and so on. The default set of atom
-                      properties is rather meaningless.
-    :type prop:       class:`AtomProp`
+    :param element:   is the atom's element. If set to a a valid element,
+                      atom properties such as mass, charge, radius are set 
+                      based on default values for that element. If the element 
+                      string is empty, or unknown, the properties are filled 
+                      with rather meaningless default values.
+    :type element:    class:`string`
+    :param occupancy: The occupancy of the atom. between 0 and 1
+    :type occupancy:  float
+    :param b_factor:  temperature factor.
+    :type  b_factor:  float
+    :param is_hetatm: whether the atom is an atom coming from a HETATM record.
+    :type is_hetatm:  bool
     :returns:         :class:`AtomHandle`
 
 Editor for the External Coordinate System
diff --git a/modules/mol/base/doc/entity.rst b/modules/mol/base/doc/entity.rst
index e6bebee7c94e7f83b8fba0c83685cc930e039002..79df5fcf21f9bf6e9daf647b9177204124dc73cc 100644
--- a/modules/mol/base/doc/entity.rst
+++ b/modules/mol/base/doc/entity.rst
@@ -143,7 +143,7 @@ The Handle Classes
     
     See :attr:`atoms`
     
-  .. method:: RequestXCSEditor([edit_mode=mol.EditMode.BUFFERED_EDIT])
+  .. method:: EditXCS([edit_mode=mol.EditMode.BUFFERED_EDIT])
     
     Request :class:`XCSEditor` for editing the external coordinate system. This
     call will fail when there are pending changes of the internal coordinate
@@ -156,7 +156,7 @@ The Handle Classes
     
     :returns: :class:`XCSEditor`
     
-  .. method:: RequestICSEditor([edit_mode=mol.EditMode.BUFFERED_EDIT])
+  .. method:: EditICS([edit_mode=mol.EditMode.BUFFERED_EDIT])
     
     Request :class:`ICSEditor` for editing the internal coordinate system, such
     as torsions, bond lengths and angle between two bonds. This call will fail
@@ -500,7 +500,14 @@ The Handle Classes
   .. attribute:: sec_structure
   
     The secondary structure of the residue.
-    
+  
+  .. attribute:: is_ligand
+  
+    Whether the residue is a ligand. When loading PDB structures, this property 
+    is set based on the HET records. This also means, that this property will 
+    most likely not be set properly for all except PDB files coming from 
+    pdb.org.
+
   .. method:: FindAtom(atom_name)
 
     Get atom by atom name. See also :attr:`atoms`
@@ -584,25 +591,32 @@ The Handle Classes
   .. attribute:: radius
   
     The van-der-Waals radius of the atom. Also available as :meth:`GetRadius`. 
-    Read-only.
+    Read/write.
     
     :type: float
   
   .. attribute:: occupancy
   
-    The atom's occupancy in the range 0 to 1. Also available as 
-    :meth:`GetOccupancy`. Read-only.
-    
+    The atom's occupancy in the range 0 to 1. Read/write. Also available as 
+    meth:`GetOccupancy`, :meth:`SetOccupancy`.
     :type: float
+    
+  .. attribute:: b_factor
+  
+    The atom's temperature factor. Read/write. Also available as 
+    :meth:`GetBFactor`, :meth:`SetBFactor`.
+    
+    :type: float    
+
   .. attribute:: charge
     
-    The atom's charge
+    The atom's charge. Also available as :meth:`GetCharge`, :meth:`SetCharge`.
     
     :type: float
 
   .. attribute:: residue
   
-    The residue this atom belongs to.
+    The residue this atom belongs to. Read-only.
     
     :type: :class:`ResidueHandle`
   
@@ -627,11 +641,7 @@ The Handle Classes
     :type  other_atom: :class:`AtomHandle`
     :rtype: :class:`BondHandle`
 
-  .. method:: GetAtomProps()
-    
-    Get atom properties such as mass, charge, element and occupancy.
-    
-    :rtype: :class:`AtomProp`
+
 
   .. method:: GetBondCount()
     
diff --git a/modules/mol/base/doc/query.rst b/modules/mol/base/doc/query.rst
index 156a91b065fa6ea08effb64767b0afdf970b4a9a..42b1cc057fd293d145d693133dd1446c99e47ed7 100644
--- a/modules/mol/base/doc/query.rst
+++ b/modules/mol/base/doc/query.rst
@@ -197,6 +197,10 @@ index is the same for views and handles.
 
 **rbfac** (float): average B (temperature) factor of residue
 
+**ligand** (bool) Whether the residue is a ligand. For official PDB files, the ligand property is set based on HET records.
+
+**water** (bool) Whether the residue is water.
+
 Properties of Atoms
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
diff --git a/modules/mol/base/pymod/export_atom.cc b/modules/mol/base/pymod/export_atom.cc
index fe12a2f64e87b484b0cfa7cd0fdde8080dc38906..23828236e4a43096e10a0765d0347e0b0c5a9ea7 100644
--- a/modules/mol/base/pymod/export_atom.cc
+++ b/modules/mol/base/pymod/export_atom.cc
@@ -50,18 +50,25 @@ void export_Atom()
                   make_function(&AtomBase::GetName,
                                 return_value_policy<copy_const_reference>()),
                   &AtomBase::SetName)
-    .add_property("index",&AtomBase::GetIndex)
+    .add_property("index", &AtomBase::GetIndex)
     
     .def("GetRadius", &AtomBase::GetRadius)
     .def("GetElement", &AtomBase::GetElement, 
          return_value_policy<copy_const_reference>())
     .def("SetElement", &AtomBase::SetElement)
     .def("GetCharge", &AtomBase::GetCharge)
+    .def("GetBFactor", &AtomBase::GetBFactor)
+    .def("SetBFactor", &AtomBase::SetBFactor)
+    .def("SetOccupancy", &AtomBase::SetOccupancy)
+    .def("GetOccupancy", &AtomBase::GetOccupancy)
     .def("GetMass", &AtomBase::GetMass)
     .def("IsHetAtom", &AtomBase::IsHetAtom)
     .def("SetMass", &AtomBase::SetMass)
+    .add_property("b_factor", &AtomBase::GetBFactor, &AtomBase::SetBFactor)
+    .add_property("occupancy", &AtomBase::GetOccupancy, 
+                  &AtomBase::SetOccupancy)
     .def("SetCharge", &AtomBase::SetCharge)
-    .add_property("radius", &AtomBase::GetRadius)
+    .add_property("radius", &AtomBase::GetRadius, &AtomBase::SetRadius)
     .add_property("element", make_function(&AtomBase::GetElement, 
                   return_value_policy<copy_const_reference>()),
                   &AtomBase::SetElement)
diff --git a/modules/mol/base/pymod/export_editors.cc b/modules/mol/base/pymod/export_editors.cc
index 91926f2e797135940d00faeb1f544b07b0d89542..4b8d4123e175070007ee6c49b2429deefcd3dd44 100644
--- a/modules/mol/base/pymod/export_editors.cc
+++ b/modules/mol/base/pymod/export_editors.cc
@@ -54,21 +54,15 @@ void (ICSEditor::*rotate_torsion_b)(const AtomHandle&, const AtomHandle&,
                                     const AtomHandle&, const AtomHandle&,
                                     Real)=&ICSEditor::RotateTorsionAngle;
                                  
-BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(X_insert_atom_overloads, 
-                                       EditorBase::InsertAtom, 3, 4)
 }
 
 void export_Editors()
-{
-  enum_<EditMode>("EditMode")
-    .value("BUFFERED_EDIT", BUFFERED_EDIT)
-    .value("UNBUFFERED_EDIT", UNBUFFERED_EDIT)
-  ;
-  
+{  
   class_<EditorBase>("EditorBase", no_init)
     .def("InsertChain", &EditorBase::InsertChain)
     .def("InsertAtom", &EditorBase::InsertAtom,
-         X_insert_atom_overloads())
+         (arg("residue"), arg("name"), arg("pos"), arg("element")="", 
+          arg("occupancy")=1.0, arg("b_factor")=0.0, arg("is_hetatm")=false))
     .def("InsertAltAtom", &EditorBase::InsertAltAtom)
     .def("DeleteResidue", &EditorBase::DeleteResidue)
     .def("DeleteChain", &EditorBase::DeleteChain)
diff --git a/modules/mol/base/pymod/export_entity.cc b/modules/mol/base/pymod/export_entity.cc
index b0df16c0c9065f8084127b48a1055cd29090d849..b8fcff8a959679f64573b905cb9880737d703549 100644
--- a/modules/mol/base/pymod/export_entity.cc
+++ b/modules/mol/base/pymod/export_entity.cc
@@ -49,11 +49,20 @@ StringMethod select_string=&EntityHandle::Select;
 
 Real (EntityHandle::*get_angle1)(const AtomHandle&, const AtomHandle&, const AtomHandle&) const = &EntityHandle::GetAngle;
 Real (EntityHandle::*get_angle2)(const AtomView&, const AtomView&, const AtomView&) const = &EntityHandle::GetAngle;
+                                      
+XCSEditor depr_request_xcs_editor(EntityHandle e, EditMode m)
+{
+  WARN_DEPRECATED("EntityHandle::RequestXCSEditor is deprecated. Use "
+                  "EntityHandle::EditXCS instead");
+  return e.EditXCS(m);
+}
 
-BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(X_xcs_editor_overloads, 
-                                      EntityHandle::RequestXCSEditor, 0, 1)
-BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(X_ics_editor_overloads, 
-                                      EntityHandle::RequestICSEditor, 0, 1)                                      
+ICSEditor depr_request_ics_editor(EntityHandle e, EditMode m)
+{
+  WARN_DEPRECATED("EntityHandle::RequestICSEditor is deprecated. Use "
+                  "EntityHandle::EditICS instead");
+  return e.EditICS(m);
+}
 
 
 }
@@ -121,10 +130,11 @@ void export_Entity()
     .add_property("transform", 
                    make_function(&EntityHandle::GetTransformationMatrix, 
                                  return_value_policy<copy_const_reference>()))    
-    .def("RequestICSEditor", &EntityHandle::RequestICSEditor,
-         X_ics_editor_overloads(args("mode")))
-    .def("RequestXCSEditor", &EntityHandle::RequestXCSEditor,
-         X_xcs_editor_overloads(args("mode")))
+
+    .def("EditXCS", &EntityHandle::EditXCS, arg("mode")=UNBUFFERED_EDIT)
+    .def("EditICS", &EntityHandle::EditICS, arg("mode")=UNBUFFERED_EDIT)
+    .def("RequestXCSEditor", &depr_request_xcs_editor, arg("mode")=UNBUFFERED_EDIT)
+    .def("RequestICSEditor", &depr_request_ics_editor, arg("mode")=UNBUFFERED_EDIT)  
     .def("IsTransformationIdentity",&EntityHandle::IsTransformationIdentity)
     .def(self==self)
     .def(self!=self)
diff --git a/modules/mol/base/pymod/export_residue.cc b/modules/mol/base/pymod/export_residue.cc
index ef844831cb222c399cf5a4405803be9224c2c48e..66892c8de2dae95f99a73714b2a0ff3b4dfb6e20 100644
--- a/modules/mol/base/pymod/export_residue.cc
+++ b/modules/mol/base/pymod/export_residue.cc
@@ -120,6 +120,9 @@ void export_Residue()
     .def("GetChemClass", &ResidueBase::GetChemClass)
     .def("SetChemClass", set_chemclass1)
     .def("SetChemClass", set_chemclass2)
+    .add_property("is_ligand", &ResidueBase::IsLigand, &ResidueBase::SetIsLigand)
+    .def("IsLigand", &ResidueBase::IsLigand)
+    .def("SetIsLigand", &ResidueBase::SetIsLigand)
     .add_property("number",
                    make_function(&ResidueBase::GetNumber,
                                  return_value_policy<copy_const_reference>()))
@@ -161,7 +164,7 @@ void export_Residue()
     .add_property("atom_count", &ResidueHandle::GetAtomCount)
     .add_property("index", &ResidueHandle::GetIndex)
     .def("Select", select_string, arg("flags")=0)
-    .def("Select", select_query, arg("flags")=0)
+    .def("Select", select_query, arg("flags")=0)    
     .def("GetMass", &ResidueHandle::GetMass)
     .def("GetCenterOfMass", &ResidueHandle::GetCenterOfMass)
     .def("GetCenterOfAtoms", &ResidueHandle::GetCenterOfAtoms)
diff --git a/modules/mol/base/pymod/wrap_mol.cc b/modules/mol/base/pymod/wrap_mol.cc
index 6885a79020eb5a667a498766a7ae6c07df7c54e8..16db0ed59a5579e5f1fdc32f74d7b6566f93fe82 100644
--- a/modules/mol/base/pymod/wrap_mol.cc
+++ b/modules/mol/base/pymod/wrap_mol.cc
@@ -18,6 +18,7 @@
 //------------------------------------------------------------------------------
 #include <boost/python.hpp>
 #include <ost/mol/transform.hh>
+#include <ost/mol/editor_base.hh>
 #include <ost/info/info.hh>
 
 using namespace boost::python;
@@ -44,6 +45,11 @@ void export_QueryViewWrapper();
 void export_EntityPropertyMapper();
 BOOST_PYTHON_MODULE(_mol)
 {
+  enum_<EditMode>("EditMode")
+    .value("BUFFERED_EDIT", BUFFERED_EDIT)
+    .value("UNBUFFERED_EDIT", UNBUFFERED_EDIT)
+    .export_values()
+  ;
   export_Entity();
   export_Surface();
   export_Query();
diff --git a/modules/mol/base/src/atom_base.cc b/modules/mol/base/src/atom_base.cc
index 6de12176fc090aa013d084ecf1bd178153778011..a8719ab960b8e367aca7be53590d025f182de08b 100644
--- a/modules/mol/base/src/atom_base.cc
+++ b/modules/mol/base/src/atom_base.cc
@@ -188,7 +188,7 @@ void AtomBase::SetCharge(Real charge)
 void AtomBase::SetRadius(Real radius)
 {
   this->CheckValidity();
-  Impl()->SetCharge(radius);
+  Impl()->SetRadius(radius);
 }
 
 const geom::Mat3& AtomBase::GetAnisou() const
diff --git a/modules/mol/base/src/chain_handle.hh b/modules/mol/base/src/chain_handle.hh
index 6337818deeebc8356c1a08421173edc39da076ee..514188612bd03e31fea1556dfa4856924223f046 100644
--- a/modules/mol/base/src/chain_handle.hh
+++ b/modules/mol/base/src/chain_handle.hh
@@ -46,7 +46,7 @@ namespace ost { namespace mol {
 /// the residue numbers are in ascending order.
 ///
 /// New residues are inserted via one of the editors obtained from 
-/// EntityHandle::RequestXCSEditor() or EntityHandle::RequestICSEditor(). To
+/// EntityHandle::EditXCS() or EntityHandle::EditICS(). To
 /// append a residue to the C-terminal end, use EditorBase::AppendResidue, to
 /// insert after or before a specific residue, EditorBase::InsertResidueAfter
 /// and ditorBase::InsertResidueABefore will do the job, respectively.
diff --git a/modules/mol/base/src/chem_class.hh b/modules/mol/base/src/chem_class.hh
index f9c0f8279666df6fee4f2370b2ed40ba29432203..43bdef9a85cbcfc623c95eda4de7314071378fbc 100644
--- a/modules/mol/base/src/chem_class.hh
+++ b/modules/mol/base/src/chem_class.hh
@@ -18,16 +18,13 @@
 //------------------------------------------------------------------------------
 #ifndef OST_BASE_CHEM_CLASS_HI
 #define OST_BASE_CHEM_CLASS_HI
-#include <vector>
-
-#include <boost/shared_ptr.hpp>
 
 #include <ost/mol/module_config.hh>
 
 
 namespace ost { namespace mol {
 
-struct ChemClass {
+struct DLLEXPORT ChemClass {
   const static char PeptideLinking  ='P';
   const static char DPeptideLinking ='D';
   const static char LPeptideLinking ='L';
diff --git a/modules/mol/base/src/coord_source.cc b/modules/mol/base/src/coord_source.cc
index 37d1fbd91cf9ce4dba16bb3614909cf77f064111..db02718fd5bec7c2721ddf11ec3eca4bc55e0932 100644
--- a/modules/mol/base/src/coord_source.cc
+++ b/modules/mol/base/src/coord_source.cc
@@ -63,7 +63,7 @@ void CoordSource::CopyFrame(uint frame_id)
     return;
   }
   assert(frame->size()==atoms_.size());
-  XCSEditor edi=atoms_.front().GetEntity().RequestXCSEditor(BUFFERED_EDIT);  
+  XCSEditor edi=atoms_.front().GetEntity().EditXCS(BUFFERED_EDIT);  
   CoordFrame::const_iterator c=frame->begin();
   for (AtomHandleList::iterator i=atoms_.begin(), 
        e=atoms_.end(); i!=e; ++i, ++c) {
diff --git a/modules/mol/base/src/editor_base.cc b/modules/mol/base/src/editor_base.cc
index 4ed9b6a4b3bcbf2bde6cf6e4183cefe13ef06bfb..29b5d19116a9b260aa39c6be97e6051306c9ccea 100644
--- a/modules/mol/base/src/editor_base.cc
+++ b/modules/mol/base/src/editor_base.cc
@@ -78,11 +78,17 @@ void EditorBase::RenameChain(ChainHandle chain, const String& new_name)
 
 
 AtomHandle EditorBase::InsertAtom(ResidueHandle res, const String& name,
-                                  const geom::Vec3& pos, const String& ele)
+                                  const geom::Vec3& pos, const String& ele,
+                                  Real occupancy, Real b_factor, 
+                                  bool is_hetatm)
 {
   CheckHandleValidity(res);
   ent_.Impl()->MarkTraceDirty();  
-  return AtomHandle(res.Impl()->InsertAtom(name, pos, ele));
+  AtomHandle atom(res.Impl()->InsertAtom(name, pos, ele));
+  atom.SetBFactor(b_factor);
+  atom.SetHetAtom(is_hetatm);
+  atom.SetOccupancy(occupancy);
+  return atom;
 }
 
 AtomHandle EditorBase::InsertAltAtom(ResidueHandle res, const String& name,
diff --git a/modules/mol/base/src/editor_base.hh b/modules/mol/base/src/editor_base.hh
index e8a11272657de25b909201a73eca6fb2bb42e64e..964f2fdba6ce7e94c3d498c36f07ba179ba5af09 100644
--- a/modules/mol/base/src/editor_base.hh
+++ b/modules/mol/base/src/editor_base.hh
@@ -39,8 +39,8 @@ namespace ost { namespace mol {
 /// Editors are usually used as one of the concrete subclasses of EditorBase:
 /// XCSEditor and ICSEditor. The former operates on the external carthesian
 /// coordinate system while the latter operates on the internal coordinate
-/// system. To create a new editor, use EntityHandle::RequestXCSEditor() and
-/// EntityHandle::RequestICSEditor(), respectively.
+/// system. To create a new editor, use EntityHandle::EditXCS() and
+/// EntityHandle::EditICS(), respectively.
 /// 
 /// For an introduction to the concept of editors go \ref editors "here"
 class DLLEXPORT_OST_MOL EditorBase {
@@ -116,7 +116,9 @@ public:
   ///     naming.
   /// \param pos is the position of the atom in global coordinates
   AtomHandle InsertAtom(ResidueHandle residue, const String& name, 
-                        const geom::Vec3& pos, const String& ele="");
+                        const geom::Vec3& pos, const String& ele="",
+                        Real occupancy=1.0, Real b_factor=0.0, 
+                        bool is_hetatm=false);
 
   /// \brief Insert new atom with alternative position indicator
   /// \sa EditorBase::AddAltAtomPos(), ResidueHandle
diff --git a/modules/mol/base/src/entity_handle.cc b/modules/mol/base/src/entity_handle.cc
index 17c47cd81112c92ef308c598cf7c03202a1c6648..1de8bff483b9d256e0784fc68b054c31d30010e7 100644
--- a/modules/mol/base/src/entity_handle.cc
+++ b/modules/mol/base/src/entity_handle.cc
@@ -304,13 +304,13 @@ AtomHandleIter EntityHandle::AtomsEnd() const
                         impl::end(r.back()->GetAtomList()), ent, false);
 }
 
-XCSEditor EntityHandle::RequestXCSEditor(EditMode mode) const
+XCSEditor EntityHandle::EditXCS(EditMode mode) const
 {
   this->CheckValidity();
   return XCSEditor(*this, mode);
 }
 
-ICSEditor EntityHandle::RequestICSEditor(EditMode mode) const
+ICSEditor EntityHandle::EditICS(EditMode mode) const
 {
   this->CheckValidity();
   Impl()->EnableICS();
diff --git a/modules/mol/base/src/entity_handle.hh b/modules/mol/base/src/entity_handle.hh
index 540425c70219e49396c29ce19ef54850712edd70..d67d9c754d20d22ddb67ec156315388fef76be6d 100644
--- a/modules/mol/base/src/entity_handle.hh
+++ b/modules/mol/base/src/entity_handle.hh
@@ -263,12 +263,12 @@ public:
   /// \brief Get editor for external coordinate system to manipulate atom 
   ///     positions
   /// \sa editors
-  XCSEditor RequestXCSEditor(EditMode mode=UNBUFFERED_EDIT) const;
+  XCSEditor EditXCS(EditMode mode=UNBUFFERED_EDIT) const;
   
   /// \brief Get editor for the internal coordinate system to manipulate 
   ///    torsions bond lengths and angles between bonds
   /// \sa editors
-  ICSEditor RequestICSEditor(EditMode mode=UNBUFFERED_EDIT) const;  
+  ICSEditor EditICS(EditMode mode=UNBUFFERED_EDIT) const;  
   
   /// \brief get this handle
   /// 
diff --git a/modules/mol/base/src/impl/atom_impl.cc b/modules/mol/base/src/impl/atom_impl.cc
index f355416fa95cfdfd548a27b3cdc7ef613225dd91..71b714385d071805850c189783b8c511016a34d5 100644
--- a/modules/mol/base/src/impl/atom_impl.cc
+++ b/modules/mol/base/src/impl/atom_impl.cc
@@ -45,12 +45,16 @@ AtomImpl::AtomImpl(const EntityImplPtr& e,
   res_(r),
   name_(n),
   pos_(p),
+  occupancy_(0.0),
+  b_factor_(1.0),
+  prop_(NULL),  
+  is_hetatm_(false),  
   element_(ele),
-  is_hetatm_(false),
   prim_connector_(),
   connector_list_(),
   fragment_(),
   state_(0),
+
   index_(index)
 {
   EntityHandle ent = this->GetEntity();
@@ -206,6 +210,10 @@ void AtomImpl::UpdateFromXCS()
 }
 
 AtomImpl::~AtomImpl() {
+  if (prop_ && !prop_->is_default) {
+    delete prop_;
+    prop_=NULL;
+  }
 }
 
 EntityImplPtr AtomImpl::GetEntity() const
diff --git a/modules/mol/base/src/impl/atom_impl.hh b/modules/mol/base/src/impl/atom_impl.hh
index 90507b1029575ad86c811d68a07c7142a514d438..589432ca9041c600d0fba6ec850615d97e0d6cb6 100644
--- a/modules/mol/base/src/impl/atom_impl.hh
+++ b/modules/mol/base/src/impl/atom_impl.hh
@@ -119,7 +119,7 @@ public:
       prop_=impl::AtomProp::GetDefaultProps(element_);
     }
   }
-  
+  bool HasDefaultProps() const { return prop_->is_default; }
   void SetAnisou(const geom::Mat3& anisou)
   {
     if (prop_->is_default && prop_->anisou!=anisou) {
@@ -227,9 +227,9 @@ private:
   geom::Vec3   tf_pos_;
   Real         occupancy_;
   Real         b_factor_;
-  String       element_;
   AtomProp*    prop_;
   bool         is_hetatm_;
+  String       element_;  
   ConnectorImplP prim_connector_;
   ConnectorImplList connector_list_;
   FragmentImplP fragment_;
diff --git a/modules/mol/base/src/impl/chain_impl.cc b/modules/mol/base/src/impl/chain_impl.cc
index 77948203633cb010a0a81da80dd582643f6cf327..4d5313a38fbafd97e9fb0fa658febeb71743b107 100644
--- a/modules/mol/base/src/impl/chain_impl.cc
+++ b/modules/mol/base/src/impl/chain_impl.cc
@@ -66,6 +66,8 @@ ResidueImplPtr ChainImpl::AppendResidue(const ResidueImplPtr& res)
   dst_res->SetOneLetterCode(res->GetOneLetterCode());
   dst_res->SetSecStructure(res->GetSecStructure());
   dst_res->SetChemClass(res->GetChemClass());  
+  dst_res->SetProtein(res->IsProtein());
+  dst_res->SetIsLigand(res->IsLigand());
   return dst_res;
 }
 
diff --git a/modules/mol/base/src/impl/residue_impl.cc b/modules/mol/base/src/impl/residue_impl.cc
index ef6ffd7291e2cf513c20d2047d4e9fe01478b996..75590b1fea096169c76226df15442543fafd697e 100644
--- a/modules/mol/base/src/impl/residue_impl.cc
+++ b/modules/mol/base/src/impl/residue_impl.cc
@@ -42,8 +42,10 @@ ResidueImpl::ResidueImpl(const EntityImplPtr& ent,
   key_(key),
   atom_list_(),
   sec_structure_(SecStructure::COIL),
-  olc_('?')
-{}
+  olc_('?'),
+  protein_(false), ligand_(false)
+{
+}
 
 
 AtomImplPtr ResidueImpl::InsertAtom(const String& name,
@@ -61,8 +63,19 @@ AtomImplPtr ResidueImpl::InsertAtom(const AtomImplPtr& atom)
   AtomImplPtr dst_atom=this->InsertAtom(atom->GetName(), 
                                         atom->GetPos(),
                                         atom->GetElement());
+
   dst_atom->Assign(*atom.get());
   dst_atom->SetState(atom->GetState());
+  dst_atom->SetBFactor(atom->GetBFactor());
+  dst_atom->SetOccupancy(atom->GetOccupancy());
+  dst_atom->SetHetAtom(atom->IsHetAtom());  
+
+  if (!atom->HasDefaultProps()) {
+    dst_atom->SetRadius(atom->GetRadius());
+    dst_atom->SetCharge(atom->GetCharge());
+    dst_atom->SetMass(atom->GetMass());
+    dst_atom->SetAnisou(atom->GetAnisou());
+  }
   return dst_atom;
 }
 
@@ -377,7 +390,7 @@ void ResidueImpl::DeleteAllAtoms() {
 
 String ResidueImpl::GetQualifiedName() const {
   String chain_name=this->GetChain()->GetName();
-  return (chain_name==" " ? "" :  chain_name+".")+
+  return ((chain_name==" " || chain_name=="") ? "" :  chain_name+".")+
          this->GetKey()+
          this->GetNumber().AsString();
 }
diff --git a/modules/mol/base/src/impl/residue_impl.hh b/modules/mol/base/src/impl/residue_impl.hh
index a9f8481d2304d501d8a3565d183a044f811ffccf..925204982bcd1ecaabf08e7ef3e1f7479073fd41 100644
--- a/modules/mol/base/src/impl/residue_impl.hh
+++ b/modules/mol/base/src/impl/residue_impl.hh
@@ -202,6 +202,9 @@ public:
   void SetProtein(bool protein) { protein_=protein; }
   
   bool IsProtein() const { return protein_; }
+  
+  bool IsLigand() const { return ligand_; }
+  void SetIsLigand(bool flag) { ligand_=flag; }
 private:
   void AddAltAtom(const String& group, const AtomImplPtr& atom,
                   const geom::Vec3& position);
@@ -219,6 +222,7 @@ private:
   char                       olc_;
   // whether the residue is part of the protein.
   bool                       protein_;
+  bool                       ligand_;
 };
 
 }}} // ns
diff --git a/modules/mol/base/src/property_id.cc b/modules/mol/base/src/property_id.cc
index a6408b83e97407a26060faac0824dc0659403493..0ce93195b8d8fcb0a8bf41752661381705b5be44 100644
--- a/modules/mol/base/src/property_id.cc
+++ b/modules/mol/base/src/property_id.cc
@@ -51,6 +51,7 @@ struct Properties : public boost::spirit::symbols<Prop> {
       ("peptide", Prop(Prop::PEPTIDE, Prop::INT, Prop::RESIDUE))
       ("rindex", Prop(Prop::RINDEX, Prop::INT, Prop::RESIDUE))
       ("protein", Prop(Prop::PROTEIN, Prop::INT, Prop::RESIDUE))
+      ("ligand", Prop(Prop::LIGAND, Prop::INT, Prop::RESIDUE))
       ("water", Prop(Prop::WATER, Prop::INT, Prop::RESIDUE))
       ("acharge", Prop(Prop::ACHARGE, Prop::FLOAT, Prop::ATOM));
   }
@@ -116,6 +117,8 @@ String Prop::GetName() const
       return "rindex";
     case PROTEIN:
       return "protein";
+    case LIGAND:
+      return "ligand";
     case WATER:
       return "water";
     default:
@@ -128,7 +131,7 @@ String Prop::GetTypeName() const
 
   switch(type) {
     case Prop::STRING:
-      return "String";
+      return "string";
     case Prop::FLOAT:
       return "floating point";
     case Prop::INT:
diff --git a/modules/mol/base/src/property_id.hh b/modules/mol/base/src/property_id.hh
index 4ea4be13fc66c96512edfca18169967602f747da..f8a541ce75798e1c2e143414dae09d6ac154db9c 100644
--- a/modules/mol/base/src/property_id.hh
+++ b/modules/mol/base/src/property_id.hh
@@ -40,7 +40,7 @@ public:
   /// respectively.
   typedef enum {
     RNAME, ANAME, CNAME, ELE, RNUM, ANUM, AX, AY, AZ, OCC, RTYPE, ISHETATM,
-    RBFAC, ABFAC, PEPTIDE, ACHARGE, RINDEX, PROTEIN, WATER, WITHIN, 
+    RBFAC, ABFAC, PEPTIDE, ACHARGE, RINDEX, PROTEIN, LIGAND, WATER, WITHIN, 
     UNDEF, CUSTOM
   } ID;
   
diff --git a/modules/mol/base/src/query_state.cc b/modules/mol/base/src/query_state.cc
index 03b2ea28b9236fa1088791541faf62e1a6351436..5df2d900b8b95c428e03d4a30b58e03ee2f68281 100644
--- a/modules/mol/base/src/query_state.cc
+++ b/modules/mol/base/src/query_state.cc
@@ -217,6 +217,10 @@ boost::logic::tribool QueryState::EvalResidue(const impl::ResidueImplPtr& r) {
         int_value=r->GetChemClass().IsWater();
         s_[*i]=cmp_num<int>(ss.comp_op,int_value,boost::get<int>(ss.param));
         break;
+      case Prop::LIGAND:
+        int_value=r->IsLigand();
+        s_[*i]=cmp_num<int>(ss.comp_op,int_value,boost::get<int>(ss.param));
+        break;        
       case Prop::RTYPE:
         p=boost::get<String>(ss.param);
         if (p.length()>1) {
diff --git a/modules/mol/base/src/residue_base.cc b/modules/mol/base/src/residue_base.cc
index 9ae05d783a17e7885f3f1b2f8896cdcb1a7894be..2ddf33c2e52af2443e6c3527c9771f44005a4159 100644
--- a/modules/mol/base/src/residue_base.cc
+++ b/modules/mol/base/src/residue_base.cc
@@ -193,5 +193,17 @@ void ResidueBase::SetIsProtein(bool protein)
   Impl()->SetProtein(protein);
 }
 
+void ResidueBase::SetIsLigand(bool ligand)
+{
+  this->CheckValidity();
+  return Impl()->SetIsLigand(ligand);
+}
+
+bool ResidueBase::IsLigand() const
+{
+  this->CheckValidity();
+  return Impl()->IsLigand();
+}
+
 }}
 
diff --git a/modules/mol/base/src/residue_base.hh b/modules/mol/base/src/residue_base.hh
index 1ad7438795fa240422afc912645ab5025c48d50d..363ff875c7022eeb2f845913f228dbde8880f8cd 100644
--- a/modules/mol/base/src/residue_base.hh
+++ b/modules/mol/base/src/residue_base.hh
@@ -144,6 +144,10 @@ public:
   bool IsProtein() const;
   
   void SetIsProtein(bool protein);
+  
+  void SetIsLigand(bool ligand);
+  
+  bool IsLigand() const;
 public:
   impl::ResidueImplPtr& Impl();
 
diff --git a/modules/mol/base/src/residue_handle.hh b/modules/mol/base/src/residue_handle.hh
index 83890f3afb5741bf410bbc9e9fc126aac67e609a..3dc7e85def436e2327f6058c6cd5d7ca645c46fb 100644
--- a/modules/mol/base/src/residue_handle.hh
+++ b/modules/mol/base/src/residue_handle.hh
@@ -49,7 +49,7 @@ namespace ost { namespace mol {
 /// EditorBase::InsertAtom() or EditorBase::InsertAltAtom()
 /// 
 /// \code
-/// XCSEditor edi=residue.GetEntity().RequestXCSEditor();
+/// XCSEditor edi=residue.GetEntity().EditXCS();
 /// edi.InsertAtom(residue, "CA", geom.Vec3(1.0, 0.0, 0.0));
 /// \endcode
 class DLLEXPORT_OST_MOL ResidueHandle : public ResidueBase {
diff --git a/modules/mol/base/tests/dummy_ent.hh b/modules/mol/base/tests/dummy_ent.hh
index c4689027302ae8c21ab863058134c6e7e6f376d9..8e00291764489e2afc301f82dc88c4767e5a0413 100644
--- a/modules/mol/base/tests/dummy_ent.hh
+++ b/modules/mol/base/tests/dummy_ent.hh
@@ -28,7 +28,7 @@ namespace ost { namespace test {
 struct DummyEnt {
   DummyEnt() {
     e=CreateEntity();
-    XCSEditor editor=e.RequestXCSEditor();
+    XCSEditor editor=e.EditXCS();
     c=editor.InsertChain("A");
     r=editor.AppendResidue(c, "XXX");
     aa=editor.InsertAtom(r, "A", geom::Vec3());
diff --git a/modules/mol/base/tests/test_atom_groups.cc b/modules/mol/base/tests/test_atom_groups.cc
index 01e3510ff365c0336fe5ce1532005884e4cbd6f7..b1ed9118e4a1ef910ab800c6ddf9f1db369cd27e 100644
--- a/modules/mol/base/tests/test_atom_groups.cc
+++ b/modules/mol/base/tests/test_atom_groups.cc
@@ -37,7 +37,7 @@ BOOST_AUTO_TEST_CASE(switch_pos)
   geom::Vec3 y=geom::Vec3(0.0, 1.0, 0.0);
   geom::Vec3 z=geom::Vec3(0.0, 0.0, 1.0);  
   // Should throw, since aa has no alt-location set.
-  XCSEditor editor=ent.e.RequestXCSEditor();  
+  XCSEditor editor=ent.e.EditXCS();  
   BOOST_CHECK_THROW(editor.AddAltAtomPos("B", ent.aa, y),
                     Error);
   AtomHandle xx=editor.InsertAltAtom(ent.r, "ZZ", "A", y); 
@@ -55,7 +55,7 @@ BOOST_AUTO_TEST_CASE(switch_pos)
 BOOST_AUTO_TEST_CASE(delete_atom) 
 {
   test::DummyEnt ent;
-  XCSEditor editor=ent.e.RequestXCSEditor();       
+  XCSEditor editor=ent.e.EditXCS();       
   AtomHandle xx=editor.InsertAltAtom(ent.r, "ZZ", "A", geom::Vec3());
   AtomHandle zz=editor.InsertAltAtom(ent.r, "XX", "A", geom::Vec3());
   
@@ -75,7 +75,7 @@ BOOST_AUTO_TEST_CASE(atom_group_triv)
   BOOST_CHECK(ent.r.HasAltAtomGroup("")==false);
   std::vector<String> names=ent.r.GetAltAtomGroupNames();
   BOOST_CHECK(names.empty());
-  XCSEditor editor=ent.e.RequestXCSEditor();
+  XCSEditor editor=ent.e.EditXCS();
   AtomHandle xx=editor.InsertAltAtom(ent.r, "A", "ZZ", geom::Vec3(0.0,1.0,0.0));   
   editor.AddAltAtomPos("B", xx, geom::Vec3(1.0, 0.0, 0.0));
   BOOST_CHECK(ent.r.HasAltAtoms()==true);
diff --git a/modules/mol/base/tests/test_chain.cc b/modules/mol/base/tests/test_chain.cc
index e03c588a5b0a83ed7b959d02e99e8b386b0381f4..2e42ea77184ab789a659abff5857cef576950f76 100644
--- a/modules/mol/base/tests/test_chain.cc
+++ b/modules/mol/base/tests/test_chain.cc
@@ -46,7 +46,7 @@ void no_find_res(ChainHandle chain, const ResNum& n) {
 
 void test_res_pos() {
   EntityHandle eh=CreateEntity();
-  XCSEditor e=eh.RequestXCSEditor();  
+  XCSEditor e=eh.EditXCS();  
   ChainHandle ch1=e.InsertChain("A");
   e.AppendResidue(ch1, "A");
   e.AppendResidue(ch1, "B");
@@ -76,7 +76,7 @@ BOOST_AUTO_TEST_SUITE( mol_base )
 BOOST_AUTO_TEST_CASE(test_comparison) 
 {
   EntityHandle eh=CreateEntity();
-  XCSEditor e=eh.RequestXCSEditor();  
+  XCSEditor e=eh.EditXCS();  
   ChainHandle ch1=e.InsertChain("A");
   ChainHandle ch2=e.InsertChain("B");
   ChainHandle cc=ch1;
@@ -89,7 +89,7 @@ BOOST_AUTO_TEST_CASE(test_comparison)
 BOOST_AUTO_TEST_CASE(res_pos) 
 {
   EntityHandle eh=CreateEntity();
-  XCSEditor e=eh.RequestXCSEditor();  
+  XCSEditor e=eh.EditXCS();  
   ChainHandle ch1=e.InsertChain("A");
   e.AppendResidue(ch1, "A");
   e.AppendResidue(ch1, "B");
@@ -118,7 +118,7 @@ BOOST_AUTO_TEST_CASE(res_pos)
 BOOST_AUTO_TEST_CASE(res_pos_with_insertion_code) 
 {
   EntityHandle eh=CreateEntity();
-  XCSEditor e=eh.RequestXCSEditor();  
+  XCSEditor e=eh.EditXCS();  
   ChainHandle ch1=e.InsertChain("A");
   e.AppendResidue(ch1, "A");
   e.AppendResidue(ch1, "B");
@@ -148,7 +148,7 @@ BOOST_AUTO_TEST_CASE(res_pos_with_insertion_code)
 BOOST_AUTO_TEST_CASE(prev_next) 
 {
   EntityHandle eh=CreateEntity();
-  XCSEditor e=eh.RequestXCSEditor();  
+  XCSEditor e=eh.EditXCS();  
   ChainHandle ch1=e.InsertChain("A");
   e.AppendResidue(ch1, "A");
   e.AppendResidue(ch1, "B");
diff --git a/modules/mol/base/tests/test_conn.cc b/modules/mol/base/tests/test_conn.cc
index b36e5f754e453cba393920adc8c0852b81059b84..0c81d6900611ee77b826af1faaa74d7808a3fa9a 100644
--- a/modules/mol/base/tests/test_conn.cc
+++ b/modules/mol/base/tests/test_conn.cc
@@ -31,7 +31,7 @@ BOOST_AUTO_TEST_SUITE( mol_base )
 BOOST_AUTO_TEST_CASE(connect) 
 {
   EntityHandle e=CreateEntity();
-  XCSEditor editor=e.RequestXCSEditor();  
+  XCSEditor editor=e.EditXCS();  
   ChainHandle c=editor.InsertChain("A");
   ResidueHandle r=editor.AppendResidue(c, "GLY");
 
diff --git a/modules/mol/base/tests/test_coord_group.cc b/modules/mol/base/tests/test_coord_group.cc
index f2012b9983cd652d373cb68b813fea65cd460aa6..cce3eb4873336242739b2cae689e8d18073a742b 100644
--- a/modules/mol/base/tests/test_coord_group.cc
+++ b/modules/mol/base/tests/test_coord_group.cc
@@ -33,7 +33,7 @@ BOOST_AUTO_TEST_SUITE( io )
 BOOST_AUTO_TEST_CASE(coord_group) 
 {
   EntityHandle e=CreateEntity();
-  XCSEditor editor=e.RequestXCSEditor();  
+  XCSEditor editor=e.EditXCS();  
   ChainHandle c=editor.InsertChain("A");
   ResidueHandle r=editor.AppendResidue(c, "XXX");
   AtomHandle aa=editor.InsertAtom(r, "A", geom::Vec3(0,1,2));
diff --git a/modules/mol/base/tests/test_delete.cc b/modules/mol/base/tests/test_delete.cc
index c117f5d9ae50dfd0d26a41c665627b957d3dd751..56d78f0a016d1671292ad091a849ddd13403871b 100644
--- a/modules/mol/base/tests/test_delete.cc
+++ b/modules/mol/base/tests/test_delete.cc
@@ -42,7 +42,7 @@ public:
 struct Fixture {
   Fixture() {
     e=CreateEntity();
-    XCSEditor editor=e.RequestXCSEditor();    
+    XCSEditor editor=e.EditXCS();    
     c=editor.InsertChain("A");
     r=editor.AppendResidue(c, "XXX");
     aa=editor.InsertAtom(r, "A", geom::Vec3());
@@ -71,7 +71,7 @@ BOOST_AUTO_TEST_SUITE( mol_base )
 BOOST_AUTO_TEST_CASE(atom_delete) 
 {
   Fixture f;
-  XCSEditor e=f.e.RequestXCSEditor();
+  XCSEditor e=f.e.EditXCS();
   e.DeleteAtom(f.ab);
   E ev;
   BOOST_CHECK_NO_THROW(f.e.Apply(ev));
diff --git a/modules/mol/base/tests/test_entity.cc b/modules/mol/base/tests/test_entity.cc
index 0504422946e34546f0c3dee532bb05de4fbd232a..ac262c406cc7620febc688ef57237ad646f879c4 100644
--- a/modules/mol/base/tests/test_entity.cc
+++ b/modules/mol/base/tests/test_entity.cc
@@ -19,6 +19,8 @@
 /*
  *  Authors: Marco Biasini, Juergen Haas
  */
+ 
+#include <ost/mol/chem_class.hh>
 #include <ost/mol/mol.hh>
 #include <cmath>
 #define BOOST_TEST_DYN_LINK
@@ -42,10 +44,12 @@
 
 using namespace ost;
 using namespace ost::mol;
+
+
 EntityHandle make_test_entity()
 {
   EntityHandle eh = CreateEntity();
-  XCSEditor e=eh.RequestXCSEditor();
+  XCSEditor e=eh.EditXCS();
   ChainHandle chain = e.InsertChain("A");
   ResidueHandle res1 = e.AppendResidue(chain, "MET");
 
@@ -83,7 +87,7 @@ BOOST_AUTO_TEST_CASE(entity_creator)
   eh.SetName("TestEntity");
   BOOST_CHECK(eh.GetName()=="TestEntity");
 
-  XCSEditor e=eh.RequestXCSEditor();
+  XCSEditor e=eh.EditXCS();
   ChainHandle chain = e.InsertChain("C");
   BOOST_CHECK(chain.GetName()=="C");
 
@@ -118,7 +122,7 @@ BOOST_AUTO_TEST_CASE(entity_creator)
 BOOST_AUTO_TEST_CASE(spatial_organizer) 
 {
   EntityHandle eh=CreateEntity();
-  XCSEditor e=eh.RequestXCSEditor();  
+  XCSEditor e=eh.EditXCS();  
   ChainHandle chain = e.InsertChain("A");
   ResidueHandle res = e.AppendResidue(chain, "X");
 
@@ -139,7 +143,7 @@ BOOST_AUTO_TEST_CASE(spatial_organizer)
 BOOST_AUTO_TEST_CASE(transformation) 
 {
   EntityHandle eh = CreateEntity();
-  XCSEditor e=eh.RequestXCSEditor();
+  XCSEditor e=eh.EditXCS();
   ChainHandle chain = e.InsertChain("A");
   ResidueHandle res = e.AppendResidue(chain, "X");
 
@@ -240,7 +244,7 @@ BOOST_AUTO_TEST_CASE(transformation)
 
   BOOST_CHECK(bond1.GetLength()==1.5);
   BOOST_CHECK(bond2.GetLength()==2.0);
-  ICSEditor i = eh.RequestICSEditor();
+  ICSEditor i = eh.EditICS();
   i.SetBondLength(bond1,1.0);
   i.SetBondLength(bond2,3.0);
 
@@ -325,4 +329,56 @@ BOOST_AUTO_TEST_CASE(copy)
   BOOST_CHECK(r2.GetPhiTorsion());
 }
 
+BOOST_AUTO_TEST_CASE(copy_residue_props)
+{
+  EntityHandle ent=mol::CreateEntity();
+  XCSEditor edi=ent.EditXCS();
+  ChainHandle ch=edi.InsertChain("A");
+  ResidueHandle res=edi.AppendResidue(ch, "DUMMY", mol::ResNum(666, '6'));
+  res.SetOneLetterCode('X');
+  res.SetIsProtein(true);
+  res.SetIsLigand(true);
+  ChemClass cl(ChemClass::LPeptideLinking);  
+  res.SetSecStructure(SecStructure(SecStructure::ALPHA_HELIX));
+  res.SetChemClass(cl);
+  EntityHandle copy=ent.Copy();
+  ResidueHandle res2=copy.GetResidueList()[0];
+  BOOST_CHECK_EQUAL(res2.GetName(), String("DUMMY"));
+  BOOST_CHECK_EQUAL(res2.GetOneLetterCode(), 'X');
+
+  BOOST_CHECK_EQUAL(res2.GetChemClass(), cl);
+  BOOST_CHECK_EQUAL(res.GetSecStructure(), SecStructure::ALPHA_HELIX);
+  BOOST_CHECK(res2.IsProtein()==true);
+  BOOST_CHECK(res2.IsLigand()==true);  
+  BOOST_CHECK_EQUAL(res2.GetNumber(), ResNum(666, '6'));
+}
+
+BOOST_AUTO_TEST_CASE(copy_atom_props)
+{
+  EntityHandle ent=mol::CreateEntity();
+  XCSEditor edi=ent.EditXCS();
+  ChainHandle ch=edi.InsertChain("A");
+  ResidueHandle res=edi.AppendResidue(ch, "DUMMY");
+  AtomHandle   atom=edi.InsertAtom(res, "X", geom::Vec3(1,2,3), "C");
+  atom.SetMass(100.0);
+  atom.SetBFactor(200.0);
+  atom.SetOccupancy(300.0);
+  atom.SetHetAtom(true);
+  atom.SetRadius(500);
+  atom.SetCharge(800);
+  atom.SetAnisou(geom::Mat3(100,200,300));
+  EntityHandle copy=ent.Copy();
+  AtomHandle atom2=copy.GetAtomList()[0];
+  BOOST_CHECK_EQUAL(atom2.GetPos(), geom::Vec3(1,2,3));
+  BOOST_CHECK_EQUAL(atom2.GetName(), String("X"));
+  BOOST_CHECK_EQUAL(atom2.GetElement(), String("C"));
+  BOOST_CHECK_EQUAL(atom2.GetMass(), Real(100.0));
+  BOOST_CHECK_EQUAL(atom2.GetCharge(), Real(800.0));  
+  BOOST_CHECK_EQUAL(atom2.GetBFactor(), Real(200.0)); 
+  BOOST_CHECK_EQUAL(atom2.IsHetAtom(), true);
+  BOOST_CHECK_EQUAL(atom2.GetAnisou(), geom::Mat3(100,200,300));
+  BOOST_CHECK_EQUAL(atom2.GetRadius(), Real(500.0));
+}
+
+
 BOOST_AUTO_TEST_SUITE_END()
diff --git a/modules/mol/base/tests/test_ics.cc b/modules/mol/base/tests/test_ics.cc
index 37955909398b208a556a3a9feaf4c7f1f8c48ba0..d577f8ca9dd60a720ea1f780b5f3922e311e4993 100644
--- a/modules/mol/base/tests/test_ics.cc
+++ b/modules/mol/base/tests/test_ics.cc
@@ -36,7 +36,7 @@ struct Structure {
   Structure()
   {
     e=CreateEntity();
-    ICSEditor editor=e.RequestICSEditor();
+    ICSEditor editor=e.EditICS();
     c=editor.InsertChain("A");
     r=editor.AppendResidue(c, "ANGELIN");
     a1=editor.InsertAtom(r, "CC", geom::Vec3(-1.0, 0.0,  0.0));
@@ -76,7 +76,7 @@ BOOST_AUTO_TEST_SUITE( mol_base )
 BOOST_AUTO_TEST_CASE(ics_angle_trivia) 
 {
   Structure s;
-  ICSEditor e=s.e.RequestICSEditor();
+  ICSEditor e=s.e.EditICS();
   BOOST_CHECK(!e.SetAngle(s.a1, s.a3, s.a2, 0));
   BOOST_CHECK(!e.SetAngle(s.a2, s.a3, s.a1, 0));
   BOOST_CHECK(e.SetAngle(s.a1, s.a2, s.a3, 0));
@@ -94,7 +94,7 @@ BOOST_AUTO_TEST_CASE(ics_set_angle_sec)
 {
   Structure s;
   // test for set angle of two secondary connectors
-  ICSEditor e=s.e.RequestICSEditor();  
+  ICSEditor e=s.e.EditICS();  
   geom::Plane p(s.a3.GetPos(), s.a2.GetPos(), s.a4.GetPos());
   e.SetAngle(s.a3, s.a2, s.a4, M_PI/4);
   e.UpdateXCS();  
@@ -111,7 +111,7 @@ BOOST_AUTO_TEST_CASE(ics_set_angle_prim)
 {
   Structure s;
   // test for set angle of two secondary connectors
-  ICSEditor e=s.e.RequestICSEditor();    
+  ICSEditor e=s.e.EditICS();    
   e.SetAngle(s.a1, s.a2, s.a4, M_PI/4);
   e.UpdateXCS();
   geom::Plane p(s.a1.GetPos(), s.a2.GetPos(), s.a4.GetPos());
diff --git a/modules/mol/base/tests/test_iterators.cc b/modules/mol/base/tests/test_iterators.cc
index 8dfc0dca0f1215b730a6e637cd98f36b0b2b59d0..0c2900571e9e4482f03dce839eb4c19b593649fe 100644
--- a/modules/mol/base/tests/test_iterators.cc
+++ b/modules/mol/base/tests/test_iterators.cc
@@ -140,7 +140,7 @@ BOOST_AUTO_TEST_SUITE( mol_base )
 BOOST_AUTO_TEST_CASE(chain_handle_iterator) 
 {
   EntityHandle ent=CreateEntity();
-  XCSEditor editor=ent.RequestXCSEditor();  
+  XCSEditor editor=ent.EditXCS();  
   ChainHandle ch1=editor.InsertChain("A");
   ChainHandle ch2=editor.InsertChain("B");
   ChainHandle ch3=editor.InsertChain("C");
@@ -161,7 +161,7 @@ BOOST_AUTO_TEST_CASE(chain_handle_iterator)
 BOOST_AUTO_TEST_CASE(test_res_handle_iterator) 
 {
   EntityHandle eh=CreateEntity();
-  XCSEditor editor=eh.RequestXCSEditor();  
+  XCSEditor editor=eh.EditXCS();  
   ChainHandle ch1=editor.InsertChain("A");
   editor.AppendResidue(ch1, "A");
   editor.AppendResidue(ch1, "B");
@@ -197,7 +197,7 @@ BOOST_AUTO_TEST_CASE(test_empty_iterators)
   BOOST_CHECK(eh.ChainsBegin()==eh.ChainsEnd());
   BOOST_CHECK(eh.ResiduesBegin()==eh.ResiduesEnd());  
   BOOST_CHECK(eh.AtomsBegin()==eh.AtomsEnd());    
-  XCSEditor editor=eh.RequestXCSEditor();
+  XCSEditor editor=eh.EditXCS();
   ChainHandle ch1=editor.InsertChain("A");  
   BOOST_CHECK(ch1.ResiduesBegin()==ch1.ResiduesEnd());
   BOOST_CHECK(ch1.AtomsBegin()==ch1.AtomsEnd());  
@@ -205,7 +205,7 @@ BOOST_AUTO_TEST_CASE(test_empty_iterators)
   BOOST_CHECK(r1.AtomsBegin()==r1.AtomsEnd());    
   
   eh=CreateEntity();
-  editor=eh.RequestXCSEditor();  
+  editor=eh.EditXCS();  
   ch1=editor.InsertChain("A");
   r1=editor.AppendResidue(ch1, "A");
   ResidueHandle r2=editor.AppendResidue(ch1, "B");
@@ -229,7 +229,7 @@ BOOST_AUTO_TEST_CASE(test_empty_iterators)
 BOOST_AUTO_TEST_CASE(test_atom_handle_iterator) 
 {
   EntityHandle eh=CreateEntity();
-  XCSEditor editor=eh.RequestXCSEditor();  
+  XCSEditor editor=eh.EditXCS();  
   ChainHandle ch1=editor.InsertChain("A");
   ResidueHandle r1=editor.AppendResidue(ch1, "A");
   ResidueHandle r2=editor.AppendResidue(ch1, "B");
diff --git a/modules/mol/base/tests/test_query.cc b/modules/mol/base/tests/test_query.cc
index c3f779a872aac92060c96572378458c090598b38..6e603a16adf42d60671bf2b916d4cfc29f0dbee1 100644
--- a/modules/mol/base/tests/test_query.cc
+++ b/modules/mol/base/tests/test_query.cc
@@ -31,7 +31,7 @@ using namespace ost::mol;
 EntityHandle make_query_test_entity()
 {
   EntityHandle eh = CreateEntity();
-  XCSEditor e=eh.RequestXCSEditor();
+  XCSEditor e=eh.EditXCS();
   ChainHandle chain = e.InsertChain("A");
   chain.SetFloatProp("testprop_c", 1.0);
   ResidueHandle res = e.AppendResidue(chain, "MET");
diff --git a/modules/mol/base/tests/test_residue.cc b/modules/mol/base/tests/test_residue.cc
index 332d60edd6534837b9511314b4a3aecceadbffae..d6cc11f4a447e4d62a0a2f82f867f3173e18f8b3 100644
--- a/modules/mol/base/tests/test_residue.cc
+++ b/modules/mol/base/tests/test_residue.cc
@@ -34,7 +34,7 @@ BOOST_AUTO_TEST_SUITE( mol_base )
 BOOST_AUTO_TEST_CASE(test_in_sequence) 
 {
   EntityHandle eh=CreateEntity();
-  XCSEditor e=eh.RequestXCSEditor();
+  XCSEditor e=eh.EditXCS();
   ChainHandle ch1=e.InsertChain("A");
   ResidueHandle rA = e.AppendResidue(ch1, "A");
   ResidueHandle rB = e.AppendResidue(ch1, "B");
@@ -48,7 +48,7 @@ BOOST_AUTO_TEST_CASE(test_in_sequence)
 BOOST_AUTO_TEST_CASE(test_res_index)
 {
   EntityHandle eh=CreateEntity();
-  XCSEditor e=eh.RequestXCSEditor();
+  XCSEditor e=eh.EditXCS();
   ChainHandle ch1=e.InsertChain("A");
   ResidueHandle rA = e.AppendResidue(ch1, "A");
   ResidueHandle rB = e.AppendResidue(ch1, "B");
diff --git a/modules/mol/base/tests/test_view.cc b/modules/mol/base/tests/test_view.cc
index 26399e10e1c240182d87f59a453a605d69dd3902..3f60928d627552a50450a62a6b89cb0de31c7ae8 100644
--- a/modules/mol/base/tests/test_view.cc
+++ b/modules/mol/base/tests/test_view.cc
@@ -30,7 +30,7 @@ using namespace ost::mol;
 struct Fixture {
   Fixture() {
     e=CreateEntity();
-    XCSEditor editor=e.RequestXCSEditor();
+    XCSEditor editor=e.EditXCS();
     c=editor.InsertChain("A");
     r=editor.AppendResidue(c, "ANGELIN");
     aa=editor.InsertAtom(r, "X1", geom::Vec3( 0.0, 0.0,  0.0));
diff --git a/modules/mol/base/tests/test_view_op.cc b/modules/mol/base/tests/test_view_op.cc
index f589bf2107638956d21663a4db196044c020c610..fb9d8ffda7b0fd210268a4ae3e5a6f3eb7074875 100644
--- a/modules/mol/base/tests/test_view_op.cc
+++ b/modules/mol/base/tests/test_view_op.cc
@@ -31,7 +31,7 @@ EntityHandle mk_test_ent()
 {
   EntityHandle ent=CreateEntity();
   ent.SetName("TestEntity");
-  XCSEditor edi=ent.RequestXCSEditor();
+  XCSEditor edi=ent.EditXCS();
   ChainHandle chain_a=edi.InsertChain("A");
   ResidueHandle res_a=edi.AppendResidue(chain_a, "A");
   AtomHandle atom_a=edi.InsertAtom(res_a, "A", geom::Vec3());
@@ -334,7 +334,8 @@ BOOST_AUTO_TEST_CASE(test_intersection_b)
                          bonds));
 }
 
-BOOST_AUTO_TEST_CASE(entity_from_view) {
+BOOST_AUTO_TEST_CASE(entity_from_view) 
+{
   EntityHandle ent=mk_test_ent();
   EntityView v1=ent.Select("aname=B,C,F,G");
   EntityHandle ent_fv=mol::CreateEntityFromView(v1, false);
@@ -347,5 +348,54 @@ BOOST_AUTO_TEST_CASE(entity_from_view) {
 
 }
 
+BOOST_AUTO_TEST_CASE(ent_from_view_residue_props)
+{
+  EntityHandle ent=mol::CreateEntity();
+  XCSEditor edi=ent.EditXCS();
+  ChainHandle ch=edi.InsertChain("A");
+  ResidueHandle res=edi.AppendResidue(ch, "DUMMY", mol::ResNum(666, '6'));
+  res.SetOneLetterCode('X');
+  res.SetIsProtein(true);
+  ChemClass cl(ChemClass::LPeptideLinking);  
+  res.SetSecStructure(SecStructure(SecStructure::ALPHA_HELIX));
+  res.SetChemClass(cl);
+  EntityHandle copy=mol::CreateEntityFromView(ent.Select(""), false);
+  ResidueHandle res2=copy.GetResidueList()[0];
+  BOOST_CHECK_EQUAL(res2.GetName(), String("DUMMY"));
+  BOOST_CHECK_EQUAL(res2.GetOneLetterCode(), 'X');
+
+  BOOST_CHECK_EQUAL(res2.GetChemClass(), cl);
+  BOOST_CHECK_EQUAL(res.GetSecStructure(), SecStructure::ALPHA_HELIX);
+  BOOST_CHECK(res2.IsProtein()==true);
+  BOOST_CHECK_EQUAL(res2.GetNumber(), ResNum(666, '6'));
+}
+
+BOOST_AUTO_TEST_CASE(ent_from_view_atom_props)
+{
+  EntityHandle ent=mol::CreateEntity();
+  XCSEditor edi=ent.EditXCS();
+  ChainHandle ch=edi.InsertChain("A");
+  ResidueHandle res=edi.AppendResidue(ch, "DUMMY");
+  AtomHandle   atom=edi.InsertAtom(res, "X", geom::Vec3(1,2,3), "C");
+  atom.SetMass(100.0);
+  atom.SetBFactor(200.0);
+  atom.SetOccupancy(300.0);
+  atom.SetHetAtom(true);
+  atom.SetRadius(500);
+  atom.SetCharge(800);
+  atom.SetAnisou(geom::Mat3(100,200,300));
+  EntityHandle copy=mol::CreateEntityFromView(ent.Select(""), false);
+  AtomHandle atom2=copy.GetAtomList()[0];
+  BOOST_CHECK_EQUAL(atom2.GetPos(), geom::Vec3(1,2,3));
+  BOOST_CHECK_EQUAL(atom2.GetName(), String("X"));
+  BOOST_CHECK_EQUAL(atom2.GetElement(), String("C"));
+  BOOST_CHECK_EQUAL(atom2.GetMass(), Real(100.0));
+  BOOST_CHECK_EQUAL(atom2.GetCharge(), Real(800.0));  
+  BOOST_CHECK_EQUAL(atom2.GetBFactor(), Real(200.0)); 
+  BOOST_CHECK_EQUAL(atom2.IsHetAtom(), true);
+  BOOST_CHECK_EQUAL(atom2.GetAnisou(), geom::Mat3(100,200,300));
+  BOOST_CHECK_EQUAL(atom2.GetRadius(), Real(500.0));
+}
+
 BOOST_AUTO_TEST_SUITE_END()
 
diff --git a/modules/qa/src/amino_acids.cc b/modules/qa/src/amino_acids.cc
index 8e98cbcf24e6292fe9880aec7312159a17dc31e2..7c3b606de733275690f5529a367aeeaefa734208 100644
--- a/modules/qa/src/amino_acids.cc
+++ b/modules/qa/src/amino_acids.cc
@@ -125,6 +125,55 @@ String AminoAcidToResidueName(AminoAcid aa)
   }
 }
 
+String OneLetterCodeToResidueName(char olc)
+{
+  char upper_olc=toupper(olc);
+  switch(upper_olc) {
+    case 'A':
+      return "ALA";
+    case 'R':
+      return "ARG";
+    case 'N':
+      return "ASN";
+    case 'D':
+      return "ASP";
+    case 'Q':
+      return "GLN";
+    case 'E':
+      return "GLU";
+    case 'K':
+      return "LYS";
+    case 'S':
+      return "SER";
+    case 'C':
+      return "CYS";
+    case 'Y':  
+      return "TYR";
+    case 'W':
+      return "TRP";
+    case 'T':
+      return "THR";
+    case 'V':
+      return "VAL";
+    case 'I':
+      return "ILE";
+    case 'M':
+      return "MET";
+    case 'L':  
+      return "LEU";
+    case 'G':  
+      return "GLY";
+    case 'P':  
+      return "PRO";
+    case 'H':  
+      return "HIS";
+    case 'F':
+      return "PHE";
+    default:
+      return "UNK";
+  }
+}
+
 AminoAcidSet AminoAcidSet::CreatePolarSet()
 {
   AminoAcidSet polar;
diff --git a/modules/qa/src/amino_acids.hh b/modules/qa/src/amino_acids.hh
index d2337068c8743f8f80a2827112862b60259d88ca..393974eb9de7a58ef73b5b7a6faed400340bce11 100644
--- a/modules/qa/src/amino_acids.hh
+++ b/modules/qa/src/amino_acids.hh
@@ -50,6 +50,8 @@ DLLEXPORT_OST_QA AminoAcid ResidueToAminoAcid(const mol::ResidueHandle& r);
 // \brief from amino acid to residue name
 DLLEXPORT_OST_QA String AminoAcidToResidueName(AminoAcid aa);
 
+DLLEXPORT_OST_QA String OneLetterCodeToResidueName(char olc);
+
 class AminoAcidSetIterator : public std::iterator<std::forward_iterator_tag,
                                                   AminoAcid> {
 public:
diff --git a/modules/seq/alg/pymod/renumber.py b/modules/seq/alg/pymod/renumber.py
index 39ea9fb489949845fb65681ac1cbb6f000f4e56e..39f34ba7b0dc68b4c84421e6b14ac606a9ddc107 100644
--- a/modules/seq/alg/pymod/renumber.py
+++ b/modules/seq/alg/pymod/renumber.py
@@ -1,11 +1,11 @@
 from ost import io, seq, mol, conop
-import ost
+from ost import *
 
-def Renumber(seq_handle):
+def Renumber(seq_handle, sequence_number_with_attached_view=1):
   """
   Function to renumber an entity according to an alignment between the model sequence 
-  and the full-length target sequence. The aligned model sequence with an attached 
-  view needs to be provided. Upon succcess, the renumbered entity is returned.
+  and the full-length target sequence. The aligned model sequence or the alignment itself
+  with an attached view needs to be provided. Upon succcess, the renumbered entity is returned.
 
   .. code-block:: python
 
@@ -16,35 +16,70 @@ def Renumber(seq_handle):
     pdb_seq=seq.SequenceFromChain("model", ent.chains[0])
     aln=ClustalW(s,pdb_seq)
     aln.AttachView(1,ent.chains[0].Select(""))
-    e=Renumber(aln.GetSequence(1))
+    e=Renumber(aln.GetSequence(sequence_number_with_attached_view))
     io.SavePDB(e, "renum.pdb")
    
   """
-  if seq_handle.HasAttachedView()==False:
-    raise RuntimeError, "Sequence Handle has no attached view"
-  changed_residue_count=0
-  renumberingFlag = False
-  ent_n=mol.CreateEntity()
-  ed=ent_n.RequestXCSEditor()
-  c=ed.InsertChain(" ")
-  for pos in range(len(seq_handle)):
-    if seq_handle[pos]!='-':
-      r=seq_handle.GetResidue(pos)
-      if r.IsValid():
-          #print seq_handle[pos],r.number.num,pos+1
-          if r.number.num!=pos+1:
-            changed_residue_count+=1
-            renumberingFlag = True
-          r_n=ed.AppendResidue(c,r.name, mol.ResNum(pos+1))
-          for atom in r.atoms:
-            ed.InsertAtom(r_n,atom.name,atom.pos,atom.prop)
-      else:
-        err='Error: renumbering failed at position %s' %pos
-        raise RuntimeError, err
-  if renumberingFlag == True:
-    err = 'Warning: %s residues have been renumbered!' %changed_residue_count
-    ost.LogMessage(err)
-  conop.ConnectAll(ent_n)
-  return ent_n
+  if isinstance(seq_handle, seq.SequenceHandle):
+    if seq_handle.HasAttachedView()==False:
+      raise RuntimeError, "Sequence Handle has no attached view"
+    changed_residue_count=0
+    renumberingFlag = False
+    ent_n=mol.CreateEntity()
+    ed=ent_n.EditXCS()
+    c=ed.InsertChain(" ")
+    for pos in range(len(seq_handle)):
+      if seq_handle[pos]!='-':
+        r=seq_handle.GetResidue(pos)
+        if r.IsValid():
+            #print seq_handle[pos],r.number.num,pos+1
+            if r.number.num!=pos+1:
+              changed_residue_count+=1
+              renumberingFlag = True
+            r_n=ed.AppendResidue(c,r.name, mol.ResNum(pos+1))
+            for atom in r.atoms:
+              ed.InsertAtom(r_n,atom.name,atom.pos,atom.prop)
+        else:
+          err='Error: renumbering failed at position %s' %pos
+          raise RuntimeError, err
+    if renumberingFlag == True:
+      err = 'Warning: %s residues have been renumbered!' %changed_residue_count
+      LogInfo(err)
+    conop.ConnectAll(ent_n)
+    return ent_n
 
+  elif isinstance(seq_handle, seq.AlignmentHandle):
+    if seq_handle.GetSequence(sequence_number_with_attached_view).HasAttachedView()==False:
+      raise RuntimeError, "Sequence Handle has no attached view"
+    dir(seq_handle)
+    counter=0
+    changed_residue_count=0
+    renumberingFlag = False
+    ent_n=mol.CreateEntity()
+    ed=ent_n.EditXCS()
+    c=ed.InsertChain(seq_handle.GetSequence(sequence_number_with_attached_view).GetAttachedView().chains[0].name)
+    for col in seq_handle:
+      if col[0]!='-' and col[1]!='-':
+        if col[0]==col[1]:
+          rnum=seq_handle.GetSequence(sequence_number_with_attached_view).GetResidueIndex(counter)
+          r=seq_handle.GetSequence(sequence_number_with_attached_view).GetResidue(counter)
+          if r.IsValid():
+            if r.number.num!=counter+1:
+              changed_residue_count+=1
+              renumberingFlag = True
+            r_n=ed.AppendResidue(c,r.name, mol.ResNum(counter+1))
+            for atom in r.atoms:
+              ed.InsertAtom(r_n,atom.name,atom.pos,atom.element, atom.b_factor, 
+                            atom.occupancy, atom.is_hetatom)
+
+          else:
+            raise RuntimeError("invalide residue at postion %s (renumbering failed)" %(counter))
+        else:
+          raise RuntimeError("residue mismatch at position %d (%s vs %s) (renumbering failed)"%(counter, col[0],col[1]))
+      counter+=1
+    if renumberingFlag == True:
+      err = 'Warning: %s residues have been renumbered!' %changed_residue_count
+      LogInfo(err)
+    conop.ConnectAll(ent_n)
+    return ent_n
 
diff --git a/modules/seq/alg/tests/CMakeLists.txt b/modules/seq/alg/tests/CMakeLists.txt
index 37969a869b14c0f740f2b8e221509120f1cd1a6e..aafdabc4b723b7ee0ac6b978eb28cf34f95b5c23 100644
--- a/modules/seq/alg/tests/CMakeLists.txt
+++ b/modules/seq/alg/tests/CMakeLists.txt
@@ -2,6 +2,7 @@ set(OST_SEQ_ALG_UNIT_TESTS
   test_merge_pairwise_alignments.cc
   test_sequence_identity.cc
   tests.cc
+  test_renumber.py
 )
 
 ost_unittest(seq_alg "${OST_SEQ_ALG_UNIT_TESTS}")
diff --git a/modules/seq/alg/tests/test_renumber.py b/modules/seq/alg/tests/test_renumber.py
new file mode 100644
index 0000000000000000000000000000000000000000..6d365a9b77ff2e0b9ffe80aad910cd428b599854
--- /dev/null
+++ b/modules/seq/alg/tests/test_renumber.py
@@ -0,0 +1,124 @@
+import unittest
+from ost import *
+from ost import settings
+from ost import seq
+from ost.bindings.clustalw import *
+from ost.seq.alg import renumber
+
+class TestRenumber(unittest.TestCase):
+  
+  def setUp(self):
+    self.target_seq = io.LoadSequence("testfiles/peptide.fasta")
+    self.peptide_original = io.LoadEntity("testfiles/peptide_original.pdb")
+    self.peptide_plus_5 = io.LoadEntity("testfiles/peptide_plus_5.pdb")
+    self.peptide_random = io.LoadEntity("testfiles/peptide_random.pdb")
+    self.peptide_del_1_2 = io.LoadEntity("testfiles/peptide_del_1_2.pdb")
+    self.peptide_del_4 = io.LoadEntity("testfiles/peptide_del_4.pdb")
+    self.peptide_mutation_3 = io.LoadEntity("testfiles/peptide_mutation_3.pdb")
+    
+
+  def testPeptidePlusFive(self):
+    """
+    All residue numbers shifted by 5.
+    Check whether internal atom order changes while renumbering
+    (a new entity is generated in the edit_mode)
+    TODO: add more basic tests: are all properties preserved?
+    """
+    model_seq=seq.SequenceFromChain(" ", self.peptide_plus_5.chains[0]) 
+    model_seq.name="model"
+    aln=ClustalW(self.target_seq,model_seq)
+    aln.AttachView(1,self.peptide_plus_5.Select(""))
+    ent_n=renumber.Renumber(aln)
+
+    for r_counter in range(len(self.peptide_original.residues)):
+      assert self.peptide_original.residues[r_counter].qualified_name == ent_n.residues[r_counter].qualified_name, \
+              "Renumbering failed on residue level: restoring from ResNum+5"
+      for atom_nr in range(len(self.peptide_original.residues[r_counter].atoms)):
+        assert self.peptide_original.residues[r_counter].atoms[atom_nr].name==ent_n.residues[r_counter].atoms[atom_nr].name, \
+                "Renumbering failed on atom level: restoring from ResNum+5"
+  
+
+  def testPeptideRandom(self):
+    """
+    Change residue names in random order
+    """
+    model_seq=seq.SequenceFromChain(" ", self.peptide_random.chains[0]) 
+    model_seq.name="model"
+    aln=ClustalW(self.target_seq,model_seq)
+    aln.AttachView(1,self.peptide_random.Select(""))
+    ent_n=renumber.Renumber(aln)
+
+    for r_counter in range(len(self.peptide_original.residues)):
+      assert self.peptide_original.residues[r_counter].qualified_name == ent_n.residues[r_counter].qualified_name, \
+             "Renumbering failed on residue level: restoring from random residue numbers"
+      for atom_nr in range(len(self.peptide_original.residues[r_counter].atoms)):
+        assert self.peptide_original.residues[r_counter].atoms[atom_nr].name==ent_n.residues[r_counter].atoms[atom_nr].name, \
+               "Renumbering failed on atom level: restoring from random residue numbers"
+
+
+  def testPeptideDel_1_2(self):
+    """
+    First two residues were removed
+    """
+    model_seq=seq.SequenceFromChain(" ", self.peptide_del_1_2.chains[0]) 
+    model_seq.name="model"
+    aln=ClustalW(self.target_seq,model_seq)
+    aln.AttachView(1,self.peptide_del_1_2.Select(""))
+    ent_n=renumber.Renumber(aln)
+
+    for r_counter in range(len(self.peptide_original.residues)):
+      if r_counter==0 or r_counter==1:
+        continue
+      assert self.peptide_original.residues[r_counter].qualified_name == ent_n.residues[r_counter-2].qualified_name, \
+             "Renumbering failed on residue level: restoring from random residue numbers"
+      for atom_nr in range(len(self.peptide_original.residues[r_counter].atoms)):
+        assert self.peptide_original.residues[r_counter].atoms[atom_nr].name==ent_n.residues[r_counter-2].atoms[atom_nr].name, \
+               "Renumbering failed on atom level: restoring from random residue numbers"
+
+
+  def testPeptideDel_4(self):
+    """
+    Residues in the middle (position 4) was removed
+    """
+    model_seq=seq.SequenceFromChain(" ", self.peptide_del_4.chains[0]) 
+    model_seq.name="model"
+    aln=ClustalW(self.target_seq,model_seq)
+    aln.AttachView(1,self.peptide_del_4.Select(""))
+    ent_n=renumber.Renumber(aln)
+
+    flag=0
+    for r_counter in range(len(self.peptide_original.residues)):
+      if r_counter==3:
+        flag=1
+        continue
+      assert self.peptide_original.residues[r_counter].qualified_name == ent_n.residues[r_counter-flag].qualified_name, \
+             "Renumbering failed on residue level: restoring from random residue numbers"
+      for atom_nr in range(len(self.peptide_original.residues[r_counter].atoms)):
+        assert self.peptide_original.residues[r_counter].atoms[atom_nr].name==ent_n.residues[r_counter-flag].atoms[atom_nr].name, \
+               "Renumbering failed on atom level: restoring from random residue numbers"
+
+
+  def testPeptideMutation_3(self):
+    """
+    Mutation to GLY at postion 3
+    """
+    model_seq=seq.SequenceFromChain(" ", self.peptide_mutation_3.chains[0]) 
+    model_seq.name="model"
+    aln=ClustalW(self.target_seq,model_seq)
+    aln.AttachView(1,self.peptide_mutation_3.Select(""))
+    self.assertRaises(RuntimeError, renumber.Renumber, aln)
+
+
+
+if __name__ == "__main__":
+  # test renumbering
+  # test if clustalw package is available on system, otherwise ignore tests
+  try:
+    clustalw_path=settings.Locate(('clustalw', 'clustalw2'))
+  except(settings.FileNotFound):
+    print "Could not find clustalw executable: ignoring unit tests"
+    exit(0)  
+  try:
+    unittest.main()
+  except Exception, e:
+    print e
\ No newline at end of file
diff --git a/modules/seq/alg/tests/test_sequence_identity.cc b/modules/seq/alg/tests/test_sequence_identity.cc
index fa2d58eaface67484bfe5c69ed6486c10c33c02b..a6f55339361fd66687c5691a39fece31cd9d1363 100644
--- a/modules/seq/alg/tests/test_sequence_identity.cc
+++ b/modules/seq/alg/tests/test_sequence_identity.cc
@@ -42,18 +42,18 @@ BOOST_AUTO_TEST_CASE(seqid_one)
   aln.AddSequence(s2);
   
   Real seqid=alg::SequenceIdentity(aln, alg::RefMode::LONGER_SEQUENCE, 0, 1);
-  BOOST_CHECK_CLOSE(seqid, 50.0, 1e-6);
+  BOOST_CHECK_CLOSE(seqid, Real(50.0), Real(1e-6));
 
   // check the default sequence indices
   seqid=alg::SequenceIdentity(aln, alg::RefMode::LONGER_SEQUENCE);
-  BOOST_CHECK_CLOSE(seqid, 50.0, 1e-6);
+  BOOST_CHECK_CLOSE(seqid, Real(50.0), Real(1e-6));
 
   // check the default value for reference mode
   seqid=alg::SequenceIdentity(aln);
-  BOOST_CHECK_CLOSE(seqid, 50.0, 1e-6);  
+  BOOST_CHECK_CLOSE(seqid, Real(50.0), Real(1e-6));  
   
   seqid=alg::SequenceIdentity(aln, alg::RefMode::ALIGNMENT);
-  BOOST_CHECK_CLOSE(seqid, 100.0, 1e-6);  
+  BOOST_CHECK_CLOSE(seqid, Real(100.0), Real(1e-6));  
 }
 
 BOOST_AUTO_TEST_CASE(seqid_two) 
@@ -66,18 +66,18 @@ BOOST_AUTO_TEST_CASE(seqid_two)
   aln.AddSequence(s2);
   
   Real seqid=alg::SequenceIdentity(aln, alg::RefMode::LONGER_SEQUENCE, 0, 1);
-  BOOST_CHECK_CLOSE(seqid, 50.0, 1e-6);
+  BOOST_CHECK_CLOSE(seqid, Real(50.0), Real(1e-6));
 
   // check the default sequence indices
   seqid=alg::SequenceIdentity(aln, alg::RefMode::LONGER_SEQUENCE);
-  BOOST_CHECK_CLOSE(seqid, 50.0, 1e-6);
+  BOOST_CHECK_CLOSE(seqid, Real(50.0), Real(1e-6));
 
   // check the default value for reference mode
   seqid=alg::SequenceIdentity(aln);
-  BOOST_CHECK_CLOSE(seqid, 50.0, 1e-6);  
+  BOOST_CHECK_CLOSE(seqid, Real(50.0), Real(1e-6));  
   
   seqid=alg::SequenceIdentity(aln, alg::RefMode::ALIGNMENT);
-  BOOST_CHECK_CLOSE(seqid, 50.0, 1e-6);  
+  BOOST_CHECK_CLOSE(seqid, Real(50.0), Real(1e-6));  
 }
 
 BOOST_AUTO_TEST_CASE(seqid_three) 
@@ -90,18 +90,18 @@ BOOST_AUTO_TEST_CASE(seqid_three)
   aln.AddSequence(s2);
   
   Real seqid=alg::SequenceIdentity(aln, alg::RefMode::LONGER_SEQUENCE, 0, 1);
-  BOOST_CHECK_CLOSE(seqid, 0.0, 1e-6);
+  BOOST_CHECK_CLOSE(seqid, Real(0.0), Real(1e-6));
 
   // check the default sequence indices
   seqid=alg::SequenceIdentity(aln, alg::RefMode::LONGER_SEQUENCE);
-  BOOST_CHECK_CLOSE(seqid, 0.0, 1e-6);
+  BOOST_CHECK_CLOSE(seqid, Real(0.0), Real(1e-6));
 
   // check the default value for reference mode
   seqid=alg::SequenceIdentity(aln);
-  BOOST_CHECK_CLOSE(seqid, 0.0, 1e-6);  
+  BOOST_CHECK_CLOSE(seqid, Real(0.0), Real(1e-6));  
   
   seqid=alg::SequenceIdentity(aln, alg::RefMode::ALIGNMENT);
-  BOOST_CHECK_CLOSE(seqid, 0.0, 1e-6);  
+  BOOST_CHECK_CLOSE(seqid, Real(0.0), Real(1e-6));  
 }
 
 BOOST_AUTO_TEST_CASE(seqid_empty) 
@@ -114,18 +114,18 @@ BOOST_AUTO_TEST_CASE(seqid_empty)
   aln.AddSequence(s2);
   
   Real seqid=alg::SequenceIdentity(aln, alg::RefMode::LONGER_SEQUENCE, 0, 1);
-  BOOST_CHECK_CLOSE(seqid, 0.0, 1e-6);
+  BOOST_CHECK_CLOSE(seqid, Real(0.0), Real(1e-6));
 
   // check the default sequence indices
   seqid=alg::SequenceIdentity(aln, alg::RefMode::LONGER_SEQUENCE);
-  BOOST_CHECK_CLOSE(seqid, 0.0, 1e-6);
+  BOOST_CHECK_CLOSE(seqid, Real(0.0), Real(1e-6));
 
   // check the default value for reference mode
   seqid=alg::SequenceIdentity(aln);
-  BOOST_CHECK_CLOSE(seqid, 0.0, 1e-6);  
+  BOOST_CHECK_CLOSE(seqid, Real(0.0), Real(1e-6));  
   
   seqid=alg::SequenceIdentity(aln, alg::RefMode::ALIGNMENT);
-  BOOST_CHECK_CLOSE(seqid, 0.0, 1e-6);  
+  BOOST_CHECK_CLOSE(seqid, Real(0.0), Real(1e-6));  
 }
 
 
diff --git a/modules/seq/alg/tests/testfiles/peptide.fasta b/modules/seq/alg/tests/testfiles/peptide.fasta
new file mode 100644
index 0000000000000000000000000000000000000000..8366b04ca04fb059f3d15348e964b9bdf8f4490e
--- /dev/null
+++ b/modules/seq/alg/tests/testfiles/peptide.fasta
@@ -0,0 +1,2 @@
+>peptide
+MPTNA
\ No newline at end of file
diff --git a/modules/seq/alg/tests/testfiles/peptide_del_1_2.pdb b/modules/seq/alg/tests/testfiles/peptide_del_1_2.pdb
new file mode 100644
index 0000000000000000000000000000000000000000..06fc7e30a5bd50f197a3db75a8cda18ba1b5361f
--- /dev/null
+++ b/modules/seq/alg/tests/testfiles/peptide_del_1_2.pdb
@@ -0,0 +1,20 @@
+ATOM     16  N   THR     1     -26.565  -9.309  10.007  1.00  0.00           N
+ATOM     17  CA  THR     1     -26.102  -8.194   9.247  1.00  0.00           C
+ATOM     18  C   THR     1     -25.296  -7.372  10.186  1.00  0.00           C
+ATOM     19  O   THR     1     -24.295  -6.768   9.810  1.00  0.00           O
+ATOM     20  CB  THR     1     -27.274  -7.369   8.683  1.00  0.00           C
+ATOM     21  OG1 THR     1     -28.080  -6.880   9.762  1.00  0.00           O
+ATOM     22  CG2 THR     1     -28.139  -8.227   7.772  1.00  0.00           C
+ATOM     23  N   ASN     2     -25.736  -7.349  11.452  1.00  0.00           N
+ATOM     24  CA  ASN     2     -25.104  -6.609  12.495  1.00  0.00           C
+ATOM     25  C   ASN     2     -23.742  -7.171  12.684  1.00  0.00           C
+ATOM     26  O   ASN     2     -22.806  -6.454  13.030  1.00  0.00           O
+ATOM     27  CB  ASN     2     -25.901  -6.728  13.795  1.00  0.00           C
+ATOM     28  CG  ASN     2     -27.189  -5.929  13.764  1.00  0.00           C
+ATOM     29  OD1 ASN     2     -27.340  -5.007  12.963  1.00  0.00           O
+ATOM     30  ND2 ASN     2     -28.124  -6.282  14.639  1.00  0.00           N
+ATOM     31  N   ALA     3     -16.677  -4.828  10.806  1.00  0.00           N
+ATOM     32  CA  ALA     3     -15.984  -3.708  10.241  1.00  0.00           C
+ATOM     33  C   ALA     3     -15.498  -2.863  11.363  1.00  0.00           C
+ATOM     34  O   ALA     3     -14.369  -2.378  11.344  1.00  0.00           O
+ATOM     35  CB  ALA     3     -16.917  -2.901   9.352  1.00  0.00           C
\ No newline at end of file
diff --git a/modules/seq/alg/tests/testfiles/peptide_del_4.pdb b/modules/seq/alg/tests/testfiles/peptide_del_4.pdb
new file mode 100644
index 0000000000000000000000000000000000000000..183ce9c57a125cc1bd0a16c7125b1fb13154de5d
--- /dev/null
+++ b/modules/seq/alg/tests/testfiles/peptide_del_4.pdb
@@ -0,0 +1,27 @@
+ATOM      1  N   MET     1     -29.037  -8.783  14.347  1.00  0.00           N
+ATOM      2  CA  MET     1     -28.985  -9.502  13.056  1.00  0.00           C
+ATOM      3  C   MET     1     -27.597  -9.852  12.665  1.00  0.00           C
+ATOM      4  O   MET     1     -26.614  -9.275  13.129  1.00  0.00           O
+ATOM      5  CB  MET     1     -29.575  -8.640  11.938  1.00  0.00           C
+ATOM      6  CG  MET     1     -31.084  -8.470  12.016  1.00  0.00           C
+ATOM      7  SD  MET     1     -31.752  -7.534  10.628  1.00  0.00           S
+ATOM      8  CE  MET     1     -33.497  -7.530  11.030  1.00  0.00           C
+ATOM      9  N   PRO     2     -27.533 -10.838  11.828  1.00  0.00           N
+ATOM     10  CA  PRO     2     -26.273 -11.293  11.337  1.00  0.00           C
+ATOM     11  C   PRO     2     -25.709 -10.233  10.478  1.00  0.00           C
+ATOM     12  O   PRO     2     -24.518 -10.265  10.186  1.00  0.00           O
+ATOM     13  CB  PRO     2     -26.616 -12.565  10.559  1.00  0.00           C
+ATOM     14  CG  PRO     2     -28.043 -12.386  10.161  1.00  0.00           C
+ATOM     15  CD  PRO     2     -28.699 -11.637  11.286  1.00  0.00           C
+ATOM     16  N   THR     3     -26.565  -9.309  10.007  1.00  0.00           N
+ATOM     17  CA  THR     3     -26.102  -8.194   9.247  1.00  0.00           C
+ATOM     18  C   THR     3     -25.296  -7.372  10.186  1.00  0.00           C
+ATOM     19  O   THR     3     -24.295  -6.768   9.810  1.00  0.00           O
+ATOM     20  CB  THR     3     -27.274  -7.369   8.683  1.00  0.00           C
+ATOM     21  OG1 THR     3     -28.080  -6.880   9.762  1.00  0.00           O
+ATOM     22  CG2 THR     3     -28.139  -8.227   7.772  1.00  0.00           C
+ATOM     31  N   ALA     4     -16.677  -4.828  10.806  1.00  0.00           N
+ATOM     32  CA  ALA     4     -15.984  -3.708  10.241  1.00  0.00           C
+ATOM     33  C   ALA     4     -15.498  -2.863  11.363  1.00  0.00           C
+ATOM     34  O   ALA     4     -14.369  -2.378  11.344  1.00  0.00           O
+ATOM     35  CB  ALA     4     -16.917  -2.901   9.352  1.00  0.00           C
\ No newline at end of file
diff --git a/modules/seq/alg/tests/testfiles/peptide_mutation_3.pdb b/modules/seq/alg/tests/testfiles/peptide_mutation_3.pdb
new file mode 100644
index 0000000000000000000000000000000000000000..be9fa82c7d15a43b2a9d906466c33c74d0293fca
--- /dev/null
+++ b/modules/seq/alg/tests/testfiles/peptide_mutation_3.pdb
@@ -0,0 +1,32 @@
+ATOM      1  N   MET     1     -29.037  -8.783  14.347  1.00  0.00           N
+ATOM      2  CA  MET     1     -28.985  -9.502  13.056  1.00  0.00           C
+ATOM      3  C   MET     1     -27.597  -9.852  12.665  1.00  0.00           C
+ATOM      4  O   MET     1     -26.614  -9.275  13.129  1.00  0.00           O
+ATOM      5  CB  MET     1     -29.575  -8.640  11.938  1.00  0.00           C
+ATOM      6  CG  MET     1     -31.084  -8.470  12.016  1.00  0.00           C
+ATOM      7  SD  MET     1     -31.752  -7.534  10.628  1.00  0.00           S
+ATOM      8  CE  MET     1     -33.497  -7.530  11.030  1.00  0.00           C
+ATOM      9  N   PRO     2     -27.533 -10.838  11.828  1.00  0.00           N
+ATOM     10  CA  PRO     2     -26.273 -11.293  11.337  1.00  0.00           C
+ATOM     11  C   PRO     2     -25.709 -10.233  10.478  1.00  0.00           C
+ATOM     12  O   PRO     2     -24.518 -10.265  10.186  1.00  0.00           O
+ATOM     13  CB  PRO     2     -26.616 -12.565  10.559  1.00  0.00           C
+ATOM     14  CG  PRO     2     -28.043 -12.386  10.161  1.00  0.00           C
+ATOM     15  CD  PRO     2     -28.699 -11.637  11.286  1.00  0.00           C
+ATOM     16  N   GLY     3     -26.565  -9.309  10.007  1.00  0.00           N
+ATOM     17  CA  GLY     3     -26.102  -8.194   9.247  1.00  0.00           C
+ATOM     18  C   GLY     3     -25.296  -7.372  10.186  1.00  0.00           C
+ATOM     19  O   GLY     3     -24.295  -6.768   9.810  1.00  0.00           O
+ATOM     23  N   ASN     4     -25.736  -7.349  11.452  1.00  0.00           N
+ATOM     24  CA  ASN     4     -25.104  -6.609  12.495  1.00  0.00           C
+ATOM     25  C   ASN     4     -23.742  -7.171  12.684  1.00  0.00           C
+ATOM     26  O   ASN     4     -22.806  -6.454  13.030  1.00  0.00           O
+ATOM     27  CB  ASN     4     -25.901  -6.728  13.795  1.00  0.00           C
+ATOM     28  CG  ASN     4     -27.189  -5.929  13.764  1.00  0.00           C
+ATOM     29  OD1 ASN     4     -27.340  -5.007  12.963  1.00  0.00           O
+ATOM     30  ND2 ASN     4     -28.124  -6.282  14.639  1.00  0.00           N
+ATOM     31  N   ALA     5     -16.677  -4.828  10.806  1.00  0.00           N
+ATOM     32  CA  ALA     5     -15.984  -3.708  10.241  1.00  0.00           C
+ATOM     33  C   ALA     5     -15.498  -2.863  11.363  1.00  0.00           C
+ATOM     34  O   ALA     5     -14.369  -2.378  11.344  1.00  0.00           O
+ATOM     35  CB  ALA     5     -16.917  -2.901   9.352  1.00  0.00           C
\ No newline at end of file
diff --git a/modules/seq/alg/tests/testfiles/peptide_original.pdb b/modules/seq/alg/tests/testfiles/peptide_original.pdb
new file mode 100644
index 0000000000000000000000000000000000000000..8068ae46b1353f2c52556919ef5cf89c2d5e5a1f
--- /dev/null
+++ b/modules/seq/alg/tests/testfiles/peptide_original.pdb
@@ -0,0 +1,35 @@
+ATOM      1  N   MET     1     -29.037  -8.783  14.347  1.00  0.00           N
+ATOM      2  CA  MET     1     -28.985  -9.502  13.056  1.00  0.00           C
+ATOM      3  C   MET     1     -27.597  -9.852  12.665  1.00  0.00           C
+ATOM      4  O   MET     1     -26.614  -9.275  13.129  1.00  0.00           O
+ATOM      5  CB  MET     1     -29.575  -8.640  11.938  1.00  0.00           C
+ATOM      6  CG  MET     1     -31.084  -8.470  12.016  1.00  0.00           C
+ATOM      7  SD  MET     1     -31.752  -7.534  10.628  1.00  0.00           S
+ATOM      8  CE  MET     1     -33.497  -7.530  11.030  1.00  0.00           C
+ATOM      9  N   PRO     2     -27.533 -10.838  11.828  1.00  0.00           N
+ATOM     10  CA  PRO     2     -26.273 -11.293  11.337  1.00  0.00           C
+ATOM     11  C   PRO     2     -25.709 -10.233  10.478  1.00  0.00           C
+ATOM     12  O   PRO     2     -24.518 -10.265  10.186  1.00  0.00           O
+ATOM     13  CB  PRO     2     -26.616 -12.565  10.559  1.00  0.00           C
+ATOM     14  CG  PRO     2     -28.043 -12.386  10.161  1.00  0.00           C
+ATOM     15  CD  PRO     2     -28.699 -11.637  11.286  1.00  0.00           C
+ATOM     16  N   THR     3     -26.565  -9.309  10.007  1.00  0.00           N
+ATOM     17  CA  THR     3     -26.102  -8.194   9.247  1.00  0.00           C
+ATOM     18  C   THR     3     -25.296  -7.372  10.186  1.00  0.00           C
+ATOM     19  O   THR     3     -24.295  -6.768   9.810  1.00  0.00           O
+ATOM     20  CB  THR     3     -27.274  -7.369   8.683  1.00  0.00           C
+ATOM     21  OG1 THR     3     -28.080  -6.880   9.762  1.00  0.00           O
+ATOM     22  CG2 THR     3     -28.139  -8.227   7.772  1.00  0.00           C
+ATOM     23  N   ASN     4     -25.736  -7.349  11.452  1.00  0.00           N
+ATOM     24  CA  ASN     4     -25.104  -6.609  12.495  1.00  0.00           C
+ATOM     25  C   ASN     4     -23.742  -7.171  12.684  1.00  0.00           C
+ATOM     26  O   ASN     4     -22.806  -6.454  13.030  1.00  0.00           O
+ATOM     27  CB  ASN     4     -25.901  -6.728  13.795  1.00  0.00           C
+ATOM     28  CG  ASN     4     -27.189  -5.929  13.764  1.00  0.00           C
+ATOM     29  OD1 ASN     4     -27.340  -5.007  12.963  1.00  0.00           O
+ATOM     30  ND2 ASN     4     -28.124  -6.282  14.639  1.00  0.00           N
+ATOM     31  N   ALA     5     -16.677  -4.828  10.806  1.00  0.00           N
+ATOM     32  CA  ALA     5     -15.984  -3.708  10.241  1.00  0.00           C
+ATOM     33  C   ALA     5     -15.498  -2.863  11.363  1.00  0.00           C
+ATOM     34  O   ALA     5     -14.369  -2.378  11.344  1.00  0.00           O
+ATOM     35  CB  ALA     5     -16.917  -2.901   9.352  1.00  0.00           C
\ No newline at end of file
diff --git a/modules/seq/alg/tests/testfiles/peptide_plus_5.pdb b/modules/seq/alg/tests/testfiles/peptide_plus_5.pdb
new file mode 100644
index 0000000000000000000000000000000000000000..c64a572640047c0f784ecf3ccd733b4756f39f92
--- /dev/null
+++ b/modules/seq/alg/tests/testfiles/peptide_plus_5.pdb
@@ -0,0 +1,35 @@
+ATOM      1  N   MET     6     -29.037  -8.783  14.347  1.00  0.00           N
+ATOM      2  CA  MET     6     -28.985  -9.502  13.056  1.00  0.00           C
+ATOM      3  C   MET     6     -27.597  -9.852  12.665  1.00  0.00           C
+ATOM      4  O   MET     6     -26.614  -9.275  13.129  1.00  0.00           O
+ATOM      5  CB  MET     6     -29.575  -8.640  11.938  1.00  0.00           C
+ATOM      6  CG  MET     6     -31.084  -8.470  12.016  1.00  0.00           C
+ATOM      7  SD  MET     6     -31.752  -7.534  10.628  1.00  0.00           S
+ATOM      8  CE  MET     6     -33.497  -7.530  11.030  1.00  0.00           C
+ATOM      9  N   PRO     7     -27.533 -10.838  11.828  1.00  0.00           N
+ATOM     10  CA  PRO     7     -26.273 -11.293  11.337  1.00  0.00           C
+ATOM     11  C   PRO     7     -25.709 -10.233  10.478  1.00  0.00           C
+ATOM     12  O   PRO     7     -24.518 -10.265  10.186  1.00  0.00           O
+ATOM     13  CB  PRO     7     -26.616 -12.565  10.559  1.00  0.00           C
+ATOM     14  CG  PRO     7     -28.043 -12.386  10.161  1.00  0.00           C
+ATOM     15  CD  PRO     7     -28.699 -11.637  11.286  1.00  0.00           C
+ATOM     16  N   THR     8     -26.565  -9.309  10.007  1.00  0.00           N
+ATOM     17  CA  THR     8     -26.102  -8.194   9.247  1.00  0.00           C
+ATOM     18  C   THR     8     -25.296  -7.372  10.186  1.00  0.00           C
+ATOM     19  O   THR     8     -24.295  -6.768   9.810  1.00  0.00           O
+ATOM     20  CB  THR     8     -27.274  -7.369   8.683  1.00  0.00           C
+ATOM     21  OG1 THR     8     -28.080  -6.880   9.762  1.00  0.00           O
+ATOM     22  CG2 THR     8     -28.139  -8.227   7.772  1.00  0.00           C
+ATOM     23  N   ASN     9     -25.736  -7.349  11.452  1.00  0.00           N
+ATOM     24  CA  ASN     9     -25.104  -6.609  12.495  1.00  0.00           C
+ATOM     25  C   ASN     9     -23.742  -7.171  12.684  1.00  0.00           C
+ATOM     26  O   ASN     9     -22.806  -6.454  13.030  1.00  0.00           O
+ATOM     27  CB  ASN     9     -25.901  -6.728  13.795  1.00  0.00           C
+ATOM     28  CG  ASN     9     -27.189  -5.929  13.764  1.00  0.00           C
+ATOM     29  OD1 ASN     9     -27.340  -5.007  12.963  1.00  0.00           O
+ATOM     30  ND2 ASN     9     -28.124  -6.282  14.639  1.00  0.00           N
+ATOM     31  N   ALA    10     -16.677  -4.828  10.806  1.00  0.00           N
+ATOM     32  CA  ALA    10     -15.984  -3.708  10.241  1.00  0.00           C
+ATOM     33  C   ALA    10     -15.498  -2.863  11.363  1.00  0.00           C
+ATOM     34  O   ALA    10     -14.369  -2.378  11.344  1.00  0.00           O
+ATOM     35  CB  ALA    10     -16.917  -2.901   9.352  1.00  0.00           C
\ No newline at end of file
diff --git a/modules/seq/alg/tests/testfiles/peptide_random.pdb b/modules/seq/alg/tests/testfiles/peptide_random.pdb
new file mode 100644
index 0000000000000000000000000000000000000000..74597e72bf51d7f8f0f6fcacb198dd14d16f7e3f
--- /dev/null
+++ b/modules/seq/alg/tests/testfiles/peptide_random.pdb
@@ -0,0 +1,35 @@
+ATOM      1  N   MET     6     -29.037  -8.783  14.347  1.00  0.00           N
+ATOM      2  CA  MET     6     -28.985  -9.502  13.056  1.00  0.00           C
+ATOM      3  C   MET     6     -27.597  -9.852  12.665  1.00  0.00           C
+ATOM      4  O   MET     6     -26.614  -9.275  13.129  1.00  0.00           O
+ATOM      5  CB  MET     6     -29.575  -8.640  11.938  1.00  0.00           C
+ATOM      6  CG  MET     6     -31.084  -8.470  12.016  1.00  0.00           C
+ATOM      7  SD  MET     6     -31.752  -7.534  10.628  1.00  0.00           S
+ATOM      8  CE  MET     6     -33.497  -7.530  11.030  1.00  0.00           C
+ATOM      9  N   PRO     1     -27.533 -10.838  11.828  1.00  0.00           N
+ATOM     10  CA  PRO     1     -26.273 -11.293  11.337  1.00  0.00           C
+ATOM     11  C   PRO     1     -25.709 -10.233  10.478  1.00  0.00           C
+ATOM     12  O   PRO     1     -24.518 -10.265  10.186  1.00  0.00           O
+ATOM     13  CB  PRO     1     -26.616 -12.565  10.559  1.00  0.00           C
+ATOM     14  CG  PRO     1     -28.043 -12.386  10.161  1.00  0.00           C
+ATOM     15  CD  PRO     1     -28.699 -11.637  11.286  1.00  0.00           C
+ATOM     16  N   THR     7     -26.565  -9.309  10.007  1.00  0.00           N
+ATOM     17  CA  THR     7     -26.102  -8.194   9.247  1.00  0.00           C
+ATOM     18  C   THR     7     -25.296  -7.372  10.186  1.00  0.00           C
+ATOM     19  O   THR     7     -24.295  -6.768   9.810  1.00  0.00           O
+ATOM     20  CB  THR     7     -27.274  -7.369   8.683  1.00  0.00           C
+ATOM     21  OG1 THR     7     -28.080  -6.880   9.762  1.00  0.00           O
+ATOM     22  CG2 THR     7     -28.139  -8.227   7.772  1.00  0.00           C
+ATOM     23  N   ASN     4     -25.736  -7.349  11.452  1.00  0.00           N
+ATOM     24  CA  ASN     4     -25.104  -6.609  12.495  1.00  0.00           C
+ATOM     25  C   ASN     4     -23.742  -7.171  12.684  1.00  0.00           C
+ATOM     26  O   ASN     4     -22.806  -6.454  13.030  1.00  0.00           O
+ATOM     27  CB  ASN     4     -25.901  -6.728  13.795  1.00  0.00           C
+ATOM     28  CG  ASN     4     -27.189  -5.929  13.764  1.00  0.00           C
+ATOM     29  OD1 ASN     4     -27.340  -5.007  12.963  1.00  0.00           O
+ATOM     30  ND2 ASN     4     -28.124  -6.282  14.639  1.00  0.00           N
+ATOM     31  N   ALA     2     -16.677  -4.828  10.806  1.00  0.00           N
+ATOM     32  CA  ALA     2     -15.984  -3.708  10.241  1.00  0.00           C
+ATOM     33  C   ALA     2     -15.498  -2.863  11.363  1.00  0.00           C
+ATOM     34  O   ALA     2     -14.369  -2.378  11.344  1.00  0.00           O
+ATOM     35  CB  ALA     2     -16.917  -2.901   9.352  1.00  0.00           C
\ No newline at end of file
diff --git a/modules/seq/base/tests/test_aligned_column.cc b/modules/seq/base/tests/test_aligned_column.cc
index f76573df3c883f7f91b076442dae9900e0c5a42e..757c8d8cb5496119324f0e666388b390b7ee2929 100644
--- a/modules/seq/base/tests/test_aligned_column.cc
+++ b/modules/seq/base/tests/test_aligned_column.cc
@@ -43,7 +43,7 @@ struct Fixture {
   Fixture() {
     eh = CreateEntity();
     eh.SetName("TestEntity");
-    XCSEditor e=eh.RequestXCSEditor();
+    XCSEditor e=eh.EditXCS();
     chain = e.InsertChain("A");
     res1 = e.AppendResidue(chain, "ARG");
     e.InsertAtom(res1, "CA",geom::Vec3(1,0,0));
diff --git a/modules/seq/base/tests/test_alignment.cc b/modules/seq/base/tests/test_alignment.cc
index 0491f7d35c124c846b5ddd48cee8965e77492025..516c966a487dc92979034befd7f89ec12a994f81 100644
--- a/modules/seq/base/tests/test_alignment.cc
+++ b/modules/seq/base/tests/test_alignment.cc
@@ -38,7 +38,7 @@ struct Fixture {
   Fixture() {
     eh = CreateEntity();
     eh.SetName("TestEntity");
-    XCSEditor e=eh.RequestXCSEditor();
+    XCSEditor e=eh.EditXCS();
     chain = e.InsertChain("A");
     res1 = e.AppendResidue(chain, "ARG");
     e.InsertAtom(res1, "CA",geom::Vec3(1,0,0));
diff --git a/modules/seq/base/tests/test_seq.py b/modules/seq/base/tests/test_seq.py
index 26abba6896e53f32f19ef43cb4d44e5999bb6c2f..80f13e364c07e3ba9665f34e62a462af79ae79ec 100644
--- a/modules/seq/base/tests/test_seq.py
+++ b/modules/seq/base/tests/test_seq.py
@@ -6,7 +6,7 @@ from ost import seq
 
 def fixture():
   e=mol.CreateEntity()
-  ede=e.RequestXCSEditor()
+  ede=e.EditXCS()
   chain=ede.InsertChain('A')
   for res in 'ABCDEFGH':
     r=ede.AppendResidue(chain, res)
diff --git a/modules/seq/base/tests/test_sequence.cc b/modules/seq/base/tests/test_sequence.cc
index e787aafb7c3de95e8d93c2b55de8b3b9bba7c8f4..264a902ea81455dcdeb994893536d24c9c9f9455 100644
--- a/modules/seq/base/tests/test_sequence.cc
+++ b/modules/seq/base/tests/test_sequence.cc
@@ -34,7 +34,7 @@ struct Fixture {
   Fixture() {
     eh = CreateEntity();
     eh.SetName("TestEntity");
-    XCSEditor e=eh.RequestXCSEditor();
+    XCSEditor e=eh.EditXCS();
     chain = e.InsertChain("A");
     res1 = e.AppendResidue(chain, "ARG");
     e.InsertAtom(res1, "CA",geom::Vec3(1,0,0));
diff --git a/scripts/ost.in b/scripts/ost.in
index 16dc6738783ce6ef78dcf6c170feb30125a47261..cacb82d60b86ff0ffd6041e795fc7480c797c92e 100755
--- a/scripts/ost.in
+++ b/scripts/ost.in
@@ -76,7 +76,9 @@ else
 fi
 # finally pass control to python instance
 IFS="#"
-exec $pyexec $interactive "$DNG_ROOT/@LIBDIR@/openstructure/init_cl.py" $opts
+$pyexec $interactive "$DNG_ROOT/@LIBDIR@/openstructure/init_cl.py" $opts
+RC=$?
 IFS=$' \t\n'
+exit $RC