diff --git a/include/class.attachment.php b/include/class.attachment.php
index 15f3fd9b1dec6de619247e1158771a73434ba797..bcda6d08af5d757c01b691b78a29b28f03def623 100644
--- a/include/class.attachment.php
+++ b/include/class.attachment.php
@@ -108,15 +108,23 @@ extends InstrumentedList {
      */
     function keepOnlyFileIds($ids, $inline=false, $lang=false) {
         if (!$ids) $ids = array();
-        $new = array_fill_keys($ids, 1);
+        $new = array_flip($ids);
         foreach ($this as $A) {
             if (!isset($new[$A->file_id]) && $A->lang == $lang && $A->inline == $inline)
                 // Not in the $ids list, delete
                 $this->remove($A);
             unset($new[$A->file_id]);
         }
-        // Everything remaining in $new is truly new
-        $this->upload(array_keys($new), $inline, $lang);
+        $attachments = array();
+        // Format $new for upload() with new name
+        foreach ($new as $id=>$name) {
+            $attachments[] = array(
+                    'id' => $id,
+                    'name' => $name
+                );
+        }
+        // Everything remaining in $attachments is truly new
+        $this->upload($attachments, $inline, $lang);
     }
 
     function upload($files, $inline=false, $lang=false) {
diff --git a/include/class.filter.php b/include/class.filter.php
index 1827342284a3bab796bc1db2244dd53c527e0e0b..690a97e62f7a2ea852d69583ab5d20ebe757bf25 100644
--- a/include/class.filter.php
+++ b/include/class.filter.php
@@ -265,7 +265,7 @@ class Filter {
             'starts'    => array('stripos', 0),
             'ends'      => array('iendsWith', true),
             'match'     => array('pregMatchB', 1),
-            'not_match' => array('pregMatchB', null, 0),
+            'not_match' => array('pregMatchB', null, 1),
         );
 
         $match = false;
diff --git a/include/class.forms.php b/include/class.forms.php
index 1c5700b5278a7e1c27bdd446481e0869e9959e37..1915257b7faf6d3c38480545781f7aca7ffbe821 100644
--- a/include/class.forms.php
+++ b/include/class.forms.php
@@ -3425,10 +3425,10 @@ class FileUploadField extends FormField {
 
     function display($value) {
         $links = array();
-        foreach ($this->getFiles() as $f) {
+        foreach ($this->getAttachments() as $a) {
             $links[] = sprintf('<a class="no-pjax" href="%s">%s</a>',
-                Format::htmlchars($f->file->getDownloadUrl()),
-                Format::htmlchars($f->file->name));
+                Format::htmlchars($a->file->getDownloadUrl()),
+                Format::htmlchars($a->getFilename()));
         }
         return implode('<br/>', $links);
     }
@@ -4382,7 +4382,7 @@ class FileUploadWidget extends Widget {
             function($t) { return strpos($t, '/') !== false; }
         );
         $maxfilesize = ($config['size'] ?: 1048576) / 1048576;
-        $files = $F = array();
+        $files = array();
         $new = array_fill_keys($this->field->getClean(), 1);
 
         //get file ids stored in session when creating tickets/tasks from thread
@@ -4391,25 +4391,24 @@ class FileUploadWidget extends Widget {
           $new = array_fill_keys($_SESSION[':form-data'][$this->field->get('name')], 1);
 
         foreach ($attachments as $a) {
-            $F[] = $a->file;
             unset($new[$a->file_id]);
         }
         // Add in newly added files not yet saved (if redisplaying after an
         // error)
         if ($new) {
-            $F = array_merge($F, AttachmentFile::objects()
-                ->filter(array('id__in' => array_keys($new)))
+            $attachments = array_merge($attachments, GenericAttachment::objects()
+                ->filter(array('file_id__in' => array_keys($new)))
                 ->all()
             );
         }
 
-        foreach ($F as $file) {
+        foreach ($attachments as $att) {
             $files[] = array(
-                'id' => $file->getId(),
-                'name' => $file->getName(),
-                'type' => $file->getType(),
-                'size' => $file->getSize(),
-                'download_url' => $file->getDownloadUrl(),
+                'id' => $att->file->getId(),
+                'name' => $att->getFilename(),
+                'type' => $att->file->getType(),
+                'size' => $att->file->getSize(),
+                'download_url' => $att->file->getDownloadUrl(),
             );
         }
         ?><div id="<?php echo $id;
diff --git a/include/class.role.php b/include/class.role.php
index 0b34853220e1ea29bb2c607a646b1063c50efac9..7898bb9b67d424c3bbbb468c5a06bf44a7c24a2d 100644
--- a/include/class.role.php
+++ b/include/class.role.php
@@ -321,6 +321,16 @@ class RolePermission {
     }
 
     static function allPermissions() {
+        static $sorted = false;
+
+        if (!$sorted) {
+            // Sort permissions in alphabetical order
+            foreach (static::$_permissions as $k => $v) {
+                asort(static::$_permissions[$k]);
+            }
+            $sorted = true;
+        }
+
         return static::$_permissions;
     }
 
diff --git a/include/staff/ticket-tasks.inc.php b/include/staff/ticket-tasks.inc.php
index aa765aef5cd39eebf3f68f53f4d02227f5ca4641..ec19431ac78f1bd772377e31212e1d31be32bab0 100644
--- a/include/staff/ticket-tasks.inc.php
+++ b/include/staff/ticket-tasks.inc.php
@@ -79,9 +79,13 @@ if ($count) { ?>
         $id = $task->getId();
         $access = $task->checkStaffPerm($thisstaff);
         $assigned='';
-        if ($task->staff)
-            $assigned=sprintf('<span class="Icon staffAssigned">%s</span>',
-                    Format::truncate($task->staff->getName(),40));
+        if ($task->staff || $task->team) {
+            $assigneeType = $task->staff ? 'staff' : 'team';
+            $icon = $assigneeType == 'staff' ? 'staffAssigned' : 'teamAssigned';
+            $assigned=sprintf('<span class="Icon %s">%s</span>',
+                    $icon,
+                    Format::truncate($task->getAssigned(),40));
+        }
 
         $status = $task->isOpen() ? '<strong>open</strong>': 'closed';
 
diff --git a/scp/canned.php b/scp/canned.php
index ae8ded5fe76017b4a65b3c75929088e4110127b6..88fdf4b81360e4b49b1b7208b14e56e723652449 100644
--- a/scp/canned.php
+++ b/scp/canned.php
@@ -37,6 +37,13 @@ $canned_form = new SimpleForm(array(
    )),
 ));
 
+// Set fields' attachments so exsting files stay put
+if ($canned
+    && $canned->attachments
+    && ($attachments = $canned_form->getField('attachments'))) {
+     $attachments->setAttachments($canned->attachments);
+}
+
 if ($_POST) {
     switch(strtolower($_POST['do'])) {
         case 'update':
diff --git a/scp/faq.php b/scp/faq.php
index 310809947f82b90d7b2f4238802aecda6a8b36a4..8b948c1421ff0b51e044410ce3f9d8ba0b296cb5 100644
--- a/scp/faq.php
+++ b/scp/faq.php
@@ -48,6 +48,21 @@ if ($langs = $cfg->getSecondaryLanguages()) {
 
 $faq_form = new SimpleForm($form_fields, $_POST);
 
+// Set fields' attachments so exsting files stay put
+if ($faq
+    && $faq->getAttachments()->window(array('inline' => false))
+    && ($common_attachments = $faq_form->getField('attachments'))) {
+     // Common attachments
+     $common_attachments->setAttachments($faq->getAttachments()->window(array('inline' => false)));
+}
+if ($langs && $faq) {
+    // Multi-lingual system
+    foreach ($langs as $lang) {
+        $attachments = $faq_form->getField('attachments.'.$lang);
+        $attachments->setAttachments($faq->getAttachments($lang)->window(array('inline' => false)));
+    }
+}
+
 if ($_POST) {
     $errors=array();
     // General attachments
@@ -126,21 +141,6 @@ if ($_POST) {
 
     }
 }
-else {
-    // Not a POST — load database-backed attachments to attachment fields
-    if ($langs && $faq) {
-        // Multi-lingual system
-        foreach ($langs as $lang) {
-            $attachments = $faq_form->getField('attachments.'.$lang);
-            $attachments->setAttachments($faq->getAttachments($lang)->window(array('inline' => false)));
-        }
-    }
-    if ($faq) {
-        // Common attachments
-        $attachments = $faq_form->getField('attachments');
-        $attachments->setAttachments($faq->getAttachments()->window(array('inline' => false)));
-    }
-}
 
 $inc='faq-categories.inc.php'; //FAQs landing page.
 if($faq) {
diff --git a/setup/test/tests/test.git-conflicts.php b/setup/test/tests/test.git-conflicts.php
new file mode 100644
index 0000000000000000000000000000000000000000..5aa27bfb951a0d43d5eb8df02fcdbb31b5e05697
--- /dev/null
+++ b/setup/test/tests/test.git-conflicts.php
@@ -0,0 +1,27 @@
+<?php
+require_once "class.test.php";
+
+class GitConflicts extends Test {
+    var $name = "Git Conflicts Checks";
+
+    function testFindGitConflicts() {
+        $regex = '/^[\t ]*?<{3,} ?HEAD[\t ]*?|^[\t ]*?>{3,}[\t ]*?/m';
+        foreach ($this->getAllScripts('*') as $s) {
+            $matches = array();
+            $content = file_get_contents($s);
+            if (preg_match_all($regex,
+                    $content, $matches,
+                    PREG_OFFSET_CAPTURE) > 0) {
+                foreach ($matches[0] as $match) {
+                    $this->fail(
+                        $s,
+                        $this->line_number_for_offset($content, $match[1]),
+                        trim($match[0]));
+                }
+            }
+            else $this->pass();
+        }
+    }
+}
+return 'GitConflicts';
+?>