diff --git a/Frx.inc b/Frx.inc
index b86eb16..84df8d4 100755
--- a/Frx.inc
+++ b/Frx.inc
@@ -1,17 +1,22 @@
 <?php
+
 /**
- * @file Frx.incL
+ * @file
+ * Frx.incL
  * General Forena Reporting Class
  */
+
 define('FRX_TOKEN_EXP', '/\{[^\n^\r^}]+}/');
 define('FRX_SQL_REWRITE_EXP', '/\[[^\n^\r^\]]+\]/');
 define('FRX_SQL_TOKEN', '/(?<!(:|[a-zA-Z]|[0-9]|[_\.])):[a-zA-Z]([a-zA-Z]|[0-9]|[_\.])+/');
-
-
+/**
+ *
+ */
 class Frx {
 
   /**
    * Helper method to return current url parameters.
+   *
    * @return unknown
    */
   public static function parms() {
@@ -23,12 +28,13 @@ class Frx {
   /**
    * Temporary dom object used for for fragment importing and manipulation.
    * We use a singleton here to reduce the memory footprint.
+   *
    * @return DOMDocument
    */
   public static function tempDOM() {
     static $o = '';
     if (!$o) {
-      $o= new DOMDocument('1.0', 'UTF-8');
+      $o = new DOMDocument('1.0', 'UTF-8');
       @$o->load('<?xml version="1.0" encoding="UTF-8"?>
          <!DOCTYPE root [
          <!ENTITY nbsp "&#160;">
@@ -38,7 +44,8 @@ class Frx {
   }
 
   /**
-   * Skin Factory
+   * Skin Factory.
+   *
    * @return FrxSkin
    */
   public static function Skin() {
@@ -51,7 +58,7 @@ class Frx {
   }
 
   /**
-   * Data Factory
+   * Data Factory.
    */
   public static function Data() {
     static $o = '';
@@ -63,7 +70,8 @@ class Frx {
   }
 
   /**
-   * File singleton factory
+   * File singleton factory.
+   *
    * @return FrxReportFile
    */
   public static function File() {
@@ -76,7 +84,8 @@ class Frx {
   }
 
   /**
-   * File singleton factory
+   * File singleton factory.
+   *
    * @return FrxDataFile
    */
   public static function DataFile() {
@@ -89,7 +98,8 @@ class Frx {
   }
 
   /**
-   * File singleton factory
+   * File singleton factory.
+   *
    * @return FrxMenu
    */
   public static function Menu() {
@@ -103,32 +113,39 @@ class Frx {
 
   /**
    *
-   * @param  $config array of field configuration;
+   * @param  $config
+   *   array of field configuration;
    * @return FrxFields
    */
   public static function Fields($config = array()) {
-    require_once('FrxFields.inc');
+    require_once 'FrxFields.inc';
     $o = new FrxFields($config);
     return $o;
   }
+
   /**
-   *
    * Enter description here ...
+   *
    * @param unknown_type $type
+   *
    * @return FrxDocument
    */
-  public static function Document($type='web') {
+  public static function Document($type = 'web') {
 
     static $doc_types = '';
     static $objects = '';
     require_once 'FrxDocument.inc';
     // Invoke doc_type hook to see which document types are there.
-    if (!$doc_types) $doc_types = module_invoke_all('forena_document_types');
+    if (!$doc_types) {
+      $doc_types = module_invoke_all('forena_document_types');
+    }
 
-    if (!$type) $type = 'web';
+    if (!$type) {
+      $type = 'web';
+    }
     if (isset($doc_types[$type]) && class_exists(@$doc_types[$type]['class'])) {
       if (!@$doc_types[$type]['object']) {
-        $o = new $doc_types[$type]['class'];
+        $o = new $doc_types[$type]['class']();
         $o->format = $type;
         $doc_types[$type]['object'] = $o;
       }
@@ -145,6 +162,7 @@ class Frx {
 
   /**
    * Returns list of document types supported.
+   *
    * @param unknown_type $all
    */
   public static function documentTypes($all = FALSE) {
@@ -152,7 +170,9 @@ class Frx {
     static $supported_doctypes = '';
     if (!$supported_doctypes || $all) {
       $doc_types = module_invoke_all('forena_document_types');
-      if (!$all) unset($doc_types['web']);
+      if (!$all) {
+        unset($doc_types['web']);
+      }
       $supported_doctypes = array();
       foreach ($doc_types as $type => $doc) {
         $supported_doctypes[$type] = $type;
@@ -163,29 +183,33 @@ class Frx {
 
   /**
    * Retreive the classes from other modules.
+   *
    * @param string $class
+   *
    * @return Ambigous <string, unknown>
    */
-  public static function Controls($class='', $instantiate = TRUE) {
+  public static function Controls($class = '', $instantiate = TRUE) {
     static $instances = '';
     static $classes = '';
     if (!$instances) {
       $instances = array();
-      $classes=array();
+      $classes = array();
       foreach (module_list() as $module) {
         $function = $module . '_forena_controls';
         if (function_exists($function)) {
           $returned_controls = $function();
-          if ($returned_controls) foreach ((array)$returned_controls as $c) {
-            $c['module'] = $module;
-            $c['file'] = drupal_get_path('module' , $c['module']) . '/' . trim($c['file'], '/');
-            if ($c['file']) {
-              include_once($c['file'] );
-              if (class_exists($c['class']) && $instantiate) {
-                $cls = $c['class'];
-                $instances[$c['class']] =  new $cls();
+          if ($returned_controls) {
+            foreach ((array) $returned_controls as $c) {
+              $c['module'] = $module;
+              $c['file'] = drupal_get_path('module', $c['module']) . '/' . trim($c['file'], '/');
+              if ($c['file']) {
+                include_once $c['file'];
+                if (class_exists($c['class']) && $instantiate) {
+                  $cls = $c['class'];
+                  $instances[$c['class']] = new $cls();
+                }
+                $classes[$c['class']] = $c['class'];
               }
-              $classes[$c['class']] = $c['class'];
             }
           }
         }
@@ -203,21 +227,24 @@ class Frx {
 
   /**
    * Returns the FrxRendererInstances.
+   *
    * @return FrxRenderer
    */
   public static function getRendererPlugins() {
-    require_once('renderers/FrxRenderer.inc');
-    $classes = Frx::Controls('',  FALSE);
+    require_once 'renderers/FrxRenderer.inc';
+    $classes = Frx::Controls('', FALSE);
     foreach ($classes as $key => $class) {
-      if (!method_exists($class, 'render')) unset($classes[$key]);
+      if (!method_exists($class, 'render')) {
+        unset($classes[$key]);
+      }
     }
     return $classes;
   }
 
-
   /**
    * Returns an object of the template class
    * that has a method named templates.
+   *
    * @return FrxRenderer
    */
   public static function Template($class) {
@@ -227,6 +254,7 @@ class Frx {
   /**
    * Forena Repository manager
    * Class factory
+   *
    * @return FrxRepoMan
    */
   public static function RepoMan() {
@@ -240,12 +268,14 @@ class Frx {
   }
 
   /**
-   * General wrapper procedure for reporting erros
+   * General wrapper procedure for reporting erros.
    *
-   * @param string $short_message Message that will be displayed to the users
-   * @param string $log Message that will be recorded in the logs.
+   * @param string $short_message
+   *   Message that will be displayed to the users.
+   * @param string $log
+   *   Message that will be recorded in the logs.
    */
-  public static function error($short_message='', $log='') {
+  public static function error($short_message = '', $log = '') {
     if ($short_message) {
       drupal_set_message(check_markup($short_message), 'error', FALSE);
     }
@@ -257,10 +287,11 @@ class Frx {
   /**
    * Debug handler
    * Enter description here ...
+   *
    * @param unknown_type $short_message
    * @param unknown_type $log
    */
-  public static function debug($short_message='', $log='') {
+  public static function debug($short_message = '', $log = '') {
     if ($log) {
       watchdog('forena debug', $log, NULL);
     }
@@ -270,9 +301,13 @@ class Frx {
   }
 
   /**
-   * Factory for token replacement syntax engine object
-   * @param $regexp string regular expression for finding tokens
-   * @param $trim string to trim off the end of tokens.
+   * Factory for token replacement syntax engine object.
+   *
+   * @param $regexp
+   *   string regular expression for finding tokens
+   * @param $trim
+   *   string to trim off the end of tokens.
+   *
    * @return FrxSyntaxEngine
    */
   public static function SyntaxEngine($regexp, $trim) {
@@ -281,8 +316,11 @@ class Frx {
   }
 
   /**
-   * Facotry for SQL Query builder object
-   * @param $new Boolean value that forces a new object
+   * Facotry for SQL Query builder object.
+   *
+   * @param $new
+   *   Boolean value that forces a new object
+   *
    * @return FrxSQLQueryBuilder
    */
   public static function SQLQueryBuilder($new = FALSE) {
@@ -295,13 +333,15 @@ class Frx {
   }
 
   /**
-   * Factory method to return instance object
+   * Factory method to return instance object.
+   *
    * @param unknown_type $parent
    * @param unknown_type $key
+   *
    * @return object
    */
   public static function PluginInstance($parent, $key) {
-    static $objects='';
+    static $objects = '';
     $o = NULL;
     if (!$objects) {
       $objects = array();
@@ -310,7 +350,9 @@ class Frx {
     if (isset($plugins[$key])) {
       $class = @$plugins[$key]['class'];
       if (!isset($objects[$class])) {
-        if (class_exists($class)) $objects[$class] = new $class();
+        if (class_exists($class)) {
+          $objects[$class] = new $class();
+        }
       }
       $o = $objects[$class];
     }
@@ -321,13 +363,15 @@ class Frx {
   /**
    * Factory object to get the context based on a name.  IF the context doesn't
    * exist we assume the default data context (FrxData).
-   * @param $context string
+   *
+   * @param string $context
+   *
    * @return FrxContext
    */
   public static function Context($context) {
     $o = NULL;
 
-    // Instantiate the class if it exists
+    // Instantiate the class if it exists.
     if ($context) {
       $o = Frx::PluginInstance('FrxContext', $context);
     }
@@ -341,9 +385,9 @@ class Frx {
   }
 
   /**
-   * Loads all of the include files that
+   * Loads all of the include files that.
    */
-  public static function plugins( $parent = '') {
+  public static function plugins($parent = '') {
     static $plugins = '';
 
     if (!$plugins) {
@@ -352,26 +396,28 @@ class Frx {
         $function = $module . '_forena_plugins';
         if (function_exists($function)) {
           $returned_plugins = $function();
-          if ($returned_plugins) foreach ((array)$returned_plugins as $key=>$p) {
-            $p['module'] = $module;
-            if (@$p['path']) {
-              $p['file'] = rtrim($p['path'],'/') . '/' . $p['file'];
-            }
-            else {
-              $p['file'] = drupal_get_path('module' , $p['module']) . '/' . $p['file'];
-            }
-            if (is_int($key)) {
-              $plugins[]=$p;
-            }
-            else {
-              $plugins[$key] = $p;
+          if ($returned_plugins) {
+            foreach ((array) $returned_plugins as $key => $p) {
+              $p['module'] = $module;
+              if (@$p['path']) {
+                $p['file'] = rtrim($p['path'], '/') . '/' . $p['file'];
+              }
+              else {
+                $p['file'] = drupal_get_path('module', $p['module']) . '/' . $p['file'];
+              }
+              if (is_int($key)) {
+                $plugins[] = $p;
+              }
+              else {
+                $plugins[$key] = $p;
+              }
             }
           }
         }
       }
       foreach ($plugins as $p) {
-        if ($p['file'] ) {
-          include_once( trim($p['file'], '/'));
+        if ($p['file']) {
+          include_once trim($p['file'], '/');
         }
       }
     }
@@ -379,7 +425,7 @@ class Frx {
     // Return the plugins if a parent was requested.
     $ret_plugins = array();
     if ($parent) {
-      foreach($plugins as $key => $p) {
+      foreach ($plugins as $key => $p) {
         if (@$p[parent] == $parent) {
           $ret_plugins[$key] = $p;
         }
@@ -388,20 +434,21 @@ class Frx {
     return $ret_plugins;
   }
 
-
   /**
    *
    * @param  $report_name
    * @return FrxEditor <string, FrxEditor>
    */
-  static public function Editor($report_name = '', $edit=TRUE) {
-    static $o='';
-    require_once('FrxEditor.inc');
+  public static function Editor($report_name = '', $edit = TRUE) {
+    static $o = '';
+    require_once 'FrxEditor.inc';
     if (!$o || !$edit) {
       $o = new FrxEditor($report_name, $edit);
     }
     else {
-      if ($report_name) $o->load($report_name, $edit) ;
+      if ($report_name) {
+        $o->load($report_name, $edit);
+      }
     }
     return $o;
   }
@@ -411,26 +458,28 @@ class Frx {
    * @param $block_name
    * @return FrxBlockEditor
    */
-  static public function BlockEditor($block_name = '', $edit=TRUE) {
-    static $o='';
-    require_once('FrxBlockEditor.inc');
+  public static function BlockEditor($block_name = '', $edit = TRUE) {
+    static $o = '';
+    require_once 'FrxBlockEditor.inc';
     if (!$o) {
       $o = new FrxBlockEditor($block_name, $edit);
     }
     else {
-      if ($block_name) $o->load($block_name, $edit);
+      if ($block_name) {
+        $o->load($block_name, $edit);
+      }
     }
     return $o;
   }
 
   /**
    * @param $command
-   *   The string name representing the command to invoke. 
-   * @return string 
+   *   The string name representing the command to invoke.
+   * @return string
    *   Class name of ajax command
    */
-  static public function getAjaxPlugin($command) {
-    
+  public static function getAjaxPlugin($command) {
+
     $commands = array(
       'add_css' => 'AddCss',
       'after' => 'After',
@@ -446,23 +495,28 @@ class Frx {
       'remove' => 'Remove',
       'replace' => 'Replace',
       'restripe' => 'Restripe',
-      'settings' => 'Settings'
-    ); 
-    require_once('AjaxCommand/AjaxCommandInterface.php');
-    require_once ('AjaxCommand/AjaxCommandBase.php');
+      'settings' => 'Settings',
+    );
+    require_once 'AjaxCommand/AjaxCommandInterface.php';
+    require_once 'AjaxCommand/AjaxCommandBase.php';
     $class = '';
     if (isset($commands[$command])) {
-      $class = $commands[$command]; 
-      require_once("AjaxCommand/$class.php" ); 
+      $class = $commands[$command];
+      require_once "AjaxCommand/$class.php";
       $class = "\\Drupal\\forena\\FrxPlugin\\AjaxCommand\\$class";
     }
-    return $class; 
+    return $class;
   }
 
-  static public function getContextPlugins() {
+  /**
+   *
+   */
+  public static function getContextPlugins() {
     static $plugins = '';
-    require_once('contexts/FrxContextBase.inc');
-    if (!$plugins) $plugins = module_invoke_all('forena_context');
+    require_once 'contexts/FrxContextBase.inc';
+    if (!$plugins) {
+      $plugins = module_invoke_all('forena_context');
+    }
     return $plugins;
   }
 
diff --git a/plugins/FrxMSSQL.inc b/plugins/FrxMSSQL.inc
index 0b1c9f9..46a0d9c 100644
--- a/plugins/FrxMSSQL.inc
+++ b/plugins/FrxMSSQL.inc
@@ -1,10 +1,17 @@
 <?php
-// $Id$
+
+/**
+ * @file
+ * $Id$
+ */
+
 /**
  * @file
- * Oracle specific driver that takes advantage of oracles native XML support
+ * Oracle specific driver that takes advantage of oracles native XML support.
  *
- * In order to take advantage of XML support the following XML
+ * In order to take advantage of XML support the following XML.
+ */
+/**
  *
  */
 class FrxMSSQL extends FrxDataSource {
@@ -14,10 +21,12 @@ class FrxMSSQL extends FrxDataSource {
   private $use_mssql_xml;
 
   /**
-   * Object constructor
+   * Object constructor.
    *
-   * @param unknown_type $uri Database connection string.
-   * @param string $repos_path Path to location of data block definitions
+   * @param unknown_type $uri
+   *   Database connection string.
+   * @param string $repos_path
+   *   Path to location of data block definitions.
    */
   public function __construct($conf, $repos_path, $name) {
 
@@ -26,9 +35,11 @@ class FrxMSSQL extends FrxDataSource {
     $this->use_mssql_xml = FALSE;
     $uri = $conf['uri'];
     $this->debug = $conf['debug'];
-    if ($conf['mssql_xml']) $this->use_mssql_xml = TRUE;
+    if ($conf['mssql_xml']) {
+      $this->use_mssql_xml = TRUE;
+    }
     if ($uri) {
-      // Test for mssql suport
+      // Test for mssql suport.
       if (!is_callable('mssql_connect')) {
         Frx::error('MSSQL support not installed.', 'MSSQL mssql support not installed.');
         return;
@@ -36,14 +47,15 @@ class FrxMSSQL extends FrxDataSource {
       try {
         ini_set('mssql.textlimit', 2147483647);
         ini_set('mssql.textsize', 2147483647);
-        $db = mssql_connect($uri, $conf['user'], $conf['password']);
+        $db = sybase_connect($uri, $conf['user'], $conf['password']);
         $this->db = $db;
 
         if ($db) {
-          mssql_select_db($conf['database'], $db);
-          mssql_query("SET QUOTED_IDENTIFIER ON");
+          sybase_select_db($conf['database'], $db);
+          sybase_query("SET QUOTED_IDENTIFIER ON");
         }
-      } catch (Exception $e) {
+      }
+      catch (Exception $e) {
         Frx::error('Unable to connect to database ' . $conf['title'], $e->getMessage());
       }
 
@@ -55,24 +67,24 @@ class FrxMSSQL extends FrxDataSource {
     // Set up the stuff required to translate.
     $this->te = new FrxSyntaxEngine(FRX_SQL_TOKEN, ':', $this);
   }
+
   /**
    * Get data based on file data block in the repository.
    *
-   * @param String $block_name
-   * @param Array $parm_data
+   * @param string $block_name
+   * @param array $parm_data
    * @param Query $subQuery
    */
   public function sqlData($sql, $options = array()) {
-    // Load the block from the file
-
+    // Load the block from the file.
     $db = $this->db;
 
-    // Load the types array based on data
-    $this->types = isset($options['type']) ? $options['type'] : array();
+    // Load the types array based on data.
+    $this->types = $options['type'] ?? array();
 
-    $xml ='';
-    // Load the types array based on data
-    $this->types = isset($options['type']) ? $options['type'] : array();
+    $xml = '';
+    // Load the types array based on data.
+    $this->types = $options['type'] ?? array();
     if ($sql && $db) {
       $sql = $this->te->replace($sql);
 
@@ -83,7 +95,9 @@ class FrxMSSQL extends FrxDataSource {
         $xml = $this->php_xml($sql);
       }
       if ($this->debug) {
-        if ($xml) $d = htmlspecialchars($xml->asXML());
+        if ($xml) {
+          $d = htmlspecialchars($xml->asXML());
+        }
         FRx::debug('SQL: ' . $sql, '<pre> SQL:' . $sql . "\n XML: " . $d . "\n</pre>");
       }
       return $xml;
@@ -92,37 +106,43 @@ class FrxMSSQL extends FrxDataSource {
   }
 
   /**
-   * Generate xml from sql using the provided f_forena
+   * Generate xml from sql using the provided f_forena.
    *
    * @param unknown_type $sql
+   *
    * @return unknown
    */
-  private function mssql_xml($sql, $block) {
+  private function mssqlXml($sql, $block) {
     $db = $this->db;
 
-    //$rs->debugDumpParams();
+    // $rs->debugDumpParams();
     $fsql = $sql . ' FOR XML AUTO';
-    $rs = mssql_query($db, $fsql, array($sql, ''));
+    $rs = sybase_query($db, $fsql, array($sql, ''));
     if ($rs) {
-      $row = mssql_fetch_row($rs);
+      $row = sybase_free_result($rs);
       $xml_text = $row[0];
     }
     if ($xml_text) {
       $xml = new SimpleXMLElement($xml_text);
       if ($xml->getName() == 'error') {
-        $msg = (string)$xml . ' in ' . $block . '.sql. ';
+        $msg = (string) $xml . ' in ' . $block . '.sql. ';
         Frx::error($msg . 'See logs for more info', $msg . ' in <pre> ' . $sql . '</pre>');
       }
     }
-    if ($rs) mssql_free_result($rs);
+    if ($rs) {
+      sybase_free_result($rs);
+    }
     return $xml;
   }
 
-  private function php_xml($sql) {
+  /**
+   *
+   */
+  private function phpXml($sql) {
     $db = $this->db;
     $xml = new SimpleXMLElement('<table/>');
 
-    $rs = mssql_query($sql, $db);
+    $rs = sybase_query($sql, $db);
     $rownum = 0;
     while ($row = mssql_fetch_assoc($rs)) {
       $rownum++;
@@ -132,13 +152,16 @@ class FrxMSSQL extends FrxDataSource {
         $row_node->addChild(strtolower($key), htmlspecialchars($value));
       }
     }
-    if ($rs) mssql_free_result($rs);
+    if ($rs) {
+      sybase_free_result($rs);
+    }
     return $xml;
 
   }
 
   /**
    * Perform search of tables.
+   *
    * @see FrxDataSource::searchTables()
    */
   public function searchTables($str) {
@@ -148,18 +171,21 @@ class FrxMSSQL extends FrxDataSource {
     $str = "'" . str_replace("'", "''", $str) . "'";
     $sql = str_replace(':str', $str, $sql);
     $rownum = 0;
-    $rs = mssql_query($sql, $db);
+    $rs = sybase_query($sql, $db);
     $tables = array();
     while ($row = mssql_fetch_assoc($rs)) {
       $tables[] = $row['table_name'];
     }
-    if ($rs) mssql_free_result($rs);
+    if ($rs) {
+      sybase_free_result($rs);
+    }
     return $tables;
 
   }
 
   /**
    * Perform search of tables.
+   *
    * @see FrxDataSource::searchTables()
    */
   public function searchTableColumns($table, $str) {
@@ -173,12 +199,16 @@ class FrxMSSQL extends FrxDataSource {
     $sql = str_replace(':table', $table, $sql);
     $rownum = 0;
 
-    $rs = mssql_query($sql, $db);
+    $rs = sybase_query($sql, $db);
     $columns = array();
-    if ($rs) while ($row = mssql_fetch_assoc($rs)) {
-      $columns[] = $row['COLUMN_NAME'];
+    if ($rs) {
+      while ($row = mssql_fetch_assoc($rs)) {
+        $columns[] = $row['COLUMN_NAME'];
+      }
+    }
+    if ($rs) {
+      sybase_free_result($rs);
     }
-    if ($rs) mssql_free_result($rs);
     return $columns;
 
   }
@@ -193,9 +223,11 @@ class FrxMSSQL extends FrxDataSource {
    * @param unknown_type $data
    */
   public function format($value, $key, $raw = FALSE) {
-    if ($raw) return $value;
+    if ($raw) {
+      return $value;
+    }
     $value = $this->parmConvert($key, $value);
-    if ($value===''||$value===NULL) {
+    if ($value === ''||$value === NULL) {
       $value = 'NULL';
     }
     elseif (is_array($value)) {
@@ -203,39 +235,41 @@ class FrxMSSQL extends FrxDataSource {
         $value = 'NULL';
       }
       else {
-        // Build a array of values string
-        $i=0;
+        // Build a array of values string.
+        $i = 0;
         $val = '';
         foreach ($value as $v) {
           $i++;
-          if ($i>1) {
+          if ($i > 1) {
             $val .= ',';
           }
-          $val .=  "'" . str_replace("'", "''", $v) . "'";
+          $val .= "'" . str_replace("'", "''", $v) . "'";
         }
         $value = $val;
       }
     }
     elseif (is_int($value)) {
-      $value = (int)$value;
-      $value = (string)$value;
+      $value = (int) $value;
+      $value = (string) $value;
     }
     elseif (is_float($value)) {
-      $value = (float)$value;
-      $value = (string)$value;
+      $value = (float) $value;
+      $value = (string) $value;
+    }
+    else {
+      $value = "'" . str_replace("'", "''", $value) . "'";
     }
-    else $value = "'" . str_replace("'", "''", $value) . "'";
     return $value;
   }
 
   /**
    * Destructor - Closes database connections.
-   *
    */
   public function __destruct() {
     $db = $this->db;
     if ($db) {
-      mssql_close($db);
+      sybase_close($db);
     }
   }
-}
\ No newline at end of file
+
+}
