diff --git a/apps/dispatcher.php b/apps/dispatcher.php
index 0a3ed9d342ffea060923a11213ecd6317a62939e..47c4685e5bc9dffceccaba920289fc64e9f187ab 100644
--- a/apps/dispatcher.php
+++ b/apps/dispatcher.php
@@ -25,8 +25,7 @@ require('client.inc.php');
 if(!defined('INCLUDE_DIR'))	Http::response(500, 'Server configuration error');
 require_once INCLUDE_DIR.'/class.dispatcher.php';
 
-$dispatcher = patterns('',
-);
+$dispatcher = new Dispatcher();
 
 Signal::send('ajax.client', $dispatcher);
 print $dispatcher->resolve($ost->get_path_info());
diff --git a/include/ajax.content.php b/include/ajax.content.php
index 463248382493cbc58fd1bc302c03ac54c2d4efab..1703ba28e4f4b7d4a91687f9e8d6c6aa7ab9725f 100644
--- a/include/ajax.content.php
+++ b/include/ajax.content.php
@@ -157,6 +157,7 @@ class ContentAjaxAPI extends AjaxController {
             Http::response(404, 'No such content');
 
         $vars = array_merge($content->getHashtable(), $_POST);
+        $errors = array();
         if (!$content->save($id, $vars, $errors)) {
             if ($errors['err'])
                 Http::response(422, $errors['err']);
diff --git a/include/ajax.users.php b/include/ajax.users.php
index 5529cf6c623e6f0c460af48f2a20d079b3bc963e..8c19ec0e7d5a8a255b75e34ab5307bc680aa7d57 100644
--- a/include/ajax.users.php
+++ b/include/ajax.users.php
@@ -309,6 +309,7 @@ class UsersAjaxAPI extends AjaxController {
                 || !($account=$user->getAccount()))
             Http::response(404, 'Unknown user account');
 
+        $info = array();
         $info['title'] = 'Organization for '.$user->getName();
         $info['action'] = '#users/'.$user->getId().'/org';
         $info['onselect'] = 'ajax.php/users/'.$user->getId().'/org';
diff --git a/include/class.client.php b/include/class.client.php
index 3ad25fa3947e6001cc3d7c0a3f73e97ff16cc1b5..e8a30dd22add91cf21afd3e40ce43555bc8da167 100644
--- a/include/class.client.php
+++ b/include/class.client.php
@@ -13,6 +13,8 @@
 
     vim: expandtab sw=4 ts=4 sts=4:
 **********************************************************************/
+require_once INCLUDE_DIR.'class.user.php';
+
 abstract class TicketUser {
 
     static private $token_regex = '/^(?P<type>\w{1})(?P<algo>\d+)x(?P<hash>.*)$/i';
@@ -307,6 +309,8 @@ class ClientAccount extends UserAccount {
     }
 
     function update($vars, &$errors) {
+        global $cfg;
+
         $rtoken = $_SESSION['_client']['reset-token'];
         if ($vars['passwd1'] || $vars['passwd2'] || $vars['cpasswd'] || $rtoken) {
 
diff --git a/include/class.orm.php b/include/class.orm.php
index ce8edcf2a553092ed7f45c83559e090346862df5..2817c66dcfca74c3f194a03c34afe84a3156b47b 100644
--- a/include/class.orm.php
+++ b/include/class.orm.php
@@ -828,7 +828,7 @@ class MySqlCompiler extends SqlCompiler {
             return (string)$q;
         }
         elseif ($what instanceof SqlFunction) {
-            return $val->toSql($this);
+            return $what->toSql($this);
         }
         else {
             $this->params[] = $what;
diff --git a/include/class.staff.php b/include/class.staff.php
index 2c60d98d09b054644717e67bbf93a1581cbf0aec..fac31e542e8f85a65fe35314033b0b589c2e6247 100644
--- a/include/class.staff.php
+++ b/include/class.staff.php
@@ -789,7 +789,7 @@ class Staff extends AuthenticatedUser {
         $_config = new Config('pwreset');
         $_config->set($vars['token'], $this->getId());
 
-        $email->send($this->getEmail(), Format::stripTags($msg['subj']),
+        $email->send($this->getEmail(), Format::striptags($msg['subj']),
             $msg['body']);
     }
 
diff --git a/include/class.ticket.php b/include/class.ticket.php
index 4b7bf4c412c0b14bd8b951008d128e3aab125ea0..a61717b811dcbd94460edd0167e135262dbbef67 100644
--- a/include/class.ticket.php
+++ b/include/class.ticket.php
@@ -2157,7 +2157,7 @@ class Ticket {
             };
         };
 
-        $reject_ticket = function($message) use (&$errors) {
+        $reject_ticket = function($message) use (&$errors, $ost) {
             $errors = array(
                 'errno' => 403,
                 'err' => 'This help desk is for use by authorized users only');
diff --git a/scp/apps/dispatcher.php b/scp/apps/dispatcher.php
index d1cf05fd81fc6a1b8fcf11e71346338e5eb8b161..ac5ac585040ffdbc0bcbc8d9056c2cd651628e31 100644
--- a/scp/apps/dispatcher.php
+++ b/scp/apps/dispatcher.php
@@ -32,8 +32,7 @@ ini_set('display_startup_errors','0');
 if(!defined('INCLUDE_DIR'))	Http::response(500, 'Server configuration error');
 
 require_once INCLUDE_DIR.'/class.dispatcher.php';
-$dispatcher = patterns('',
-);
+$dispatcher = new Dispatcher();
 
 Signal::send('apps.scp', $dispatcher);