diff --git a/bin/cdist b/bin/cdist
index 40b8dd5e..05eb8c00 100755
--- a/bin/cdist
+++ b/bin/cdist
@@ -514,7 +514,7 @@ class Cdist:
       env["__object"]      = self.object_dir(cdist_object)
       env["__object_id"]   = self.get_object_id_from_object(cdist_object)
       env["__object_fq"]   = cdist_object
-      env["__type"]        = self.type_dir(get_type_from_object(cdist_object))
+      env["__type"]        = self.type_dir(self.get_type_from_object(cdist_object))
 
       if mode == "gencode":
          paths = self.type_gencode_paths(self.get_type_from_object(cdist_object))
@@ -644,7 +644,7 @@ def install(args):
 
 def emulator():
    """Emulate type commands (i.e. __file and co)"""
-   process = {}
+   type = os.path.basename(sys.argv[0])
 
 def commandline():
    """Parse command line"""