Index: library/bdm/estim/mixtures.cpp
===================================================================
--- library/bdm/estim/mixtures.cpp (revision 943)
+++ library/bdm/estim/mixtures.cpp (revision 1004)
@@ -8,5 +8,4 @@
 	//prepare sizes
 	Coms.set_size ( c );
-	n = c;
 	weights.set_parameters ( ones ( c ) ); //assume at least one observation in each comp.
 	//est will be done at the end
@@ -22,10 +21,10 @@
 
 	//Copy it to the rest
-	for ( i = 1; i < n; i++ ) {
+	for ( i = 1; i < Coms.length(); i++ ) {
 		//copy Com0 and create new rvs for them
 		Coms ( i ) =  (BMEF*) Coms ( 0 )->_copy ( );
 	}
 	//Pick some data for each component and update it
-	for ( i = 0; i < n; i++ ) {
+	for ( i = 0; i < Coms.length(); i++ ) {
 		//pick one datum
 		int ind = (int) floor ( ndat * UniRNG.sample() );
@@ -44,4 +43,5 @@
 	multiBM weights0 ( weights );
 
+	int n = Coms.length();
 	Array<BMEF*> Coms0 ( n );
 	for ( i = 0; i < n; i++ ) {
@@ -131,5 +131,5 @@
 	vec w = weights.posterior().mean();
 	double exLL = 0.0;
-	for ( int i = 0; i < n; i++ ) {
+	for ( int i = 0; i < Coms.length(); i++ ) {
 		exLL += w ( i ) * exp ( Coms ( i )->logpred ( yt ) );
 	}
@@ -138,6 +138,6 @@
 
 emix* MixEF::epredictor ( const vec &vec) const {
-	Array<shared_ptr<epdf> > pC ( n );
-	for ( int i = 0; i < n; i++ ) {
+	Array<shared_ptr<epdf> > pC ( Coms.length() );
+	for ( int i = 0; i < Coms.length(); i++ ) {
 		pC ( i ) = Coms ( i )->epredictor ( );
 		pC (i) -> set_rv(_yrv());
@@ -153,7 +153,7 @@
 void MixEF::flatten ( const BMEF* M2 ) {
 	const MixEF* Mix2 = dynamic_cast<const MixEF*> ( M2 );
-	bdm_assert_debug ( Mix2->n == n, "Different no of coms" );
+	bdm_assert_debug ( Mix2->Coms.length() == Coms.length(), "Different no of coms" );
 	//Flatten each component
-	for ( int i = 0; i < n; i++ ) {
+	for ( int i = 0; i < Coms.length(); i++ ) {
 		Coms ( i )->flatten ( Mix2->Coms ( i ) );
 	}
Index: library/bdm/estim/mixtures.h
===================================================================
--- library/bdm/estim/mixtures.h (revision 997)
+++ library/bdm/estim/mixtures.h (revision 1004)
@@ -43,6 +43,4 @@
 class MixEF: public BMEF {
 protected:
-	//!Number of components
-	int n;
 	//! Models for Components of \f$\theta_i\f$
 	Array<BMEF*> Coms;
@@ -57,6 +55,6 @@
 		public:
 		eprod_mix(const MixEF &m):mix(m){}
-		const epdf* factor(int i) const {return (i==(mix.n-1)) ? &mix.weights.posterior() : &mix.Coms(i)->posterior();}
-		const int no_factors()const {return mix.n+1;}
+		const epdf* factor(int i) const {return (i==(mix.Coms.length()-1)) ? &mix.weights.posterior() : &mix.Coms(i)->posterior();}
+		const int no_factors()const {return mix.Coms.length()+1;}
 	} est;
 	////!indices of component rvc in common rvc
@@ -68,7 +66,7 @@
 	//! Full constructor
 	MixEF ( const Array<BMEF*> &Coms0, const vec &alpha0 ) :
-			BMEF ( ), n ( Coms0.length() ), Coms ( n ),
+			BMEF ( ), Coms ( Coms0.length() ),
 			weights (), est(*this), method ( QB ) {
-		for ( int i = 0; i < n; i++ ) {
+		for ( int i = 0; i < Coms0.length(); i++ ) {
 			Coms ( i ) = ( BMEF* ) Coms0 ( i )->_copy();
 		}
@@ -79,11 +77,11 @@
 	//! Constructor of empty mixture
 	MixEF () :
-			BMEF ( ), n ( 0 ), Coms ( 0 ),
+			BMEF ( ), Coms ( 0 ),
 			weights (), est(*this), method ( QB ) {
 	}
 	//! Copy constructor
-	MixEF ( const MixEF &M2 ) : BMEF ( ), n ( M2.n ), Coms ( n ),
+	MixEF ( const MixEF &M2 ) : BMEF ( ),  Coms ( M2.Coms.length() ),
 			weights ( M2.weights ), est(*this), method ( M2.method ) {
-		for ( int i = 0; i < n; i++ ) {
+		for ( int i = 0; i < M2.Coms.length(); i++ ) {
 			Coms ( i ) = (BMEF*) M2.Coms ( i )->_copy();
 		}
@@ -121,9 +119,16 @@
 	}
 
-	void to_setting ( Setting &set ) const {
-		BMEF::to_setting( set );
-		UI::save ( Coms, set, "Coms" );
-		UI::save ( &weights, set, "weights" );
-	}
+void to_setting ( Setting &set ) const {
+	BMEF::to_setting( set );
+	UI::save ( Coms, set, "Coms" );
+	UI::save ( &weights, set, "weights" );
+}
+/*! \brief reads data from setting
+*/
+void from_setting (const  Setting &set ) {
+	BMEF::from_setting( set );
+	UI::get ( Coms, set, "Coms" );
+	UI::get ( weights, set, "weights" );
+}
 };
 UIREGISTER ( MixEF );
