diff --git a/include/class.orm.php b/include/class.orm.php
index ef3e2cea4ce1d26b986a70fbe2d3678ab778859c..7c715f43a19002507cdf9ecbbb8ba8cb64ee8836 100644
--- a/include/class.orm.php
+++ b/include/class.orm.php
@@ -42,6 +42,8 @@ class ModelMeta implements ArrayAccess {
         'defer' => array(),
         'select_related' => array(),
         'view' => false,
+        'joins' => array(),
+        'foreign_keys' => array(),
     );
     static $model_cache;
 
@@ -68,7 +70,7 @@ class ModelMeta implements ArrayAccess {
                 sprintf(__('%s: Model does not define meta.pk'), $model));
 
         // Ensure other supported fields are set and are arrays
-        foreach (array('pk', 'ordering', 'defer') as $f) {
+        foreach (array('pk', 'ordering', 'defer', 'select_related') as $f) {
             if (!isset($meta[$f]))
                 $meta[$f] = array();
             elseif (!is_array($meta[$f]))
@@ -76,8 +78,6 @@ class ModelMeta implements ArrayAccess {
         }
 
         // Break down foreign-key metadata
-        if (!isset($meta['joins']))
-            $meta['joins'] = array();
         foreach ($meta['joins'] as $field => &$j) {
             $this->processJoin($j);
             if ($j['local'])
@@ -327,7 +327,7 @@ class VerySimpleModel {
             else
                 throw new InvalidArgumentException(
                     sprintf(__('Expecting NULL or instance of %s. Got a %s instead'),
-                    $j['fkey'][0], get_class($value)));
+                    $j['fkey'][0], is_object($value) ? get_class($value) : gettype($value)));
 
             // Capture the foreign key id value
             $field = $j['local'];
@@ -2058,6 +2058,7 @@ class MySqlCompiler extends SqlCompiler {
 
     function compileCount($queryset) {
         $model = $queryset->model;
+        $model::_inspect();
         $table = $model::$meta['table'];
         list($where, $having) = $this->getWhereHavingClause($queryset);
         $joins = $this->getJoins($queryset);
diff --git a/include/class.ticket.php b/include/class.ticket.php
index c8f0d1afd8545b3e4fda99297d569461bbcb4aff..a9b2b0078a2865cc63c0d365ee046bae0758bdbc 100644
--- a/include/class.ticket.php
+++ b/include/class.ticket.php
@@ -73,7 +73,7 @@ class TicketModel extends VerySimpleModel {
                 'null' => true,
             ),
             'thread' => array(
-                'reverse' => 'Thread.ticket',
+                'reverse' => 'TicketThread.ticket',
                 'list' => false,
                 'null' => true,
             ),
@@ -220,6 +220,7 @@ implements RestrictedAccess, Threadable {
     );
 
     var $lastMsgId;
+    var $last_message;
 
     var $owner;     // TicketOwner
     var $_user;      // EndUser
@@ -3075,9 +3076,10 @@ implements RestrictedAccess, Threadable {
         $ticket = parent::create(array(
             'created' => SqlFunction::NOW(),
             'lastupdate' => SqlFunction::NOW(),
+            'number' => $number,
             'user' => $user,
-            'dept' => $deptId,
-            'topicId' => $topicId,
+            'dept_id' => $deptId,
+            'topic_id' => $topicId,
             'ip_address' => $ipaddress,
             'source' => $source,
         ));
diff --git a/setup/css/wizard.css b/setup/css/wizard.css
index a742c75cbbbf0cc2c91b72ffbabf6a99abef16a0..9d4e8b6ae79985567148c53753b782965a23a334 100644
--- a/setup/css/wizard.css
+++ b/setup/css/wizard.css
@@ -11,7 +11,7 @@ a { color: #2a67ac; display: inline-block; }
 .hidden { display: none;}
 .error { color:#f00;}
 
-#header { height: 72px; margin-bottom: 20px; width: 100%; }
+#header { min-height: 72px; margin-bottom: 20px; width: 100%; }
 #header #logo { width: 280px; height: 72px; display: block; float: left; }
 #header .info { font-size: 11pt; font-weight: bold; border-bottom: 1px solid #2a67ac; color: #444; text-align: right; float: right; }
 #header ul { margin: 0; padding: 0; text-align: right; }