Moved datasource-handling parts to separate file