diff --git a/tools/mkfs/mkfs.cc b/tools/mkfs/mkfs.cc
index 3957030b802fc07c80c58fcaabff488543bc3342..d2a3b58f0d83f92d702d0215b0f7ac9f7a253e9b 100644
--- a/tools/mkfs/mkfs.cc
+++ b/tools/mkfs/mkfs.cc
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013 Cloudius Systems, Ltd.
+ * Copyright (C) 2013-2014 Cloudius Systems, Ltd.
  *
  * This work is open source software, licensed under the terms of the
  * BSD license as described in the LICENSE file in the top-level directory.
@@ -15,21 +15,32 @@
 using namespace osv;
 using namespace std;
 
+// Created to guarantee that shared objects resources will
+// be surely released at the function prologue.
+void run_cmd(const char *cmdpath, vector<string> args)
+{
+    int ret;
+    auto ok = run(cmdpath, args, &ret);
+    assert(ok && ret == 0);
+}
+
 void mkfs()
 {
-    /* Create zfs device, then /etc/mnttab which is required by libzfs */
+    // Create zfs device, then /etc/mnttab which is required by libzfs
     zfsdev::zfsdev_init();
+
+    // Manually create /etc/mnttab, a file required by libzfs.
     mkdir("/etc", 0755);
     int fd = creat("/etc/mnttab", 0644);
     assert(fd != -1);
     close(fd);
 
-    int ret;
-    auto ok = run("/zpool.so",
-            {"zpool", "create", "-f", "-R", "/zfs", "osv", "/dev/vblk0.1"}, &ret);
-    assert(ok && ret == 0);
-    ok = run("/zfs.so", {"zfs", "create", "osv/zfs"}, &ret);
-    assert(ok && ret == 0);
+    // Create zpool named osv
+    run_cmd("/zpool.so",
+        {"zpool", "create", "-f", "-R", "/zfs", "osv", "/dev/vblk0.1"});
+
+    // Create a zfs dataset within the pool named osv.
+    run_cmd("/zfs.so", {"zfs", "create", "osv/zfs"});
 }
 
 int main(int ac, char** av)