diff --git a/css/filedrop.css b/css/filedrop.css
index 7c11f8a2aa9768863b9b32575ef6d73426a9acfc..67512b1cfd4157c28d8ada167c2019fe3d36ed9e 100644
--- a/css/filedrop.css
+++ b/css/filedrop.css
@@ -75,6 +75,7 @@
 .tooltip-preview img {
     max-width: 300px;
     max-height: 300px;
+    z-index:11;
 }
 
 /* Bootstrap 3.2 progress-bar */
diff --git a/css/redactor.css b/css/redactor.css
index c77113360dd0a1fc068ac0cc5d00cca4d2f92474..dd2b3d91e98942c25886dcac1a63a8ac91dee951 100644
--- a/css/redactor.css
+++ b/css/redactor.css
@@ -61,7 +61,7 @@
 }
 .redactor-toolbar,
 .redactor-dropdown {
-  z-index: 5 !important;
+  z-index: 1 !important;
 }
 #redactor-modal-overlay,
 #redactor-modal-box,
diff --git a/include/class.dynamic_forms.php b/include/class.dynamic_forms.php
index 833eb318b97b581896b30744742d706a4d3bb089..8baf336e4174219c0d2cfa524d67b95c3c736805 100644
--- a/include/class.dynamic_forms.php
+++ b/include/class.dynamic_forms.php
@@ -223,23 +223,25 @@ class DynamicForm extends VerySimpleModel {
                 return false;
         }
         // New translations (?)
-        foreach ($vars['trans'] as $lang=>$parts) {
-            if (!Internationalization::isLanguageInstalled($lang))
-                continue;
-            foreach ($parts as $T => $content) {
-                $content = trim($content);
-                if (!$content)
+        if ($vars['trans'] && is_array($vars['trans'])) {
+            foreach ($vars['trans'] as $lang=>$parts) {
+                if (!Internationalization::isLanguageInstalled($lang))
                     continue;
-                $t = CustomDataTranslation::create(array(
-                    'type'      => 'phrase',
-                    'object_hash' => $tags[$T],
-                    'lang'      => $lang,
-                    'text'      => $content,
-                    'agent_id'  => $thisstaff->getId(),
-                    'updated'   => SqlFunction::NOW(),
-                ));
-                if (!$t->save())
-                    return false;
+                foreach ($parts as $T => $content) {
+                    $content = trim($content);
+                    if (!$content)
+                        continue;
+                    $t = CustomDataTranslation::create(array(
+                        'type'      => 'phrase',
+                        'object_hash' => $tags[$T],
+                        'lang'      => $lang,
+                        'text'      => $content,
+                        'agent_id'  => $thisstaff->getId(),
+                        'updated'   => SqlFunction::NOW(),
+                    ));
+                    if (!$t->save())
+                        return false;
+                }
             }
         }
         return true;
@@ -790,8 +792,6 @@ class DynamicFormEntry extends VerySimpleModel {
         'ordering' => array('sort'),
         'pk' => array('id'),
         'select_related' => array('form'),
-        'fields' => array('id', 'form_id', 'object_type', 'object_id',
-            'sort', 'extra', 'updated', 'created'),
         'joins' => array(
             'form' => array(
                 'null' => true,
diff --git a/include/class.i18n.php b/include/class.i18n.php
index 4b764717a82cdc7a51651f7f6eb3bc6f11c8d333..e0fcd9e11b9d864f66326bd9735abb244dfcd77a 100644
--- a/include/class.i18n.php
+++ b/include/class.i18n.php
@@ -382,6 +382,8 @@ class Internationalization {
     static function getCurrentLocale() {
         global $thisstaff, $cfg;
 
+        // FIXME: Move this majic elsewhere - see upgrade bug note in
+        // class.staff.php
         if ($thisstaff) {
             return $thisstaff->getLocale()
                 ?: self::getCurrentLanguage();
diff --git a/include/class.organization.php b/include/class.organization.php
index 05b23ca1230eb089dc285f8344116a454f1ca0ac..e13329507aba063361ad6cd834554f89b37f18cd 100644
--- a/include/class.organization.php
+++ b/include/class.organization.php
@@ -370,7 +370,7 @@ class Organization extends OrganizationModel {
             $org->addDynamicData($vars);
         }
 
-        Signal::send('organization.created', $user);
+        Signal::send('organization.created', $org);
         return $org;
     }
 
diff --git a/include/class.orm.php b/include/class.orm.php
index 0e0568e44a05835f8db2638872f1d1d9dd25f837..c004ab455bd3c43252cdcb42947b78aaf2c1befe 100644
--- a/include/class.orm.php
+++ b/include/class.orm.php
@@ -484,9 +484,6 @@ class AnnotatedModel {
     function __call($what, $how) {
         return call_user_func_array(array($this->model, $what), $how);
     }
-    static function __callStatic($what, $how) {
-        return call_user_func_array(array($this->model, $what), $how);
-    }
 }
 
 class SqlFunction {
@@ -1783,6 +1780,9 @@ class MySqlCompiler extends SqlCompiler {
         elseif ($what instanceof SqlFunction) {
             return $what->toSql($this);
         }
+        elseif (!isset($what)) {
+            return 'NULL';
+        }
         else {
             switch ($slot) {
             case self::SLOT_JOINS:
@@ -2076,7 +2076,7 @@ class MySqlCompiler extends SqlCompiler {
         $set = implode(', ', $set);
         list($where, $having) = $this->getWhereHavingClause($queryset);
         $joins = $this->getJoins($queryset);
-        $sql = 'UPDATE '.$this->quote($table).' SET '.$set.$joins.$where;
+        $sql = 'UPDATE '.$this->quote($table).$joins.' SET '.$set.$where;
         return new MysqlExecutor($sql, $this->params);
     }
 
diff --git a/include/class.staff.php b/include/class.staff.php
index 57e0ee30bfa10f0a2f7017d43d8a8f912dfb591d..955785bd885ec8c72b47540400968b87d56f4a0c 100644
--- a/include/class.staff.php
+++ b/include/class.staff.php
@@ -302,7 +302,9 @@ implements AuthenticatedUser, EmailContact {
     }
 
     function getLocale() {
-        return $this->locale;
+        //XXX: isset is required here to avoid possible crash when upgrading
+        // installation where locale column doesn't exist yet.
+        return isset($this->locale) ? $this->locale : 0;
     }
 
     function getRole($dept=null) {
diff --git a/include/class.thread.php b/include/class.thread.php
index de87e5819e34a00193bbdfe938c0cac084bd7133..e90fc095f92f4d718b0626beef1d60749c9ff485 100644
--- a/include/class.thread.php
+++ b/include/class.thread.php
@@ -609,7 +609,7 @@ class ThreadEntry extends VerySimpleModel {
             if(!$file['error']
                     && ($F=AttachmentFile::upload($file))
                     && $this->saveAttachment($F))
-                $uploaded[]=$id;
+                $uploaded[]= $F->getId();
             else {
                 if(!$file['error'])
                     $error = sprintf(__('Unable to upload file - %s'),$file['name']);
@@ -1099,7 +1099,8 @@ class ThreadEntry extends VerySimpleModel {
         // Inline images (attached to the draft)
         $entry->saveAttachments(Draft::getAttachmentIds($body));
 
-        Signal::send('threadentry.created', $this);
+        Signal::send('threadentry.created', $entry);
+
         return $entry;
     }
 
diff --git a/include/class.upgrader.php b/include/class.upgrader.php
index 6246e542d0b524b3dec26364297a506d9aab18ce..63fba34d852d31d41c6a970528f4fbe9d35ac722 100644
--- a/include/class.upgrader.php
+++ b/include/class.upgrader.php
@@ -348,7 +348,8 @@ class StreamUpgrader extends SetupWizard {
         if (!isset($this->task)) {
             $class = (include $task_file);
             if (!is_string($class) || !class_exists($class))
-                return $ost->logError("Bogus migration task", "{$this->phash}:{$class}") ;
+                return $ost->logError("Bogus migration task",
+                        "{$this->phash}:{$class}"); //FIXME: This can cause crash
             $this->task = new $class();
             if (isset($_SESSION['ost_upgrader']['task'][$this->phash]))
                 $this->task->wakeup($_SESSION['ost_upgrader']['task'][$this->phash]);
diff --git a/include/upgrader/streams/core/2d590ffa-9143a511.patch.sql b/include/upgrader/streams/core/2d590ffa-9143a511.patch.sql
index f52e0bb25639e765aa47b617c3726e689dce1c2c..2ef8275451131a38d2e7775b1a0d4b143d243e7e 100644
--- a/include/upgrader/streams/core/2d590ffa-9143a511.patch.sql
+++ b/include/upgrader/streams/core/2d590ffa-9143a511.patch.sql
@@ -34,8 +34,9 @@ ALTER TABLE `%TABLE_PREFIX%thread_entry`
   ADD `flags` int(11) unsigned NOT NULL default '0' AFTER `type`;
 
 -- Set the ORIGINAL_MESSAGE flag to all the first messages of each thread
-CREATE TABLE `%TABLE_PREFIX%_orig_msg_ids` AS
-SELECT min(id) AS id FROM `%TABLE_PREFIX%thread_entry`
+CREATE TABLE `%TABLE_PREFIX%_orig_msg_ids`
+  (id INT NOT NULL, PRIMARY KEY (id))
+  SELECT min(id) as id FROM `%TABLE_PREFIX%thread_entry`
   WHERE type = 'M'
   GROUP BY thread_id;
 
diff --git a/include/upgrader/streams/core/5cd0a25a-2d590ffa.task.php b/include/upgrader/streams/core/5cd0a25a-2d590ffa.task.php
index 0379bd4becece7cb4cf4688acfc891b1c08098ca..f18c0cab94359c5af4e6a2994685514b2a96f88b 100644
--- a/include/upgrader/streams/core/5cd0a25a-2d590ffa.task.php
+++ b/include/upgrader/streams/core/5cd0a25a-2d590ffa.task.php
@@ -1,6 +1,6 @@
 <?php
 
-class InstructionPorter extends MigrationTask {
+class InstructionsPorter extends MigrationTask {
     var $description = "Converting custom form instructions to HTML";
 
     function run($max_time) {
diff --git a/scp/css/scp.css b/scp/css/scp.css
index f9296da91eb1e9bf741a8cbd6e50bb44dccc8ae2..e687b82be86bc6700eb385246ce3f4118a182caa 100644
--- a/scp/css/scp.css
+++ b/scp/css/scp.css
@@ -1440,7 +1440,7 @@ time {
     bottom:0;
     left:0;
     right:0;
-    z-index:1;
+    z-index:11;
 }
 
 .redactor-editor {