diff --git a/create-cumulusvx-image/create-cumulus-vx-image.sh b/create-cumulusvx-image/create-cumulus-vx-image.sh
index 7157f45b70daa2e3d3348eb97882aa06ae3a5f5a..0abefdf8a9f9c97ef144fbb2d136df642d6012d2 100644
--- a/create-cumulusvx-image/create-cumulus-vx-image.sh
+++ b/create-cumulusvx-image/create-cumulus-vx-image.sh
@@ -9,6 +9,8 @@
 # V0.3.1   added support for newer glance releases (e.g. kilo) used in VIRL 1.0.0
 # V0.4     fixed check for existing images, added support for Cumulus VX 3.x
 # V0.41    removed debug bash
+# V0.5     fixed detection of missing loop files for Ubuntu 16.04 in VIRL >=1.3, added default subtype creation
+# V0.51    changed position of grub.cfg in cumulusvx >= 3.x (thanks to bobskye)
 
 
 # usage
@@ -97,6 +99,19 @@ elif [ $CUMULUS_VERSION == 3 ]; then
   LOOPDEV_PART_ROOT=$(echo "$LOOPDEV" | sed '4q;d' | cut -d " " -f 3)
 fi
 
+echo -n "waiting for loop devs from kpartx"
+LOOP_DEV_RETRIES=0
+until dd if=/dev/mapper/$LOOPDEV_PART_BOOT of=/dev/null bs=1k count=1 &>/dev/null && dd if=/dev/mapper/$LOOPDEV_PART_ROOT of=/dev/null bs=1k count=1 &>/dev/null ; do
+  echo -n "."
+  LOOP_DEV_RETRIES=$(expr $LOOP_DEV_RETRIES + 1)
+  if [ $LOOP_DEV_RETRIES -eq 10 ]; then
+    echo
+    echo "ERROR: timeout waiting for loop devs from kaprtx"
+    exit
+  fi
+  sleep 1
+done
+echo
 mkdir cumulusvx-boot-$TIMESTAMP
 mkdir cumulusvx-root-$TIMESTAMP
 
@@ -114,7 +129,7 @@ if [ $CUMULUS_VERSION == 2 ]; then
   sed -i.bak -e s/"# S0:3:respawn:\/sbin\/getty -L \$(get-cmdline-console) vt100"/"S0:3:respawn:\/sbin\/getty -L \$(get-cmdline-console) vt100"/g cumulusvx-root-$TIMESTAMP/etc/inittab
 elif [ $CUMULUS_VERSION == 3 ]; then
   # changing grub to show boot log
-  sed -i.bak -e s/"console=tty0 quiet"/"console=tty0"/g cumulusvx-boot-$TIMESTAMP/grub/grub.cfg
+  sed -i.bak -e s/"${extra_cmdline} quiet"/"${extra_cmdline}"/g cumulusvx-root-$TIMESTAMP/boot/grub/grub.cfg
 fi
 
 # append a script to import the configuration defined in VM Maestro to rc.local
@@ -136,14 +151,34 @@ safe_unmount cumulusvx-root-$TIMESTAMP
 
 rm -rf cumulusvx-boot-$TIMESTAMP
 rm -rf cumulusvx-root-$TIMESTAMP
-kpartx -d $CUMULUS_QCOW2_BASENAME.raw
+LOOP_DEV_DEL_RETRIES=0
+echo "removing loop devs from kpartx"
+until kpartx -vd $CUMULUS_QCOW2_BASENAME.raw ; do
+  echo -n "."
+  LOOP_DEV_DEL_RETRIES=$(expr $LOOP_DEV_DEL_RETRIES + 1)
+  if [ $LOOP_DEV_DEL_RETRIES -eq 10 ]; then
+    echo
+    echo "ERROR: timeout waiting for loop dev removal from kaprtx"
+    exit
+  fi
+  sleep 1
+done
 
 echo
-echo "Saving CumulusVX image..."
+echo "Converting new image to qcow2..."
 echo "==========================================================="
 
 qemu-img convert -O qcow2 $CUMULUS_QCOW2_BASENAME.raw $CUMULUS_PATCHED_QCOW2
 
+echo
+echo "Cleaning up..."
+echo "==========================================================="
+
+rm $CUMULUS_QCOW2_BASENAME.raw
+
+echo
+echo "Importing image into glance..."
+echo "==========================================================="
 # use e1000 for now as with virtio we get dhcp errors due to "bad udp checksum" in Debian
 glance image-create --container-format bare --disk-format qcow2 --visibility public --name $GLANCE_IMAGE_NAME \
   --file $CUMULUS_PATCHED_QCOW2 --property hw_disk_bus=ide --property serial=1 \
@@ -157,9 +192,82 @@ if [ $? == 1 ]; then
 
   nova flavor-create --is-public true CumulusVX.small auto 256 0 1
 fi
-      
+
+# create default subtype
+cat << EOF > dynamic-subtype-$GLANCE_IMAGE_NAME.json.default.virl-above-1.3
+{
+  "dynamic-subtypes": [
+    {
+      "plugin_base": "generic",
+      "device_type": "switch",
+      "plugin_desc": "CumulusVX",
+      "cli_protocol": "ssh",
+      "plugin_name": "$GLANCE_IMAGE_NAME",
+      "cli_serial": 1,
+      "interface_range": 25,
+      "gui_visible": true,
+      "interface_pattern": "swp{0}",
+      "baseline_image": "$GLANCE_IMAGE_NAME",
+      "config_disk_type": "disk",
+      "hw_vm_extra": "",
+      "gui_icon": "iosvl2",
+      "config_file": "/cumulusvx.sh",
+      "interface_first": 1,
+      "deprecated_use": "",
+      "baseline_flavor": "$GLANCE_IMAGE_NAME.small",
+      "interface_management": "eth0"
+    }
+  ]
+}
+EOF
+cat << EOF > dynamic-subtype-$GLANCE_IMAGE_NAME.json.default.virl-below-1.3
+{
+  "dynamic-subtypes": [
+    {
+      "plugin_base": "generic",
+      "plugin_desc": "CumulusVX",
+      "cli_protocol": "ssh", 
+      "plugin_name": "$GLANCE_IMAGE_NAME",
+      "cli_serial": 1,
+      "interface_range": 25,
+      "gui_visible": true,
+      "interface_pattern": "swp{0}",
+      "baseline_image": "$GLANCE_IMAGE_NAME",
+      "config_disk_type": "disk",
+      "hw_vm_extra": "",
+      "gui_icon": "iosvl2", 
+      "config_file": "/cumulusvx.sh",
+      "interface_first": 1, 
+      "deprecated_use": "",
+      "baseline_flavor": "$GLANCE_IMAGE_NAME.small",
+      "interface_management": "eth0"
+    }
+  ]
+}
+EOF
+CHECKING_FOR_EXISTING_SUBTYPE=$(virl_uwm_client subtype-info --name $GLANCE_IMAGE_NAME 2>&1)
+if [ $? == 255 ]; then
+  echo "Creating default subtype $GLANCE_IMAGE_NAME..."
+  echo "==========================================================="
+
+  CHECKING_FOR_EXISTING_DEVICE_TYPE=$(virl_uwm_client subtype-info 2>&1 | grep u\'device_type\':)
+  if [ $? == 1 ]; then
+    # device_type attribute is not available in VIRL < 1.3, use JSON definition of subtype without this attribute
+    echo "detected VIRL version < 1.3, selecting appropriate subtype to import"
+    virl_uwm_client subtype-import --dynamic-subtypes @dynamic-subtype-$GLANCE_IMAGE_NAME.json.default.virl-below-1.3
+  else
+    echo "detected VIRL version > 1.3.0, selecting appropriate subtype to import"
+    # device_type attribute is available, use JSON definition of subtype including this attribute
+    virl_uwm_client subtype-import --dynamic-subtypes @dynamic-subtype-$GLANCE_IMAGE_NAME.json.default.virl-above-1.3
+  fi
+else
+  echo "Default subtype $GLANCE_IMAGE_NAME already exists..."
+fi
+rm dynamic-subtype-$GLANCE_IMAGE_NAME.json.default.virl-above-1.3
+rm dynamic-subtype-$GLANCE_IMAGE_NAME.json.default.virl-below-1.3
+
 echo
-echo "Cleaning up..."
+echo "Image creation successful."
 echo "==========================================================="
-
-rm $CUMULUS_QCOW2_BASENAME.raw
+echo
+echo "You can import and use the subtype $GLANCE_IMAGE_NAME in VM Maestro..."
diff --git a/create-cumulusvx-image/dynamic-subtype-CumulusVX-VIRL-Version-1.2.x.json b/create-cumulusvx-image/dynamic-subtype-CumulusVX-VIRL-Version-1.2.x.json
new file mode 100644
index 0000000000000000000000000000000000000000..b6bc23c5ae13e239e31985c94cd4165604313f4b
--- /dev/null
+++ b/create-cumulusvx-image/dynamic-subtype-CumulusVX-VIRL-Version-1.2.x.json
@@ -0,0 +1,23 @@
+{
+  "dynamic-subtypes": [
+    {
+      "plugin_base": "generic",
+      "plugin_desc": "CumulusVX",
+      "cli_protocol": "ssh",
+      "plugin_name": "CumulusVX",
+      "cli_serial": 1,
+      "interface_range": 25,
+      "gui_visible": true,
+      "interface_pattern": "swp{0}",
+      "baseline_image": "CumulusVX",
+      "config_disk_type": "disk",
+      "hw_vm_extra": "",
+      "gui_icon": "iosvl2",
+      "config_file": "/cumulusvx.sh",
+      "interface_first": 1,
+      "deprecated_use": "",
+      "baseline_flavor": "CumulusVX.small",
+      "interface_management": "eth0"
+    }
+  ]
+}
diff --git a/create-cumulusvx-image/dynamic-subtype-CumulusVX-VIRL-Version-1.3.x.json b/create-cumulusvx-image/dynamic-subtype-CumulusVX-VIRL-Version-1.3.x.json
new file mode 100644
index 0000000000000000000000000000000000000000..b3feb1d6335c150a36ac7b46fe349ed71c485bb4
--- /dev/null
+++ b/create-cumulusvx-image/dynamic-subtype-CumulusVX-VIRL-Version-1.3.x.json
@@ -0,0 +1,24 @@
+{
+  "dynamic-subtypes": [
+    {
+      "plugin_base": "generic",
+      "device_type": "switch",
+      "plugin_desc": "CumulusVX",
+      "cli_protocol": "ssh",
+      "plugin_name": "CumulusVX",
+      "cli_serial": 1,
+      "interface_range": 25,
+      "gui_visible": true,
+      "interface_pattern": "swp{0}",
+      "baseline_image": "CumulusVX",
+      "config_disk_type": "disk",
+      "hw_vm_extra": "",
+      "gui_icon": "iosvl2",
+      "config_file": "/cumulusvx.sh",
+      "interface_first": 1,
+      "deprecated_use": "",
+      "baseline_flavor": "CumulusVX.small",
+      "interface_management": "eth0"
+    }
+  ]
+}
diff --git a/create-cumulusvx-image/dynamic-subtype-CumulusVX.json b/create-cumulusvx-image/dynamic-subtype-CumulusVX.json
deleted file mode 100644
index 86087d69056b5fb93ee738babf6e4374f705d421..0000000000000000000000000000000000000000
--- a/create-cumulusvx-image/dynamic-subtype-CumulusVX.json
+++ /dev/null
@@ -1,23 +0,0 @@
-{
-  "dynamic-subtypes": [
-    {
-      "cli_protocol": "ssh", 
-      "gui_icon": "iosvl2", 
-      "plugin_desc": "CumulusVX", 
-      "interface_first": 1, 
-      "baseline_flavor": "CumulusVX.small", 
-      "plugin_base": "generic", 
-      "interface_management": "eth0", 
-      "interface_pattern": "swp{0}", 
-      "config_file": "/cumulusvx.sh", 
-      "deprecated_use": "", 
-      "hw_vm_extra": "", 
-      "cli_serial": 1, 
-      "interface_range": 25, 
-      "config_disk_type": "disk", 
-      "plugin_name": "CumulusVX", 
-      "gui_visible": true, 
-      "baseline_image": "CumulusVX"
-    }
-  ]
-}
\ No newline at end of file