diff --git a/modules/gfx/src/entity.cc b/modules/gfx/src/entity.cc
index 45dbe8f706f80cbb3e9050f937339b164d23b9ff..27ebbe9573320e2588242a226b262a9a93b7225c 100644
--- a/modules/gfx/src/entity.cc
+++ b/modules/gfx/src/entity.cc
@@ -674,7 +674,7 @@ void Entity::SetDetailColor(const Color& col, const String& selection)
 /// \brief set selection
 void Entity::SetSelection(const mol::EntityView& view)
 {
-  if (!sel_.IsValid()) {
+  if (!view.IsValid()) {
     sel_=this->GetView().CreateEmptyView();
   } else {
     sel_=view;
diff --git a/modules/gui/src/tools/tool_bar.cc b/modules/gui/src/tools/tool_bar.cc
index b3cb11437a7b5018daafd818f8934d8b8fe40a07..11621af0f4f07980bf0be1755bbbd54cb7009dd5 100644
--- a/modules/gui/src/tools/tool_bar.cc
+++ b/modules/gui/src/tools/tool_bar.cc
@@ -20,7 +20,7 @@
 #include <QDebug>
 #include <QActionGroup>
 
-
+#include <ost/mol/query_view_wrapper.hh>
 #include <ost/gui/tools/tool_manager.hh>
 #include <ost/gui/gosty_app.hh>
 #include "tool_bar.hh"
@@ -37,7 +37,7 @@ ToolBar::ToolBar(QWidget* parent):
           SLOT(ActivateTool(QAction*)));  
   connect(this, SIGNAL(actionTriggered(QAction*)),
           this,SLOT(OnAction(QAction*)));
-  connect(scene_win, SIGNAL(ActiveNodesChanged(gfx::NodePtrList)),
+  connect(scene_win, SIGNAL(ActiveNodesChanged(gfx::NodePtrList,gfx::EntityP,mol::QueryViewWrapperList)),
           this,SLOT(OnActiveGfxNodeChanged(gfx::NodePtrList)));
   connect(&ToolManager::Instance(), SIGNAL(ToolAdded(const Tool*&)),
           this, SLOT(OnToolAdded(const Tool*&)));          
diff --git a/modules/mol/base/src/query_view_wrapper.hh b/modules/mol/base/src/query_view_wrapper.hh
index 40aa3f981863bac5d884f0632bd0c260d4dbb20c..e2dc1fc1b2fec8313082cf5de0b7ca84375583b6 100644
--- a/modules/mol/base/src/query_view_wrapper.hh
+++ b/modules/mol/base/src/query_view_wrapper.hh
@@ -19,6 +19,7 @@
 #ifndef OST_QUERY_VIEW_WRAPPER_HH
 #define OST_QUERY_VIEW_WRAPPER_HH
 
+#include <ost/mol/view_type_fw.hh>
 #include <ost/mol/module_config.hh>
 #include <ost/mol/entity_view.hh>
 #include <ost/mol/entity_handle.hh>
diff --git a/modules/mol/base/src/view_op.cc b/modules/mol/base/src/view_op.cc
index 88e964d92c3ee655ca600c1dc31ecf36ae53238e..c186931a79ab8b2fca6df5a67ab8c494c71957d7 100644
--- a/modules/mol/base/src/view_op.cc
+++ b/modules/mol/base/src/view_op.cc
@@ -109,7 +109,9 @@ mol::EntityView Difference(const mol::EntityView& ev1,
   if (ev1.GetHandle()!=ev2.GetHandle()) {
     throw IntegrityError(combining_not_allowed);
   }
+  if(ev2.GetChainCount()==0 && ev2.GetResidueCount()==0 && ev2.GetAtomCount()==0)return ev1.Copy();
   mol::EntityView diff=ev1.CreateEmptyView();
+  if(ev1.GetChainCount()==0 && ev1.GetResidueCount()==0 && ev1.GetAtomCount()==0)return diff;
   mol::ChainViewList::const_iterator c_it=ev1.GetChainList().begin();
   for ( ; c_it!=ev1.GetChainList().end(); ++c_it) {
     mol::ChainView cv=*c_it;
diff --git a/modules/mol/base/src/view_type_fw.hh b/modules/mol/base/src/view_type_fw.hh
index de600d79e5018393799651a9fc838554f9369e72..0916266f205e403c8f612c240f92c35732548bfa 100644
--- a/modules/mol/base/src/view_type_fw.hh
+++ b/modules/mol/base/src/view_type_fw.hh
@@ -48,6 +48,9 @@ typedef boost::shared_ptr<EntityViewData> EntityViewDataPtr;
 typedef boost::weak_ptr<EntityViewData> EntityViewDataWeakPtr;
 typedef std::vector<EntityView> EntityViewList;
 
+class QueryViewWrapper;
+typedef std::vector<QueryViewWrapper> QueryViewWrapperList;
+
 /// \brief Flags to control the behaviour when adding handles to views.
 struct ViewAddFlag {
   typedef enum {