Index: /library/bdm/bdmerror.h
===================================================================
--- /library/bdm/bdmerror.h (revision 766)
+++ /library/bdm/bdmerror.h (revision 1020)
@@ -48,4 +48,12 @@
 #endif // if defined(NDEBUG)
 
+#if defined(NDEBUG)
+//! DO argument if in DEBUG model
+#define DEBUG(command) ((void) 0)
+#else
+//! DO argument if in DEBUG model
+#define DEBUG(command) command
+#endif // if defined(NDEBUG)
+
 //! Unconditionally throw std::runtime_error
 #define bdm_error(s) \
Index: /library/bdm/base/bdmbase.h
===================================================================
--- /library/bdm/base/bdmbase.h (revision 1009)
+++ /library/bdm/base/bdmbase.h (revision 1020)
@@ -76,4 +76,6 @@
 }
 \enddot
+
+RV name may be empty string! In that case, it is not a valid name but only a size holder. It will fail in comparison.
 */
 
@@ -1023,11 +1025,17 @@
 	protected:
 		datalink_part dl;
+		int vecfromlen;
 	public:
 		void update(const vec &v1){
 			bdm_assert_debug(length()==dl._downsize(),"vec_from_vec incompatible");
-			bdm_assert_debug(v1.length()>=dl._upsize(),"vec_from_vec incompatible");//does not guarantee anything!
+			bdm_assert_debug(v1.length()==vecfromlen,"This vec was connected to vec of length "+num2str(vecfromlen)+
+			", but vec of length "+num2str(v1.length())+" was obtained"  );
 			dl.filldown(v1,*this);
 		};
-		void connect(const RV &vecrv, const RV & vec1){dl.set_connection(vecrv,vec1);set_length(vecrv._dsize());};
+		void connect(const RV &vecrv, const RV & vec1){
+			bdm_assert(vecrv._dsize()==length(),"Description of this vector, "+ vecrv.to_string() +" does not math it length: " + num2str(length()));
+			dl.set_connection(vecrv,vec1);
+			bdm_assert(dl._downsize()==length(), "Rv of this vector, "+vecrv.to_string() +" was not found in given rv: "+vec1.to_string());
+		};
 };
 
@@ -1252,11 +1260,11 @@
 class BM : public root {
 	//! \var log_level_enums logfull
-	//! TODO DOPLNIT
+	//! log full description of posterior in descriptive structure
 
 	//! \var log_level_enums logevidence
-	//! TODO DOPLNIT
+	//! log value of eveidence in each step
 	
 	//! \var log_level_enums logbounds
-	//! TODO DOPLNIT	
+	//! log lower and upper bounds of estimates
 	LOG_LEVEL(BM,logfull,logevidence,logbounds);
 
Index: /library/bdm/stat/exp_family.h
===================================================================
--- /library/bdm/stat/exp_family.h (revision 1015)
+++ /library/bdm/stat/exp_family.h (revision 1020)
@@ -76,7 +76,8 @@
 //! Estimator for Exponential family
 class BMEF : public BM {
-protected:
+	public:
 	//! forgetting factor
 	double frg;
+	protected:
 	//! cached value of lognc() in the previous step (used in evaluation of \c ll )
 	double last_lognc;
Index: /library/bdm/stat/emix.h
===================================================================
--- /library/bdm/stat/emix.h (revision 979)
+++ /library/bdm/stat/emix.h (revision 1020)
@@ -476,4 +476,32 @@
 UIREGISTER(ProdBM);
 
+//! \brief class for on-line model selection 
+class ModelComparator: public ProdBM{
+	protected:
+		multiBM weights;
+	public:
+		void bayes(const vec &yt, const vec &cond){
+			vec w_nn(no_bms());
+			for (int i=0; i<no_bms(); i++){
+				bm(i)->bayes(yt,cond);
+				w_nn(i) += bm(i)->_ll();
+			}
+			vec w=exp(w_nn-max(w_nn));
+			weights.bayes(w/sum(w));
+		}
+		void validate(){
+			ProdBM::validate();
+			weights.validate();
+		}
+		void from_setting(const Setting& set){
+			ProdBM::from_setting(set);
+			UI::get(weights.frg, set, "frg",UI::optional);
+		}
+		void to_setting(Setting& set) const{
+			ProdBM::to_setting(set);
+			UI::save(weights.frg, set, "frg");
+		}
+};
+
 }
 #endif //MX_H
Index: /applications/bdmtoolbox/mex/estimator.cpp
===================================================================
--- /applications/bdmtoolbox/mex/estimator.cpp (revision 979)
+++ /applications/bdmtoolbox/mex/estimator.cpp (revision 1020)
@@ -95,5 +95,5 @@
 
 	//DBG
- 	Cfg.writeFile ( "estimator.cfg" );
+	DEBUG( 	Cfg.writeFile ( "estimator.cfg" );)
 
 #else
