Index: library/bdm/base/bdmbase.h
===================================================================
--- library/bdm/base/bdmbase.h (revision 895)
+++ library/bdm/base/bdmbase.h (revision 896)
@@ -594,4 +594,5 @@
 	//!@}
 	void from_setting ( const Setting &set ) {
+		root::from_setting( set );
 		shared_ptr<RV> r = UI::build<RV> ( set, "rv", UI::optional );
 		if ( r ) {
@@ -740,5 +741,5 @@
 class datalink_part : public datalink {
 protected:
-	//! indeces of values in vector downsize
+	//! indices of values in vector downsize
 	ivec v2v_down;
 public:
@@ -760,9 +761,9 @@
 	//! rv of the history
 	RV Hrv;
-	//! h2v : indeces in down
+	//! h2v : indices in down
 	ivec h2v_down;
-	//! h2v : indeces in history
+	//! h2v : indices in history
 	ivec h2v_hist;
-	//! v2h: indeces of up too be pushed to h
+	//! v2h: indices of up too be pushed to h
 	ivec v2h_up;
 public:
@@ -932,9 +933,9 @@
 	virtual void getdata ( vec &dt ) const = 0;
 
-	//! Returns data records at indeces. Default is inefficent.
-	virtual void getdata ( vec &dt, const ivec &indeces ) {
+	//! Returns data records at indices. Default is inefficent.
+	virtual void getdata ( vec &dt, const ivec &indices ) {
 		vec tmp(dtsize);
 		getdata(tmp);
-		dt = tmp(indeces);
+		dt = tmp(indices);
 	};
 
@@ -942,6 +943,6 @@
 	virtual void write ( const vec &ut ) NOT_IMPLEMENTED_VOID;
 
-	//! Accepts action variables at specific indeces
-	virtual void write ( const vec &ut, const ivec &indeces ) NOT_IMPLEMENTED_VOID;
+	//! Accepts action variables at specific indices
+	virtual void write ( const vec &ut, const ivec &indices ) NOT_IMPLEMENTED_VOID;
 
 	//! Moves from \f$ t \f$ to \f$ t+1 \f$, i.e. perfroms the actions and reads response of the system.
@@ -960,4 +961,5 @@
 		return Urv;
 	}
+
 	//! set random variables
 	virtual void set_drv ( const  RV &drv, const RV &urv) {
Index: library/bdm/base/datasources.h
===================================================================
--- library/bdm/base/datasources.h (revision 895)
+++ library/bdm/base/datasources.h (revision 896)
@@ -32,14 +32,27 @@
 	//! active column in the Data matrix
 	int time;
-	//!  vector of rows that are presented in Dt
-	ivec rowid;
-
-public:
+
+public:
+	//!Default constructor
+	MemDS () {};
+
+	//! Convenience constructor
+	MemDS ( mat &Dat );
+
+	//! returns number of data in the file;
 	int max_length() {
 		return Data.cols();
 	}
+
 	void getdata ( vec &dt ) const;
-	void getdata ( vec &dt, const ivec &indeces );
-	void set_drv ( const RV &drv, const  RV &urv );
+
+	void getdata ( vec &dt, const ivec &indices );
+
+	void set_drv ( const RV &drv );
+
+	void set_drv ( const RV &drv, const RV &urv )
+	{
+		bdm_error ( "MemDS::urv is not supported" );
+	}
 
 	void write ( const vec &ut ) {
@@ -52,8 +65,5 @@
 
 	void step();
-	//!Default constructor
-	MemDS () {};
-	//! Convenience constructor
-	MemDS ( mat &Dat, ivec &rowid0 );
+
 	/*! Create object from the following structure
 	\code
@@ -63,5 +73,4 @@
 	   drv = {class="RV"; ...} // Identification how rows of the matrix Data will be known to others
 	   time = 0;               // Index of the first column to user_info,
-	   rowid = [1,2,3...];     // ids of rows to be used
 	}
 	\endcode
@@ -69,5 +78,4 @@
 	If the optional fields are not given, they will be filled as follows:
 	\code
-	rowid= [0, 1, 2, ...number_of_rows_of_Data];
 	drv = {names=("ch0", "ch1", "ch2", ..."number_of_rows_of_Data");
 	      sizes=( 1    1    1 ...);
@@ -76,27 +84,9 @@
 	time = 0;
 	\endcode
-	If \c rowid is given, \c drv will be named after indeces in rowids.
+	If \c rowid is given, \c drv will be named after indices in rowids.
 
 	Hence the data provided by method \c getdata() will be full column of matrix Data starting from the first record.
 	*/
-	void from_setting ( const Setting &set ) {
-		UI::get ( Data, set, "Data", UI::compulsory );
-		if ( !UI::get ( time, set, "time", UI::optional ) ) {
-			time = 0;
-		}
-		if ( !UI::get ( rowid, set, "rowid", UI::optional ) ) {
-			rowid = linspace ( 0, Data.rows() - 1 );
-		}
-		shared_ptr<RV> r = UI::build<RV> ( set, "drv", UI::optional );
-		if ( !r ) {
-			r = new RV();
-			for ( int i = 0; i < rowid.length(); i++ ) {
-				r->add ( RV ( "ch" + num2str ( rowid ( i ) ), 1, 0 ) );
-			}
-		}
-		set_drv ( *r, RV() ); //empty urv
-		dtsize = r->_dsize();
-		utsize = 0;
-	}
+	void from_setting ( const Setting &set );
 };
 UIREGISTER ( MemDS );
@@ -106,23 +96,8 @@
 */
 class FileDS: public MemDS {
-
-public:
-	void getdata ( vec &dt ) {
-		dt = Data.get_col ( time );
-	}
-
-	void getdata ( vec &dt, const ivec &indices ) {
-		vec tmp = Data.get_col ( time );
-		dt = tmp ( indices );
-	}
-
-	//! returns number of data in the file;
-	int ndat() {
-		return Data.cols();
-	}
-	//! no sense to log this type
-	void log_register ( logger &L, const string &prefix ) {};
-	//! no sense to log this type
-	void log_write ( ) const {};
+protected:
+	string filename;
+public:
+	void from_setting ( const Setting & set );
 };
 
@@ -142,5 +117,5 @@
 		it >> Data;
 		time = 0;
-		//rowid and delays are ignored
+		//delays are ignored
 	};
 
@@ -165,8 +140,6 @@
 */
 class CsvFileDS: public FileDS {
-
-public:
-	//! Constructor - create DS from a CSV file.
-	CsvFileDS ( const string& fname, const string& orientation = "BY_COL" );
+public:
+	void from_setting ( const Setting & set );
 };
 
@@ -203,6 +176,6 @@
 	virtual void write ( const vec &ut ) NOT_IMPLEMENTED_VOID;
 
-	//! Accepts action variables at specific indeces
-	virtual void write ( const vec &ut, const ivec &indeces ) NOT_IMPLEMENTED_VOID;
+	//! Accepts action variables at specific indices
+	virtual void write ( const vec &ut, const ivec &indices ) NOT_IMPLEMENTED_VOID;
 
 	/*!
@@ -261,6 +234,6 @@
 
 
-	//! Returns data records at indeces.
-	virtual void getdata ( vec &dt, const ivec &indeces ) NOT_IMPLEMENTED_VOID;
+	//! Returns data records at indices.
+	virtual void getdata ( vec &dt, const ivec &indices ) NOT_IMPLEMENTED_VOID;
 
 
@@ -364,5 +337,5 @@
 	}
 
-	virtual void write ( const vec &ut, const ivec &indeces ) NOT_IMPLEMENTED_VOID;
+	virtual void write ( const vec &ut, const ivec &indices ) NOT_IMPLEMENTED_VOID;
 
 	/*! UI for stateDS
Index: library/bdm/base/bdmbase.cpp
===================================================================
--- library/bdm/base/bdmbase.cpp (revision 889)
+++ library/bdm/base/bdmbase.cpp (revision 896)
@@ -522,5 +522,5 @@
 	// decide if we need to copy val to history
 	if ( Hrv._dsize() > 0 ) {
-		v2h_up = rv_hist0.dataind ( rv_up ); // indeces of elements of rv_up to be copied
+		v2h_up = rv_hist0.dataind ( rv_up ); // indices of elements of rv_up to be copied
 	} // else v2h_up is empty
 
@@ -535,5 +535,5 @@
 	ivec ind_H;
 	ivec ind_h0;
-	Hrv.dataind ( rv1, ind_H, ind_h0 ); // find indeces of rv in
+	Hrv.dataind ( rv1, ind_H, ind_h0 ); // find indices of rv in
 	set_subvector ( history, ind_H, hist0 ( ind_h0 ) ); // copy given hist to appropriate places
 }
Index: library/bdm/base/datasources.cpp
===================================================================
--- library/bdm/base/datasources.cpp (revision 895)
+++ library/bdm/base/datasources.cpp (revision 896)
@@ -1,55 +1,104 @@
-
 #include "datasources.h"
 
 using namespace bdm;
 
-void MemDS::getdata ( vec &dt ) const {
-	int i;
-
-	bdm_assert_debug ( dt.length() == rowid.length(), "MemDS:getdata incompatible dt" );
-	for ( i = 0; i < rowid.length(); i++ ) {
-		dt ( i ) = Data ( rowid ( i ), time );
-	}
+MemDS::MemDS ( mat &Dat ) : Data( Dat ) {
 }
 
-void MemDS::getdata ( vec &dt, const ivec &indeces ) {
-	int j, i;
-	bdm_assert_debug ( dt.length() == indeces.length(), "MemDS:getdata incompatible dt" );
-	for ( i = 0; i < indeces.length(); i++ ) {
-		j = indeces ( i );
-		dt ( i ) = Data ( rowid ( j ), time );
-	}
-}
-
-void MemDS::step() {
-	if ( time < Data.cols() ) {
+void MemDS::step( ) {
+	if ( time < max_length() ) {
 		time++;
 	}
 }
 
-void MemDS::set_drv ( const RV &drv, const RV &urv ) {
-	bdm_assert_debug ( drv._dsize() == rowid.length(), "MemDS::set_rvs incompatible drv" );
-	bdm_assert_debug ( urv._dsize() == 0, "MemDS does not support urv." );
-
-	DS::set_drv ( drv, urv );
+void MemDS::getdata ( vec &dt ) const {
+	bdm_assert_debug ( dt.length() == Data.rows(), "MemDS:getdata incompatible dt" );
+	dt = Data.get_col ( time );
 }
 
-MemDS::MemDS ( mat &Dat, ivec &rowid0 ) : rowid ( rowid0 ) {
-	bdm_assert_debug ( max ( rowid ) <= Dat.rows(), "MemDS rowid is too high for given Dat." );
+void MemDS::getdata ( vec &dt, const ivec &indices ) {
+	bdm_assert_debug ( dt.length() == indices.length(), "MemDS:getdata incompatible dt" );
+	vec tmp = Data.get_col ( time );
+	dt = tmp ( indices );
+}
+
+void MemDS::set_drv ( const RV &drv ) {
+	bdm_assert_debug ( drv._dsize() == Data.rows(), "MemDS::set_rvs incompatible drv" );
+	DS::set_drv ( drv, RV() );
+}
+
+void MemDS::from_setting ( const Setting &set ) {
+	DS::from_setting ( set );
+
+	UI::get ( Data, set, "Data", UI::compulsory );
+	
+	if ( !UI::get ( time, set, "time", UI::optional ) ) {
+		time = 0;
+	}
+	
+	shared_ptr<RV> r = UI::build<RV> ( set, "drv", UI::optional );
+	if ( !r ) {
+		r = new RV();
+		for ( int i = 0; i < Data.rows(); i++ ) {
+			r->add ( RV ( "ch" + num2str ( i ), 1, 0 ) );
+		}
+	}
+	
+	set_drv ( *r );
+	dtsize = r->_dsize();
+	utsize = 0;
+}
+
+void FileDS::from_setting ( const Setting & set ) {
+	// here we do not call MemDS::from_setting intentionally as we can not load any Data matrix directly
+	DS::from_setting ( set );
+
+	string filename;
+	UI::get ( filename, set, "filename", UI::compulsory );
 
 	time = 0;
-	Data = Dat;
+
+	shared_ptr<RV> r = UI::build<RV> ( set, "drv", UI::optional );
+	if ( !r ) {
+		r = new RV();
+		for ( int i = 0; i < Data.rows(); i++ ) {
+			r->add ( RV ( "ch" + num2str ( i ), 1, 0 ) );
+		}
+	}
+	
+	set_drv ( *r );
+	dtsize = r->_dsize();
+	utsize = 0;
 }
 
-void ITppFileDS::from_setting ( const Setting &set ) {
-	shared_ptr<RV> rvtmp = UI::build<RV> ( set, "rv" , UI::compulsory );
+void CsvFileDS::from_setting ( const Setting & set ) {
+	FileDS::from_setting ( set );
 
-	it_file it ( set["filename"] );
-	it << Name ( set["varname"] );
+	vec data_line;
+	string line;
+
+	ifstream fs;
+	fs.open ( filename.c_str() );
+	if ( fs.is_open() ) {
+		while ( getline ( fs, line ) ) {
+			data_line.set ( line );
+			Data.append_row ( data_line );
+		}
+	}
+
+	string orientation;
+	if( UI::get ( orientation, set, "orientation", UI::optional ) & orientation == "BY_ROW" ) 
+		transpose ( Data, Data );
+}
+
+void ITppFileDS::from_setting ( const Setting & set ) {
+	FileDS::from_setting ( set );
+
+	string varname;
+	UI::get ( varname, set, "varname", UI::compulsory );
+
+	it_file it ( filename );
+	it << Name ( varname );
 	it >> Data;
-	time = 0;
-	//rowid and delays are ignored
-	rowid = linspace ( 0, Data.rows() - 1 );
-	set_drv ( *rvtmp, RV() );
 }
 
@@ -62,5 +111,5 @@
 }
 
-void PdfDS::getdata ( vec &dt_out ) const {
+void PdfDS::getdata ( vec & dt_out ) const {
 	bdm_assert_debug ( dt_out.length() >= dtsize, "Short output vector" );
 	dt_out.set_subvector ( 0, yt );
@@ -85,5 +134,5 @@
 }
 
-void StateDS::from_setting ( const Setting &set ) {
+void StateDS::from_setting ( const Setting & set ) {
 	IM = UI::build<pdf> ( set, "IM", UI::compulsory );
 	OM = UI::build<pdf> ( set, "OM", UI::compulsory );
