diff --git a/include/ajax.tickets.php b/include/ajax.tickets.php
index 6825556a98ad07028029130e195d7eaa3d7447d5..91f12f895d7945e804bbc05ac72e3837bb6f9e64 100644
--- a/include/ajax.tickets.php
+++ b/include/ajax.tickets.php
@@ -524,8 +524,7 @@ function refer($tid, $target=null) {
                           )
                       );
 
-              $impl = $field->getImpl();
-              if ($impl instanceof FileUploadField)
+              if ($field instanceof FileUploadField)
                   $field->save();
               Http::response(201, $field->getClean());
           }
diff --git a/include/class.forms.php b/include/class.forms.php
index db227a922e162abd06931d2aff6c0b6971fcc600..7e0b829199f65e40ce4b8ebb9ae53a50d1eafc3a 100644
--- a/include/class.forms.php
+++ b/include/class.forms.php
@@ -2003,6 +2003,11 @@ class DatetimeField extends FormField {
         return $this->max;
     }
 
+    function getPastPresentLabels() {
+      return array(__('Create Date'), __('Reopen Date'),
+                    __('Close Date'), __('Last Update'));
+    }
+
     function to_database($value) {
         // Store time in format given by Date Picker (DateTime::W3C)
         return $value;
@@ -2401,11 +2406,11 @@ class DatetimeField extends FormField {
             ]);
         case 'n7':
             return $query->filter([
-                "{$name}__range" => array($now, $now->minus(SqlInterval::DAY(7))),
+                "{$name}__range" => array($now, $now->plus(SqlInterval::DAY(7))),
             ]);
         case 'n30':
             return $query->filter([
-                "{$name}__range" => array($now, $now->minus(SqlInterval::DAY(30))),
+                "{$name}__range" => array($now, $now->plus(SqlInterval::DAY(30))),
             ]);
         case 'g':
             $midnight -= 86400;
@@ -4361,6 +4366,12 @@ class FileUploadWidget extends Widget {
         $maxfilesize = ($config['size'] ?: 1048576) / 1048576;
         $files = $F = array();
         $new = array_fill_keys($this->field->getClean(), 1);
+
+        //get file ids stored in session when creating tickets/tasks from thread
+        if (!$new && is_array($_SESSION[':form-data'])
+                  && array_key_exists($this->field->get('name'), $_SESSION[':form-data']))
+          $new = array_fill_keys($_SESSION[':form-data'][$this->field->get('name')], 1);
+
         foreach ($attachments as $a) {
             $F[] = $a->file;
             unset($new[$a->file_id]);
@@ -4444,6 +4455,12 @@ class FileUploadWidget extends Widget {
         if (isset($_SESSION[':uploadedFiles']))
             $allowed += $_SESSION[':uploadedFiles'];
 
+        // Files attached to threads where we are creating tasks/tickets are allowed
+        if (isset($_SESSION[':form-data'][$this->field->get('name')])) {
+          foreach ($_SESSION[':form-data'][$this->field->get('name')] as $key => $value)
+            $allowed[$value] = 1;
+        }
+
         // Canned attachments initiated by this session
         if (isset($_SESSION[':cannedFiles']))
            $allowed += $_SESSION[':cannedFiles'];
diff --git a/include/class.queue.php b/include/class.queue.php
index 950bff75c199abf8544a45df95f6ce2402d076ab..3754c1b87ef89812f810400b8abce4e694c3485f 100644
--- a/include/class.queue.php
+++ b/include/class.queue.php
@@ -441,6 +441,11 @@ class CustomQueue extends VerySimpleModel {
             ),
         ));
         $methods = $field->getSearchMethods();
+
+        //remove future options for datetime fields that can't be in the future
+        if (in_array($field->getLabel(), DateTimeField::getPastPresentLabels()))
+          unset($methods['ndays'], $methods['future'], $methods['distfut']);
+
         $pieces["{$name}+method"] = new ChoiceField(array(
             'choices' => $methods,
             'default' => key($methods),
diff --git a/include/class.thread_actions.php b/include/class.thread_actions.php
index 8cc2d785d2f2c29ab1274e4e349a9c3936e40784..9c812d618f22e63b2913bece337fedbdf44716d3 100644
--- a/include/class.thread_actions.php
+++ b/include/class.thread_actions.php
@@ -512,9 +512,11 @@ JS
                 'description' => Format::htmlchars($this->entry->getBody()));
         if (($f= TaskForm::getInstance()->getField('description'))) {
               $k = 'attach:'.$f->getId();
+              unset($_SESSION[':form-data'][$k]);
               foreach ($this->entry->getAttachments() as $a)
-                  if (!$a->inline && $a->file)
-                      $vars[$k][] = $a->file->getId();
+                  if (!$a->inline && $a->file) {
+                    $_SESSION[':form-data'][$k][] = $a->file->getId();
+                  }
         }
 
         return $this->getTicketsAPI()->addTask($this->getObjectId(), $vars);
diff --git a/include/staff/templates/queue-quickfilter.tmpl.php b/include/staff/templates/queue-quickfilter.tmpl.php
index 6b288f49484f3887ef7a2b23e67e76666c5250e3..9e4d64850a5ec3ea3e7afac9d17e179c62edd7de 100644
--- a/include/staff/templates/queue-quickfilter.tmpl.php
+++ b/include/staff/templates/queue-quickfilter.tmpl.php
@@ -15,6 +15,10 @@ if (!($qf_field = $queue->getQuickFilterField($quick_filter)))
     return;
 
 $choices = $qf_field->getQuickFilterChoices();
+
+//remove future options for datetime fields that can't be in the future
+if (in_array($qf_field->getLabel(), DatetimeField::getPastPresentLabels()))
+  unset($choices['m'], $choices['n7'], $choices['n30']);
 ?>
 <span class="action-button muted" data-dropdown="#quickfilter-dropdown">
   <i class="icon-caret-down pull-right"></i>
diff --git a/include/staff/ticket-open.inc.php b/include/staff/ticket-open.inc.php
index 2606bb736fb852d5b66329257ecf6b70231c36af..5185c11d7549f4f66e83be8456c42fb877dc22e1 100644
--- a/include/staff/ticket-open.inc.php
+++ b/include/staff/ticket-open.inc.php
@@ -15,9 +15,12 @@ if (!$user && $_GET['tid'] && ($entry = ThreadEntry::lookup($_GET['tid']))) {
 
      if (($m= TicketForm::getInstance()->getField('message'))) {
          $k = 'attach:'.$m->getId();
-        foreach ($entry->getAttachments() as $a)
-            if (!$a->inline && $a->file)
-                $_SESSION[':form-data'][$k][] = $a->file->getId();
+         unset($_SESSION[':form-data'][$k]);
+        foreach ($entry->getAttachments() as $a) {
+          if (!$a->inline && $a->file) {
+            $_SESSION[':form-data'][$k][] = $a->file->getId();
+          }
+        }
      }
 }