diff --git a/ext/openni2/gstopenni2src.cpp b/ext/openni2/gstopenni2src.cpp
index b436e42..21a90ba 100644
--- a/ext/openni2/gstopenni2src.cpp
+++ b/ext/openni2/gstopenni2src.cpp
@@ -41,6 +41,7 @@
 #endif
 
 #include "gstopenni2src.h"
+#include <new>
 
 GST_DEBUG_CATEGORY_STATIC (openni2src_debug);
 #define GST_CAT_DEFAULT openni2src_debug
@@ -177,6 +178,13 @@ static void
 gst_openni2_src_init (GstOpenni2Src * ni2src)
 {
   gst_base_src_set_format (GST_BASE_SRC (ni2src), GST_FORMAT_TIME);
+  new((void*)&ni2src->device) openni::Device();
+  new((void*)&ni2src->depth) openni::VideoStream();
+  new((void*)&ni2src->color) openni::VideoStream();
+  new((void*)&ni2src->depthVideoMode) openni::VideoMode();
+  new((void*)&ni2src->colorVideoMode) openni::VideoMode();
+  new((void*)&ni2src->depthFrame) openni::VideoFrameRef();
+  new((void*)&ni2src->colorFrame) openni::VideoFrameRef();
 }
 
 static void
@@ -328,6 +336,11 @@ gst_openni2_src_get_caps (GstBaseSrc * src, GstCaps * filter)
   }
   // If we are here, we need to compose the caps and return them.
 
+  // if we don't have a device URI (any device), we haven't initialized the device
+  if (!ni2src->uri_name) {
+      openni2_initialise_devices (ni2src);
+  }
+
   if (ni2src->depth.isValid () && ni2src->color.isValid () &&
       ni2src->sourcetype == SOURCETYPE_BOTH
       && ni2src->colorpixfmt == openni::PIXEL_FORMAT_RGB888) {
@@ -338,6 +351,7 @@ gst_openni2_src_get_caps (GstBaseSrc * src, GstCaps * filter)
       && ni2src->colorpixfmt == openni::PIXEL_FORMAT_RGB888) {
     format = GST_VIDEO_FORMAT_RGB;
   } else {
+    GST_OBJECT_UNLOCK (ni2src);
     return gst_caps_new_empty ();
   }
 
@@ -350,6 +364,7 @@ gst_openni2_src_get_caps (GstBaseSrc * src, GstCaps * filter)
   GST_INFO_OBJECT (ni2src, "probed caps: %" GST_PTR_FORMAT, caps);
   ni2src->gst_caps = caps;
   GST_OBJECT_UNLOCK (ni2src);
+
   return (filter)
       ? gst_caps_intersect_full (filter, ni2src->gst_caps,
       GST_CAPS_INTERSECT_FIRST)
@@ -376,10 +391,6 @@ gst_openni2_src_change_state (GstElement * element, GstStateChange transition)
     case GST_STATE_CHANGE_NULL_TO_READY:
       break;
     case GST_STATE_CHANGE_READY_TO_PAUSED:
-      if (!src->uri_name) {
-        GST_ERROR_OBJECT (src, "Invalid location");
-        return ret;
-      }
       break;
     case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
       break;
@@ -478,14 +489,16 @@ static gboolean
 openni2_initialise_library (void)
 {
   openni::Status rc = openni::STATUS_OK;
+
   rc = openni::OpenNI::initialize ();
   if (rc != openni::STATUS_OK) {
     GST_ERROR ("Initialization failed: %s",
         openni::OpenNI::getExtendedError ());
     openni::OpenNI::shutdown ();
-    return GST_FLOW_ERROR;
+    return FALSE;
   }
-  return (rc == openni::STATUS_OK);
+
+  return TRUE;
 }
 
 GstFlowReturn
