Index: include/libroar/plugincontainer.h
===================================================================
--- include/libroar/plugincontainer.h	(revision 5433)
+++ include/libroar/plugincontainer.h	(revision 5436)
@@ -41,7 +41,8 @@
 struct roar_plugincontainer;
 
-#if 0
+/* Create a new plugin container.
+ * Takes a default parameter set.
+ */
 struct roar_plugincontainer * roar_plugincontainer_new(struct roar_dl_librarypara * default_para);
-#endif
 
 /* Create a new plugin container.
Index: libroar/plugincontainer.c
===================================================================
--- libroar/plugincontainer.c	(revision 5432)
+++ libroar/plugincontainer.c	(revision 5436)
@@ -46,4 +46,88 @@
 };
 
+static int _loader(struct roar_dl_librarypara * lhandle, void * loader_userdata, enum roar_dl_loadercmd cmd, void * argp) {
+ roar_err_set(ROAR_ERROR_NOSYS);
+ return -1;
+}
+
+static inline void _copy_str(char ** dst, const char * src) {
+ for (; *src; src++, (*dst)++) **dst = *src;
+ *((*dst)++) = 0;
+}
+
+static void * _copy_kv(struct roar_keyval ** copy, struct roar_keyval * src, size_t len) {
+ size_t buflen, i;
+ void * ret;
+ char * p;
+ struct roar_keyval * c;
+
+ buflen = len * (sizeof(struct roar_keyval) + 2 /* terminating \0s */);
+
+ for (i = 0; i < len; i++) {
+  if ( src[i].key != NULL )
+   buflen += roar_mm_strlen(src[i].key);
+  if ( src[i].value != NULL )
+   buflen += roar_mm_strlen(src[i].value);
+ }
+
+ ret = roar_mm_malloc(buflen);
+ if ( ret == NULL )
+  return NULL;
+
+ memset(ret, 0, buflen);
+
+ c = ret;
+ p = ret + len*sizeof(struct roar_keyval);
+
+ for (i = 0; i < len; i++) {
+  if ( src[i].key == NULL ) {
+   c[i].key = NULL;
+  } else {
+   c[i].key = p;
+   _copy_str(&p, src[i].key);
+  }
+
+  if ( src[i].value == NULL ) {
+   c[i].value = NULL;
+  } else {
+   c[i].value = p;
+   _copy_str(&p, src[i].value);
+  }
+ }
+
+ *copy = c;
+ return ret;
+}
+
+static struct roar_dl_librarypara * _copy_para(struct roar_dl_librarypara * para, struct roar_plugincontainer * cont) {
+ struct roar_dl_librarypara * ret = NULL;
+ int err;
+
+ if ( para == NULL || cont == NULL ) {
+  roar_err_set(ROAR_ERROR_FAULT);
+  return NULL;
+ }
+
+ ret = roar_dl_para_new(NULL, para->binargv, para->appname, para->abiversion);
+
+ if ( para->argc && para->argv != NULL ) {
+  ret->argc       = para->argc;
+  ret->args_store = _copy_kv(&(ret->argv), para->argv, para->argc);
+  if ( ret->args_store == NULL ) {
+   err = roar_error;
+   roar_dl_para_unref(ret);
+   roar_error = err;
+   return NULL;
+  }
+ }
+
+ ret->notifycore      = para->notifycore;
+ ret->container       = cont;
+ ret->loader          = _loader;
+ ret->loader_userdata = NULL;
+
+ return ret;
+}
+
 static struct roar_plugincontainer * _new_init(void) {
  struct roar_plugincontainer * ret = roar_mm_malloc(sizeof(struct roar_plugincontainer));
@@ -58,5 +142,5 @@
 }
 
-static struct roar_plugincontainer * roar_plugincontainer_new(struct roar_dl_librarypara * default_para) {
+struct roar_plugincontainer * roar_plugincontainer_new(struct roar_dl_librarypara * default_para) {
  struct roar_plugincontainer * ret = _new_init();
  int err;
@@ -66,5 +150,6 @@
 
  if ( default_para != NULL ) {
-  if ( roar_dl_para_ref(default_para) == -1 ) {
+  ret->default_para = _copy_para(default_para, ret);
+  if ( ret->default_para == NULL ) {
    err = roar_error;
    roar_plugincontainer_unref(ret);
@@ -72,5 +157,4 @@
    return NULL;
   }
-  ret->default_para = default_para;
  }
 
@@ -158,4 +242,5 @@
  ssize_t idx = -1;
  size_t i;
+ int err;
 
  if ( cont == NULL || name == NULL ) {
@@ -164,7 +249,10 @@
  }
 
- if ( para == NULL )
+ if ( para == NULL ) {
   para = cont->default_para;
- // we do not need to _ref(para) here. This will be done by the roardl open function.
+  roar_dl_para_ref(para);
+ } else {
+  para = _copy_para(para, cont);
+ }
 
 
@@ -172,4 +260,5 @@
  if ( cont->numhandles == MAX_PLUGINS ) {
   // return early if we are full.
+  roar_dl_para_unref(para);
   roar_err_set(ROAR_ERROR_NOSPC);
   return NULL;
@@ -183,4 +272,5 @@
 
  if ( idx == -1 ) {
+  roar_dl_para_unref(para);
   roar_err_set(ROAR_ERROR_NOSPC);
   return NULL;
@@ -188,10 +278,15 @@
 
  cont->handle[idx] = roar_dl_open(name, flags, ra_init, para);
- if ( cont->handle[idx] == NULL )
-  return NULL;
+ if ( cont->handle[idx] == NULL ) {
+  err = roar_error;
+  roar_dl_para_unref(para);
+  roar_error = err;
+  return NULL;
+ }
 
  cont->deprefc[idx] = 0;
  cont->numhandles++;
 
+ roar_dl_para_unref(para);
  roar_dl_ref(cont->handle[idx]);
  return cont->handle[idx];
