diff --git a/fillpdf.admin.inc b/fillpdf.admin.inc
index 545c5d6..b708a8d 100644
--- a/fillpdf.admin.inc
+++ b/fillpdf.admin.inc
@@ -231,8 +231,19 @@ function fillpdf_form_edit($form, &$form_state, $fid) {
     '#maxlength' => 127,
     '#default_value' => $pdf_form->title,
     '#required' => TRUE,
+    '#description' => t('Enter a title for this mapping configuration.
+      This will also be used for deciding the filename of your PDF. <strong>This
+      field supports tokens.</strong>'),
   );
 
+  $form['title_tokens_fieldset'] = array(
+    '#type' => 'fieldset',
+    '#title' => 'Tokens',
+    '#collapsible' => TRUE,
+    '#collapsed' => TRUE,
+  );
+
+  $form['title_tokens_fieldset']['tokens'] = _fillpdf_admin_token_form();
   $form['default_nid'] = array(
     '#type' => 'textfield',
     '#title' => t('Default Node ID'),
@@ -309,10 +320,7 @@ function fillpdf_form_edit($form, &$form_state, $fid) {
     '#collapsible' => TRUE,
     '#collapsed' => TRUE,
   );
-  $form['extra']['tokens_fieldset']['tokens'] = array(
-    '#theme' => 'token_tree',
-    '#token_types' => array('node', 'webform'),
-  );
+  $form['extra']['tokens_fieldset']['tokens'] = _fillpdf_admin_token_form();
   $form['extra']['replacements'] = array(
     '#type' => 'textarea',
     '#title' => t('Transform filled PDF field values'),
@@ -744,3 +752,10 @@ function fillpdf_update_field(&$pdf_form, &$field, $old_key) {
   ->execute();
 }
 
+function _fillpdf_admin_token_form() {
+  return array(
+    '#theme' => 'token_tree',
+    '#token_types' => array('node', 'webform'),
+  );
+}
+
diff --git a/fillpdf.module b/fillpdf.module
index ac8990a..5207aeb 100644
--- a/fillpdf.module
+++ b/fillpdf.module
@@ -336,17 +336,15 @@ function fillpdf_merge_pdf($fid, $nids = NULL, $webform_arr = NULL, $sample = NU
       // --- node token replacements
       if (!empty($nodes)) {
         foreach ($nodes as $node) {
+          $token_objects['node'] = $node;
           // The third parameter says to clear the value if no token can be generated
           $token = token_replace($obj->value, array('node' => $node), array('clear' => TRUE));
           if ($token && $token != $obj->value) {
-            $token_objects['node'] = $node;
             break;
           }
         }
         $transform_string = TRUE;
-        // TODO: Fix *everything* here.
-        // if they're populating with an imagefield
-        //TODO: check if an image (not another pdf or some-such)_
+        // If they're populating with an Image field
         if (strstr($obj->value, '[stamp:')) {
           // HACK: Use a pseudo-token to stamp images.
 
@@ -371,9 +369,9 @@ function fillpdf_merge_pdf($fid, $nids = NULL, $webform_arr = NULL, $sample = NU
       // --- webform token replacements
       if (!empty($webforms)) {
         foreach ($webforms as $webform) {
+          $token_objects['webform'] = $webform['submission'];
           $token = token_replace($obj->value, array('webform' => $webform['submission']), array('clear' => TRUE));
           if ($token) {
-            $token_objects['webform'] = $webform['submission'];
             break;
           }
         }
@@ -398,11 +396,6 @@ function fillpdf_merge_pdf($fid, $nids = NULL, $webform_arr = NULL, $sample = NU
   );
   drupal_alter('fillpdf_merge_fields_alter', $fields, $context);
 
-  // Generate the filename of downloaded PDF from title of the PDF set in admin/structure/fillpdf/%fid
-  $output_name = str_replace(' ', '_', $fillpdf_info->title);
-  $output_name = preg_replace('/\.pdf$/i', '', $output_name);
-  $output_name = preg_replace('/[^a-zA-Z0-9_.-]+/', '', $output_name) . '.pdf';
-
   $pdf_data = _fillpdf_get_file_contents($fillpdf_info->url, "<front>");
   switch (variable_get('fillpdf_service')) {
     case 'remote': // use fillpdf-service.com's xmlrpc service (must be registered)
@@ -469,6 +462,10 @@ function fillpdf_merge_pdf($fid, $nids = NULL, $webform_arr = NULL, $sample = NU
     ));
   }
 
+  // Generate the filename of downloaded PDF from title of the PDF set in
+  // admin/structure/fillpdf/%fid
+  $output_name = _fillpdf_process_filename($fillpdf_info->title, $token_objects);
+
   if (!empty($fillpdf_info->destination_path)) {
     $destination_path = _fillpdf_process_destination_path($fillpdf_info->destination_path, $token_objects);
     $path_exists = file_prepare_directory($destination_path, FILE_CREATE_DIRECTORY);
@@ -551,6 +548,19 @@ function fillpdf_merge_pdf_access($nodes = array(), $webforms = array()) {
   return TRUE;
 }
 
+function _fillpdf_process_filename($original, $token_objects) {
+  // Replace tokens *before* sanitization
+  if (!empty($token_objects)) {
+    $original = token_replace($original, $token_objects);
+  }
+
+  $output_name = str_replace(' ', '_', $original);
+  $output_name = preg_replace('/\.pdf$/i', '', $output_name);
+  $output_name = preg_replace('/[^a-zA-Z0-9_.-]+/', '', $output_name) . '.pdf';
+
+  return $output_name;
+}
+
 /**
  * Utility function to allow other functions to merge PDFs with the various methods in a consistent way.
  * @param string $method The service or program being used. Possible values: local, remote, pdftk. Currently, only pdftk is supported.
