Index: library/bdm/base/user_info.h
===================================================================
--- library/bdm/base/user_info.h (revision 870)
+++ library/bdm/base/user_info.h (revision 907)
@@ -304,23 +304,6 @@
 	//! This method converts a Setting into a real scalar	
 	static void from_setting ( double &real, const Setting &element );
-
-	//! This method converts a Setting into a specific log_level_template<T> variant and initialize options properly
-	template< class T> static void from_setting ( log_level_template<T> &log_level, const Setting &element )
-	{
-		string raw_log_level;
-		UI::get( raw_log_level, element );
-		Array<string> loaded_log_level = log_level_template<T>::string2Array( raw_log_level );
-		
-		log_level.values.reset();
-
-		for( int i = 0; i < loaded_log_level.length(); i++ )
-			for( int j = 0; j < log_level.names().length(); j++ ){
-				if( loaded_log_level(i) == log_level.names()(j)  ) 
-				{
-					log_level.values[j] = true;
-					break;
-				} 
-			}
-	}
+	//! This method converts a Setting into a log_level variant and initialize options properly
+	static void from_setting ( log_level_base &log_level, const Setting &element );
 
 	//! This method converts a Setting into a class T descendant
@@ -374,7 +357,7 @@
 
 	//! This method converts a Setting into a descendant of class
-	//! T, wrapped in an instance of shared_ptr<T> .
+	//! T, wrapped in an instance of bdm::shared_ptr<T> .
 	template<class T>
-	static void from_setting ( shared_ptr<T> &instance, const Setting &element ) {
+	static void from_setting ( bdm::shared_ptr<T> &instance, const Setting &element ) {
 		T *tmp_inst = 0;
 		from_setting ( tmp_inst, element );
@@ -398,13 +381,12 @@
 	}
 
-
 	//! This is dummy version of the from_setting method for other, unsupported types. It just throws an exception.
 	//!
 	//! At the moment, this is the only way how to compile the library without obtaining the compiler error c2665.
 	//! The exception can help to find the place where the template is misused and also to correct it.
-	template<class T> static void from_setting ( T &variable_to_load, const Setting &element ) {
-		std::string msg = "UIException: from_setting is not implemented for type ";
+//	template<class T> static void from_setting ( T &variable_to_load, const Setting &element ) {
+//		std::string msg = "UIException: from_setting is not implemented for type ";
 //		try{
-			variable_to_load.from_setting(element);
+//			variable_to_load.from_setting(element);
 /*		} catch (...){
 		msg += typeid ( T ).name();
@@ -412,5 +394,5 @@
 		throw UISettingException ( msg, element );
 		}*/
-	}
+//	}
 
 
@@ -432,15 +414,15 @@
 	//! The new instance of type T* is constructed and initialized with values stored in the Setting element[name]
 	//!
-	//! If there is not any sub-element named #name and settingPresence is #optional, an empty shared_ptr<T> is returned. When settingPresence is #compulsory, the returned shared_ptr<T> is never empty (an exception is thrown when the object isn't found).
+	//! If there is not any sub-element named #name and settingPresence is #optional, an empty bdm::shared_ptr<T> is returned. When settingPresence is #compulsory, the returned bdm::shared_ptr<T> is never empty (an exception is thrown when the object isn't found).
 	template<class T>
-	static shared_ptr<T> build ( const Setting &element, const string &name, SettingPresence settingPresence = optional ) {
+	static bdm::shared_ptr<T> build ( const Setting &element, const string &name, SettingPresence settingPresence = optional ) {
 		if ( !element.exists ( name ) ) {
 			if ( settingPresence == optional )
-				return shared_ptr<T>();
+				return bdm::shared_ptr<T>();
 			else
 				throw UISettingException ( "UIException: the compulsory Setting named \"" + name + "\" is missing.", element );
 		}
 
-		shared_ptr<T> instance;
+		bdm::shared_ptr<T> instance;
 		from_setting<T> ( instance, to_child_setting ( element, name ) );
 		return instance;
@@ -449,10 +431,10 @@
 	//! The new instance of type T* is constructed and initialized with values stored in the Setting element[index]
 	//!
-	//! If there is not any sub-element indexed by #index, and settingPresence is #optional, an empty shared_ptr<T> is returned. When settingPresence is #compulsory, the returned shared_ptr<T> is never empty (an exception is thrown when the object isn't found).
+	//! If there is not any sub-element indexed by #index, and settingPresence is #optional, an empty bdm::shared_ptr<T> is returned. When settingPresence is #compulsory, the returned bdm::shared_ptr<T> is never empty (an exception is thrown when the object isn't found).
 	template<class T>
-	static shared_ptr<T> build ( const Setting &element, const int index, SettingPresence settingPresence = optional ) {
+	static bdm::shared_ptr<T> build ( const Setting &element, const int index, SettingPresence settingPresence = optional ) {
 		if ( element.getLength() <= index ) {
 			if ( settingPresence == optional )
-				return shared_ptr<T>();
+				return bdm::shared_ptr<T>();
 			else {
 				stringstream stream;
@@ -462,5 +444,5 @@
 		}
 
-		shared_ptr<T> instance;
+		bdm::shared_ptr<T> instance;
 		from_setting<T> ( instance, to_child_setting ( element, index ) );
 		return instance;
@@ -471,6 +453,6 @@
 //! Handy in mex files. Use with care.
 	template<class T>
-	static shared_ptr<T> build ( const Setting &element, SettingPresence settingPresence = optional ) {
-		shared_ptr<T> instance;
+	static bdm::shared_ptr<T> build ( const Setting &element, SettingPresence settingPresence = optional ) {
+		bdm::shared_ptr<T> instance;
 		from_setting<T> ( instance,  element );
 		return instance;
@@ -545,5 +527,5 @@
 		if ( element.getLength() <= index ) {
 			if ( settingPresence == optional )
-				return shared_ptr<T>();
+				return bdm::shared_ptr<T>();
 			else {
 				stringstream stream;
@@ -590,5 +572,5 @@
 	}
 
-	template< class T> static void save ( const shared_ptr<T> &instance, Setting &element, const string &name = "" ) {
+	template< class T> static void save ( const bdm::shared_ptr<T> &instance, Setting &element, const string &name = "" ) {
 		save<T> ( instance.get(), element, name );
 	}
@@ -603,5 +585,23 @@
 	}
 
-	// The only difference from classical UserInfo approach to log_level_template is the fact
+	//! A matrix(of type mat) is stored in the new child Setting appended to the passed element
+	static void save ( const mat &matrix, Setting &element, const string &name = "" );
+
+	//! An integer vector (of type ivec) is stored in the new child Setting appended to the passed element
+	static void save ( const ivec &vec, Setting &element, const string &name = "" );
+
+	//! A double vector (of type vec) is stored in the new child Setting appended to the passed element
+	static void save ( const vec &vector, Setting &element, const string &name = "" );
+
+	//! A string is stored in the new child Setting appended to the passed element
+	static void save ( const string &str, Setting &element, const string &name = "" );
+
+	//! An integer is stored in the new child Setting appended to the passed element
+	static void save ( const int &integer, Setting &element, const string &name = "" );
+
+	//! A double is stored in the new child Setting appended to the passed element
+	static void save ( const double &real, Setting &element, const string &name = "" );
+
+// The only difference from classical UserInfo approach to log_level_template is the fact
 	// that the actual UI element related to log_level_template could possibly exists yet. In this case, 
 	// we do not want to throw an exception like in the case of any other type being loaded
@@ -609,48 +609,6 @@
 	// possible that more instances of log_level_template class (templated with different classes)
 	// can be stored in only one line in a configuration file
-	template< class T> static void save ( const log_level_template<T> &log_level, Setting &element, const string &name = "log_level"  ) {
-		assert_type ( element, Setting::TypeGroup );
-
-		string string_to_write;
-
-		Setting *list;
-		if( element.exists( name ) ) 
-		{
-			list = &element[name];
-			assert_type ( *list, Setting::TypeString );
-			string_to_write = ( const char* ) *list;
-		}
-		else
-			list = &element.add ( name, Setting::TypeString ); 
-
-		for( unsigned int i = 0; i < log_level.values.size(); i++ )
-			if( log_level.values[i] ) // a jeste zkontrolovat zda to jmeno uz neni obsazeno? 
-			{
-				if( string_to_write.length() > 0 )
-					string_to_write = string_to_write + ',';
-				string_to_write = string_to_write + log_level.names()(i);
-			}
-			
-		*list = string_to_write;
-	}
-
-
-	//! A matrix(of type mat) is stored in the new child Setting appended to the passed element
-	static void save ( const mat &matrix, Setting &element, const string &name = "" );
-
-	//! An integer vector (of type ivec) is stored in the new child Setting appended to the passed element
-	static void save ( const ivec &vec, Setting &element, const string &name = "" );
-
-	//! A double vector (of type vec) is stored in the new child Setting appended to the passed element
-	static void save ( const vec &vector, Setting &element, const string &name = "" );
-
-	//! A string is stored in the new child Setting appended to the passed element
-	static void save ( const string &str, Setting &element, const string &name = "" );
-
-	//! An integer is stored in the new child Setting appended to the passed element
-	static void save ( const int &integer, Setting &element, const string &name = "" );
-
-	//! A double is stored in the new child Setting appended to the passed element
-	static void save ( const double &real, Setting &element, const string &name = "" );
+	static void save ( const log_level_base &log_level, Setting &element, const string &name = "log_level"  );
+
 	//!@}
 
Index: library/bdm/base/bdmbase.h
===================================================================
--- library/bdm/base/bdmbase.h (revision 896)
+++ library/bdm/base/bdmbase.h (revision 907)
@@ -86,8 +86,6 @@
 	//! Internal global variable storing names of RVs
 	static Array<string> NAMES;
-
 	//! TODO
 	const static int BUFFER_STEP;
-
 	//! TODO
 	static str2int_map MAP;
@@ -141,6 +139,9 @@
 	RV() : dsize ( 0 ), len ( 0 ), ids ( 0 ), times ( 0 ) {}
 
-	//! Constructor of a single RV with given id
+	//! Constructor of a single RV 
 	RV ( string name, int sz, int tm = 0 );
+
+	//! Constructor of a single nameless RV 
+	RV ( int sz, int tm = 0 );
 
 	// compiler-generated copy constructor is used
@@ -295,4 +296,92 @@
 RV concat ( const RV &rv1, const RV &rv2 );
 
+
+//! This class stores a details that will be logged to a logger
+template<class T> class log_level_template : public log_level_base {
+	//! this is necessary to allow logger to set ids vector appropriately and also to set registered_logger
+	friend class logger; 
+
+	//! vector of log IDs - one element for each entry
+	ivec ids;
+
+	//! internal pointer to the logger to which this log_level is registered
+	//! 
+	//! it is set to NULL at the beginning
+	logger * registered_logger;
+
+public:
+	//! default constructor
+	log_level_template() {
+		registered_logger = NULL;
+		ids.set_size(  T::log_level_names().length() );
+		ids = -1;
+	}
+
+	//! This method stores a vector to the proper place in registered logger 
+	void store( const enum T::log_level_enums log_level_enum, const vec &vect ) const
+	{
+		bdm_assert_debug( registered_logger != NULL, "You have to register instance to a logger first! Use root::log_register(...) method.");
+		bdm_assert_debug( ids( log_level_enum ) >= 0, "This particular vector was not added to logger! Use logger::add_vector(...) method.");
+		registered_logger->log_vector( ids( log_level_enum ), vect );
+	}
+
+	//! This method stores a double to the proper place in registered logger 
+	void store( const enum T::log_level_enums log_level_enum, const double &dbl ) const
+	{
+		bdm_assert_debug( registered_logger != NULL, "You have to register instance to a logger first! See root::log_register(...) method.");
+		bdm_assert_debug( ids( log_level_enum ) >= 0, "This particular double was not added to logger! Use logger::add_vector(...) method.");
+		registered_logger->log_double( ids( log_level_enum ), dbl );
+	}
+
+	//! This method stores a Setting obtained by call of UI::save( data, .. ) to the proper place in registered logger 
+	template<class U> void store( const enum T::log_level_enums log_level_enum, const U data ) const
+	{			
+		bdm_assert_debug( registered_logger != NULL, "You have to register instance to a logger first! See root::log_register(...) method.");
+		bdm_assert_debug( ids( log_level_enum ) >= 0, "This particular vector was not added to logger! Use logger::add_setting(...) method.");
+		registered_logger->log_setting( ids( log_level_enum ), data);
+	}
+
+
+	//! string equivalents of the used enumerations which are filled with a help of #LOG_LEVEL macro within class T
+	const Array<string> &names() const
+	{
+		return T::log_level_names();
+	}
+
+	//! read only operator for testing  individual fields of log_level
+	//!
+	//! it is necessary to acces it with a proper enumeration type, thus this approach is type-safe
+	bool operator [] (const enum T::log_level_enums &log_level_enum ) const
+	{
+		return values[log_level_enum];
+	}
+
+	//! operator for setting an individual field of log_level 
+	//!
+	//! it is necessary to acces it with a proper enumeration type, thus this approach is type-safe
+	bitset<32>::reference operator [] (const enum T::log_level_enums &log_level_enum )
+	{
+		return values[log_level_enum];
+	}
+};
+
+/*!
+  \def LOG_LEVEL(classname,...)
+  \brief Macro for defining a log_level attribute with a specific set of enumerations related to a specific class 
+
+  This macro has to be called within a class declaration. Its argument \a classname has to correspond to that wrapping class.
+  This macro defines a log_level instance which can be modified either directly or by the means of #UI class.
+
+  One of the main purposes of this macro is to allow variability in using enumerations. By relating them to their names through
+  an array of strings, we are no more dependant on their precise ordering. What is more, we can add or remove any without harming 
+  any applications which are using this library.
+
+  \todo Write a more detailed explanation including also examples
+
+  \ref ui
+*/
+#define LOG_LEVEL(classname,...) public: enum log_level_enums { __VA_ARGS__ }; log_level_template<classname> log_level; private: friend class log_level_template<classname>; static const Array<string> &log_level_names() { static const Array<string> log_level_names = log_level_base::string2Array( #__VA_ARGS__ ); return log_level_names; }
+
+
 /*!
 @brief Class for storing results (and semi-results) of an experiment
@@ -301,4 +390,9 @@
 */
 class logger : public root {
+private:
+	//! this method removes a "log" prefix from a string, i.e., it transforms "logevidence" to "evidence"
+	//!
+	//! for other cases, it keeps string unchanged
+	static string remove_log_prefix_if_possible( string name_with_prefix );
 protected:
 	//! RVs of all logged variables.
@@ -310,8 +404,25 @@
 	//! list of Settings for specific ids
 	Array<Setting*> settings;
-public:
-	//!Default constructor
-	logger ( const string separator0 ) : entries ( 0 ), names ( 0 ), separator ( separator0 ) {}
-
+
+	//! log this instance to Setting
+	//!
+	//! this method has to be called only through \c log_level class to assure the validity of the passed id
+	template<class U> void log_setting ( int id, const U data ) {
+		UI::save(data, *settings ( id ) );
+	}
+
+	//! log this vector 
+	//!
+	//! this method has to be called only through \c log_level class to assure the validity of the passed id
+	virtual void log_vector ( int id, const vec &v ) NOT_IMPLEMENTED_VOID;
+
+	//! log this double
+	//!
+	//! this method has to be called only through \c log_level class to assure the validity of the passed id
+	virtual void log_double ( int id, const double &d ) NOT_IMPLEMENTED_VOID;
+
+	//! it is necessary to allow log_levels to call log_setting, log_vector and log_double methods
+	template<class T> friend class log_level_template;
+public:
 	//!separator of prefixes of entries
 	//!
@@ -319,19 +430,51 @@
 	const string separator;
 
-
-	//! returns an identifier which will be later needed for calling the \c logit() function
-	//! For empty RV it returns -1, this entry will be ignored by \c logit().
-	virtual int add_vector ( const RV &rv, const string &prefix, const string &name = "" );
-
-	virtual int add_setting ( const string &prefix );
-
-	//! log this vector
-	virtual void log_vector ( int id, const vec &v ) = 0;
-
-	virtual Setting & log_to_setting ( int id ) {
-		return settings ( id )->add ( Setting::TypeGroup );
-	}
-	//! log this double
-	virtual void logit ( int id, const double &d ) = 0;
+	//!Default constructor
+	logger ( const string separator ) : entries ( 0 ), names ( 0 ), separator ( separator ) {}
+
+	//!Destructor calls the finalize method
+	~logger() {
+		finalize(); 
+	}
+
+	//! sets up the ids identifier in the passed log_level instance to permit future calls of the log_level_template<T>::store(...) method
+	//!
+	//! It also sets a pointer to logger or justify it is correctly assigned from previous call to this procedure 
+	//! Entries with empty RV will be ignored 
+	template<class T> void add_vector ( log_level_template<T> &log_level, enum T::log_level_enums const log_level_enum, const RV &rv, const string &prefix )
+	{
+		if( !log_level.registered_logger )
+			log_level.registered_logger = this;
+		else
+			bdm_assert_debug ( log_level.registered_logger == this, "This log_level is already registered to another logger!");
+
+
+		if ( rv._dsize() == 0 ) 
+			return;
+		
+		int id = entries.length();
+		string adjusted_name = remove_log_prefix_if_possible( log_level.names()(log_level_enum) );
+		names = concat ( names, prefix + separator + adjusted_name ); // diff
+		entries.set_length ( id + 1, true );
+		entries ( id ) = rv;
+		log_level.ids(log_level_enum) = id; 
+	}
+
+	//! sets up the ids identifier in the passed log_level instance to permit future calls of the log_level_template<T>::store(...) method
+	//!
+	//! It also sets a pointer to logger or justify it is correctly assigned from previous call to this procedure 
+	template<class T> void add_setting ( log_level_template<T> &log_level, enum T::log_level_enums const log_level_enum,  const string &prefix ) {
+		if( !log_level.registered_logger )
+			log_level.registered_logger = this;
+		else
+			bdm_assert_debug ( log_level.registered_logger == this, "This log_level is already registered to another logger!");
+
+		Setting &root = setting_conf.getRoot(); 
+		int id = root.getLength(); //root must be group!!
+		settings.set_length ( id + 1, true );			
+		string adjusted_name = remove_log_prefix_if_possible( log_level.names()(log_level_enum) );
+		settings ( id ) = &root.add ( prefix + separator + adjusted_name, Setting::TypeList );		
+		log_level.ids(log_level_enum) = id; 
+	}
 
 	//! Shifts storage position for another time step.
@@ -339,4 +482,6 @@
 
 	//! Finalize storing information
+	//!
+	//! This method is called either directly or via destructor ~logger(), therefore it has to permit repetitive calls for the case it is called twice
 	virtual void finalize() {};
 
@@ -344,6 +489,4 @@
 	virtual void init() {};
 };
-
-
 
 //! Class representing function \f$f(x)\f$ of variable \f$x\f$ represented by \c rv
@@ -907,7 +1050,10 @@
 
 class DS : public root {
-	//! \var log_level_enums dt
+	//! \var log_level_enums logdt
 	//! TODO DOPLNIT
-	LOG_LEVEL(DS, dt);
+
+	//! \var log_level_enums logut 
+	//! TODO DOPLNIT
+	LOG_LEVEL(DS,logdt,logut);
 
 protected:
@@ -923,5 +1069,6 @@
 	//! default constructors
 	DS() : dtsize ( 0 ), utsize ( 0 ), Drv(), Urv(){
-		log_level[dt] = true;
+		log_level[logdt] = true;
+		log_level[logut] = true;
 	};
 
@@ -967,4 +1114,8 @@
 		Urv = urv;
 	}
+
+	void from_setting ( const Setting &set );
+
+	void validate();
 };
 
Index: library/bdm/base/datasources.h
===================================================================
--- library/bdm/base/datasources.h (revision 896)
+++ library/bdm/base/datasources.h (revision 907)
@@ -89,4 +89,6 @@
 	*/
 	void from_setting ( const Setting &set );
+
+	void validate();
 };
 UIREGISTER ( MemDS );
@@ -127,4 +129,5 @@
 	// TODO dodelat void to_setting( Setting &set ) const;
 
+	void validate(); 
 };
 
@@ -142,4 +145,6 @@
 public:
 	void from_setting ( const Setting & set );
+
+	void validate();
 };
 
Index: library/bdm/base/loggers.cpp
===================================================================
--- library/bdm/base/loggers.cpp (revision 899)
+++ library/bdm/base/loggers.cpp (revision 907)
@@ -167,6 +167,8 @@
 
 void dirfilelog::finalize ( ) {
-	if ( ind > 0 )
+	if ( ind > 0 && !buffers_written) {
 		write_buffers ( ind ); //assuming here that i+1 was not filled
+		buffers_written = true;
+	}
 }
 
Index: library/bdm/base/loggers.h
===================================================================
--- library/bdm/base/loggers.h (revision 899)
+++ library/bdm/base/loggers.h (revision 907)
@@ -34,10 +34,13 @@
 	//! name of  file to save results (IT file for vectors and cfg for settings)
 	string filename;
+
+	//! this flag is only to assure reentrance of the finalize() method 
+	bool file_saved;
 public:
 	//! convenience constructor
-	memlog ( int maxlen0, string fn = "" ) : logger ( "_" ), maxlen ( maxlen0 ), ind ( 0 ), vectors ( 0 ), filename ( fn ) {}
+	memlog ( int maxlen0, string fn = "" ) : logger ( "_" ), maxlen ( maxlen0 ), ind ( 0 ), vectors ( 0 ), filename ( fn ), file_saved(false) {}
 
 	//!Default constructor
-	memlog() : logger ( "_" ), maxlen ( 0 ), ind ( 0 ), vectors ( 0 ) {}
+	memlog() : logger ( "_" ), maxlen ( 0 ), ind ( 0 ), vectors ( 0 ), file_saved(false) {}
 
 	//! Initialize storage
@@ -66,9 +69,10 @@
 	//!
 	void finalize() {
-		if ( filename.length() > 0 ) {
+		if ( filename.length() > 0 && !file_saved ) {
 			itsave ( ( filename + ".it" ).c_str() );
 			if ( settings.length() > 0 ) {
 				setting_conf.writeFile ( ( filename + ".cfg" ).c_str() );
 			}
+			file_saved = true;
 		}
 
@@ -153,11 +157,14 @@
 	//! Automatically generated
 	Array<string> scalarnames;
+
+	//! this flag is only to assure reentrance of the finalize() method 
+	bool buffers_written;
 public:
 	/*!\brief Default constructor
 	@param dirname0 name of the directory in which to store the results
 	@param maxlen0 length of the memory buffers, when full the buffers will be dumped to HDD and returned to the beginning. */
-	dirfilelog ( string dirname0, int maxlen0 ) : memlog ( maxlen0 ), dirname ( dirname0 ), scalarnames ( 0 ) {}
+	dirfilelog ( string dirname0, int maxlen0 ) : memlog ( maxlen0 ), dirname ( dirname0 ), scalarnames ( 0 ), buffers_written(false) {}
 
-	dirfilelog() {}
+	dirfilelog() : buffers_written(false) {}
 
 	//! Initialize storage
Index: library/bdm/base/user_info.cpp
===================================================================
--- library/bdm/base/user_info.cpp (revision 771)
+++ library/bdm/base/user_info.cpp (revision 907)
@@ -235,4 +235,30 @@
 }
 
+void UI::save ( const log_level_base &log_level, Setting &element, const string &name ) {
+	assert_type ( element, Setting::TypeGroup );
+
+	string string_to_write;
+
+	Setting *list;
+	if( element.exists( name ) ) 
+	{
+		list = &element[name];
+		assert_type ( *list, Setting::TypeString );
+		string_to_write = ( const char* ) *list;
+	}
+	else
+		list = &element.add ( name, Setting::TypeString ); 
+
+	for( unsigned int i = 0; i < log_level.values.size(); i++ )
+		if( log_level.values[i] ) // a jeste zkontrolovat zda to jmeno uz neni obsazeno? 
+		{
+			if( string_to_write.length() > 0 )
+				string_to_write = string_to_write + ',';
+			string_to_write = string_to_write + log_level.names()(i);
+		}
+			
+	*list = string_to_write;
+}
+
 void UI::from_setting ( mat& matrix, const Setting &element ) {
 	const SettingResolver link ( element );
@@ -367,3 +393,21 @@
 }
 
+void UI::from_setting ( log_level_base &log_level, const Setting &element )
+{
+	string raw_log_level;
+	UI::get( raw_log_level, element );
+	Array<string> loaded_log_level = log_level_base::string2Array( raw_log_level );
+	
+	log_level.values.reset();
+
+	for( int i = 0; i < loaded_log_level.length(); i++ )
+		for( int j = 0; j < log_level.names().length(); j++ ){
+			if( loaded_log_level(i) == log_level.names()(j)  ) 
+			{
+				log_level.values[j] = true;
+				break;
+			} 
+		}
+}
+
 }//namespace
Index: library/bdm/base/bdmbase.cpp
===================================================================
--- library/bdm/base/bdmbase.cpp (revision 899)
+++ library/bdm/base/bdmbase.cpp (revision 907)
@@ -99,4 +99,10 @@
 }
 
+RV::RV ( int sz, int tm ) {
+	Array<string> A ( 1 );
+	A ( 0 ) = "";
+	init ( A, vec_1 ( sz ), vec_1 ( tm ) );
+}
+
 bool RV::add ( const RV &rv2 ) {
 	if ( rv2.len > 0 ) { //rv2 is nonempty
@@ -426,59 +432,35 @@
 }
 
-int logger::add_vector ( const RV &rv, const string &prefix, const string &name ) {
-	int id;
-	if ( rv._dsize() > 0 ) {
-		id = entries.length();
-		if( name.length() > 0 )	{
-			names = concat ( names, prefix + separator + name); // diff
-		} else {
-			names = concat ( names, prefix ); // diff
-		}
-		entries.set_length ( id + 1, true );
-		entries ( id ) = rv;
-	} else {
-		id = -1;
-	}
-	return id; // identifier of the last entry
-}
-
-int logger::add_setting ( const string &prefix ) {
-	Setting &root = setting_conf.getRoot();
-	int id = root.getLength(); //root must be group!!
-	if ( prefix.length() > 0 ) {
-		settings.set_length ( id + 1, true );
-		settings ( id ) = &root.add ( prefix, Setting::TypeList );
-	} else {
-		id = -1;
-	}
-	return id;
+
+string logger::remove_log_prefix_if_possible( string name_with_prefix )
+{
+	string possible_log_prefix = name_with_prefix.substr(0,3);
+	if( possible_log_prefix == "log" )
+		return name_with_prefix.substr(3,name_with_prefix.length()-3);
+	else return name_with_prefix;
 }
 
 void epdf::log_register ( logger &L, const string &prefix ) {
+	root::log_register ( L, prefix );
+
 	RV r;
 	if ( isnamed() ) {
 		r = _rv();
 	} else {
-		r = RV ( "", dimension() );
+		r = RV (  dimension() );
 	};
-	root::log_register ( L, prefix );
-
-	// log full data
+
 	if ( log_level[logfull] ) {
-		logrec->ids.set_size ( 1 );
-		logrec->ids ( 0 ) = logrec->L.add_setting ( prefix );
+		// log full data
+		registered_logger->add_setting ( log_level, logfull, prefix );
 	} else {
 		// log only
-		logrec->ids.set_size ( 3 );
-		if ( log_level[logmean] ) {
-			logrec->ids ( 0 ) = logrec->L.add_vector ( r, prefix, "mean" );
-		}
-		if ( log_level[loglbound]  ) {
-			logrec->ids ( 1 ) = logrec->L.add_vector ( r, prefix, "lb" );
-		}	
-		if ( log_level[logubound]  ) {
-			logrec->ids ( 2 ) = logrec->L.add_vector ( r, prefix, "ub" );
-		}
-	
+
+		if ( log_level[logmean] )
+			registered_logger->add_vector ( log_level, logmean, r, prefix );			
+		if ( log_level[loglbound] )
+			registered_logger->add_vector ( log_level, loglbound, r, prefix );
+		if ( log_level[logubound] )
+			registered_logger->add_vector ( log_level, logubound, r, prefix );
 	}
 }
@@ -486,8 +468,8 @@
 void epdf::log_write() const {
 	if ( log_level[logfull] ) {
-		UI::save(this,  logrec->L.log_to_setting ( logrec->ids ( 0 ) ) );
+		log_level.store( logfull, this );
 	} else {
 		if ( log_level[logmean] ) {
-			logrec->L.log_vector ( logrec->ids ( 0 ), mean() );
+			log_level.store( logmean, mean() );
 		}
 		if ( log_level[loglbound] || log_level[logubound] ) {
@@ -496,7 +478,7 @@
 				qbounds ( lb, ub );
 				if (log_level[loglbound])
-					logrec->L.log_vector ( logrec->ids ( 1 ), lb );
+					log_level.store( loglbound, lb );
 				if (log_level[logubound])
-					logrec->L.log_vector ( logrec->ids ( 2 ), ub );
+					log_level.store( logubound, ub );
 			}
 		}
@@ -543,18 +525,40 @@
 
 	root::log_register ( L, prefix );
-	//we know that
-	if ( log_level.any() ) {
-		logrec->ids.set_size ( 1 );
-		logrec->ids ( 0 ) = logrec->L.add_vector ( Drv, prefix );
-	//	logrec->ids ( 1 ) = logrec->L.add_vector ( Urv, prefix );
-	}
+
+
+	if ( log_level[logdt] )
+		registered_logger->add_vector ( log_level, logdt, Drv, prefix );	
+	if ( log_level[logut] )
+		registered_logger->add_vector ( log_level, logut, Urv, prefix );
 }
 
 void DS::log_write ( ) const {
-	if ( log_level.any() ) {
+	if( log_level[logdt] ) {
 		vec tmp ( Drv._dsize());
 		getdata ( tmp );
 		// d is first in getdata
-		logrec->L.log_vector ( logrec->ids ( 0 ), tmp );
+		log_level.store( logdt, tmp );
+	}
+	if( log_level[logut] ) { 
+		bdm_warning("We are sorry, but DS::log_write() is not able to log \"ut\" at the moment, would you be so kind and code this functionality?");
+	}
+}
+
+
+void DS::from_setting ( const Setting &set ) {
+	shared_ptr<RV> r = UI::build<RV> ( set, "drv", UI::optional );
+	if ( r ) 	
+		set_drv ( *r, RV() );
+}
+
+void DS::validate() {
+	if( !Drv._dsize() && dtsize > 0 )
+	{
+		RV *r = new RV();
+		for ( int i = 0; i < dtsize; i++ ) {
+			r->add ( RV ( "ch" + num2str ( i ), 1, 0 ) );
+		}
+		set_drv ( *r, RV() );
+		delete r;
 	}
 }
@@ -563,9 +567,7 @@
 	root::log_register ( L, prefix );
 
-	if ( log_level.any() ) {
-		logrec->ids.set_size ( 1 );
-		logrec->ids ( 0) = L.add_vector ( RV ( "", 1 ), prefix, "ll" );
-	}
-	
+	if ( log_level[logevidence] )
+		registered_logger->add_vector ( log_level, logevidence, RV ( 1 ), prefix );	
+
 	if (log_level[logbounds]){
 		prior().log_level[epdf::loglbound]=true;
@@ -580,7 +582,7 @@
 void BM::log_write ( ) const {
 	posterior().log_write();
-	if ( log_level.any() ) {
-		logrec->L.logit ( logrec->ids ( 0 ), ll );
-	}
+
+	if( log_level[logevidence] ) 
+		log_level.store( logevidence, ll );
 }
 
Index: library/bdm/base/datasources.cpp
===================================================================
--- library/bdm/base/datasources.cpp (revision 896)
+++ library/bdm/base/datasources.cpp (revision 907)
@@ -36,17 +36,13 @@
 		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();
+}
+
+void MemDS::validate()
+{
+	dtsize = Data.rows();
 	utsize = 0;
+	DS::validate();
 }
+
 
 void FileDS::from_setting ( const Setting & set ) {
@@ -58,16 +54,4 @@
 
 	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;
 }
 
@@ -92,4 +76,8 @@
 }
 
+void CsvFileDS::validate() {
+	// TODO NASTASVIT DSIZE, OKOMENTOVAT PRO VOLAM DS::VALIDATE AZ PAK
+}
+
 void ITppFileDS::from_setting ( const Setting & set ) {
 	FileDS::from_setting ( set );
@@ -101,4 +89,8 @@
 	it << Name ( varname );
 	it >> Data;
+}
+
+void ITppFileDS::validate() {
+	// TODO NASTASVIT DSIZE, OKOMENTOVAT PRO VOLAM DS::VALIDATE AZ PAK
 }
 
