Moved code to retrieve datastreams to a function which is called by plugins, so that only datastreams that are wanted are retrieved.