diff --git a/backend.class.php b/backend.class.php
index 6686c62017852dd37f2861dc68baff844436bb22..844b0a9bc0491787d0c8172eaa679b51e45531b7 100644
--- a/backend.class.php
+++ b/backend.class.php
@@ -24,13 +24,10 @@ class backend {
   # Description..: Constructor - initializes the internal variables.
   #
   function backend($id, $site, $url, $file, $contact, $timout = 1800) {
-    ### Connect to database:
-    dbconnect();
-
     ### Get channel info:
-    $result = mysql_query("SELECT * FROM channel WHERE id = '$id' OR site = '$site'");
+    $result = db_query("SELECT * FROM channel WHERE id = '$id' OR site = '$site'");
 
-    if ($channel = mysql_fetch_object($result)) {
+    if ($channel = db_fetch_object($result)) {
       ### Initialize internal variables:
       $this->id = $channel->id;
       $this->site = $channel->site;
@@ -43,8 +40,8 @@ function backend($id, $site, $url, $file, $contact, $timout = 1800) {
       if (time() - $this->timestamp > $timout) $this->url2sql();
 
       ### Read headlines:
-      $result = mysql_query("SELECT * FROM headlines WHERE id = $this->id ORDER BY number");
-      while ($headline = mysql_fetch_object($result)) {
+      $result = db_query("SELECT * FROM headlines WHERE id = $this->id ORDER BY number");
+      while ($headline = db_fetch_object($result)) {
         array_push($this->headlines, "<A HREF=\"$headline->link\">$headline->title</A>");
       }
 
@@ -70,7 +67,7 @@ function rdf2sql($timout = 10) {
       $port = $url[port] ? $url[port] : 80;
       $path = $url[path];
      
-      // print "<PRE>$url - $host - $port - $path</PRE>";
+      // print "<PRE><B>Debug:</B> $url - $host - $port - $path</PRE>";
  
       ### Retrieve data from website:
       $fp = fsockopen($host, $port, &$errno, &$errstr, $timout);
@@ -89,7 +86,7 @@ function rdf2sql($timout = 10) {
         if (strstr($data, "200 OK")) {
 
           ### Remove existing entries:
-          $result = mysql_query("DELETE FROM headlines WHERE id = $this->id");
+          $result = db_query("DELETE FROM headlines WHERE id = $this->id");
 
           ### Strip all 'junk':
           $data = ereg_replace("<?xml.*/image>", "", $data);
@@ -114,11 +111,11 @@ function rdf2sql($timout = 10) {
             $number += 1;
 
             ### Insert item in database:
-            $result = mysql_query("INSERT INTO headlines (id, title, link, number) VALUES('$this->id', '$title', '$link', '$number')");
+            $result = db_query("INSERT INTO headlines (id, title, link, number) VALUES('$this->id', '$title', '$link', '$number')");
           }
  
           ### Mark channels as being updated:
-          $result = mysql_query("UPDATE channel SET timestamp = '". time() ."' WHERE id = $this->id");
+          $result = db_query("UPDATE channel SET timestamp = '". time() ."' WHERE id = $this->id");
           $this->timestamp = time();
         }
         else print "<HR>RDF parser: 404 error?<BR><BR><PRE>$data</PRE><HR>";
@@ -169,11 +166,8 @@ function url2sql($timout = 10) {
   function displayHeadlines($timout = 1800) {
     global $theme;
 
-    ### Connect to database:
-    dbconnect();
-
     ### Get channel info:
-    $result = mysql_query("SELECT * FROM channel WHERE site = '$this->site'");
+    $result = db_query("SELECT * FROM channel WHERE site = '$this->site'");
 
     if ($this->id) {
 
@@ -181,8 +175,8 @@ function displayHeadlines($timout = 1800) {
       if (time() - $this->timestamp > $timout) $this->url2sql();
 
       ### Grab headlines from database:
-      $result = mysql_query("SELECT * FROM headlines WHERE id = $this->id ORDER BY number");
-      while ($headline = mysql_fetch_object($result)) {
+      $result = db_query("SELECT * FROM headlines WHERE id = $this->id ORDER BY number");
+      while ($headline = db_fetch_object($result)) {
         $content .= "<LI><A HREF=\"$headline->link\">$headline->title</A></LI>";
       }
       ### Add timestamp:
@@ -201,11 +195,8 @@ function displayHeadlines($timout = 1800) {
   # Description..: Adds this backend to the database.
   #
   function add() {
-    ### Connect to database:
-    dbconnect();
-
     ### Add channel:    
-    $result = mysql_query("INSERT INTO channel (site, file, url, contact, timestamp) VALUES ('$this->site', '$this->file', '$this->url', '$this->contact', 42)");
+    $result = db_query("INSERT INTO channel (site, file, url, contact, timestamp) VALUES ('$this->site', '$this->file', '$this->url', '$this->contact', 42)");
   }
 
 
@@ -214,14 +205,11 @@ function add() {
   # Description..: Deletes this backend
   #
   function delete() {
-    ### Connect to database:
-    dbconnect();
-
     ### Delete channel:    
-    $result = mysql_query("DELETE FROM channel WHERE id = $this->id");
+    $result = db_query("DELETE FROM channel WHERE id = $this->id");
 
     ### Delete headlines:
-    $result = mysql_query("DELETE FROM headlines WHERE id = $this->id");    
+    $result = db_query("DELETE FROM headlines WHERE id = $this->id");    
   }
 
   #####
@@ -229,14 +217,11 @@ function delete() {
   # Description..: Deletes all headlines associated with this backend.
   #
   function refresh() {
-    ### Connect to database:
-    dbconnect();
-
     ### Delete headlines:
-    $result = mysql_query("DELETE FROM headlines WHERE id = $this->id");    
+    $result = db_query("DELETE FROM headlines WHERE id = $this->id");    
 
     ### Mark channel as invalid to enforce an update:
-    $result = mysql_query("UPDATE channel SET timestamp = 42 WHERE id = $this->id");    
+    $result = db_query("UPDATE channel SET timestamp = 42 WHERE id = $this->id");    
   }
 
   #####
diff --git a/backend.php b/backend.php
index 45d169bb39aa4cea5ccea7c3815b37a2689b17f5..a0eabf120b4026143bf45dc39cb4d0a2ff88c93b 100644
--- a/backend.php
+++ b/backend.php
@@ -1,7 +1,5 @@
 <?
 
-include "theme.inc";
-include "backend.class.php";
 
 function adminAddChannel() {
   ?>
@@ -34,18 +32,15 @@ function adminAddChannel() {
 function displayAll() {
   global $theme;
 
-  ### Connect to database:
-  dbconnect();
-
   ### Get channel info:
-  $result = mysql_query("SELECT * FROM channel ORDER BY id");
+  $result = db_query("SELECT * FROM channel ORDER BY id");
 
-  print "<HR>";
-  print "<TABLE BORDER=\"0\">";
-  while ($channel = mysql_fetch_object($result)) {
-    if ($state % 3 == 0) print " <TR>";
+  print "<HR>\n";
+  print "<TABLE BORDER=\"0\">\n";
+  while ($channel = db_fetch_object($result)) {
+    if ($state % 3 == 0) print " <TR>\n";
 
-    print " <TD ALIGN=\"center\" VALIGN=\"top\" WIDTH=\"33%\">";
+    print "  <TD ALIGN=\"center\" VALIGN=\"top\" WIDTH=\"33%\">\n";
     
     ### Load backend from database:
     $backend = new backend($channel->id);
@@ -53,33 +48,30 @@ function displayAll() {
     ### Read headlines from backend class:
     $content = "";
     for (reset($backend->headlines); $headline = current($backend->headlines); next($backend->headlines)) {
-      $content .= "<LI>$headline</LI>";
+      $content .= "<LI>$headline</LI>\n";
     }
 
     ### Print backend box to screen:
-    $theme->box($backend->site, "$content<P ALIGN=\"right\">[ <A HREF=\"$backend->url\">more</A> ]");
-    print " </TD>";
+    $theme->box($backend->site, "$content<P ALIGN=\"right\">[ <A HREF=\"$backend->url\">more</A> ]\n");
+    print " </TD>\n";
 
-    if ($state % 3 == 2) print " </TR>";
+    if ($state % 3 == 2) print " </TR>\n";
 
     $state += 1;
   }  
-  print "</TABLE>";
+  print "</TABLE>\n";
 }
 
 function adminMain() {
   global $theme, $PHP_SELF;
 
-  ### Connect to database:
-  dbconnect();
-
   ### Get channel info:
-  $result = mysql_query("SELECT * FROM channel ORDER BY id");
+  $result = db_query("SELECT * FROM channel ORDER BY id");
 
   print "<TABLE BORDER=\"0\" WIDTH=\"100%\" CELLSPACING=\"2\" CELLPADDING=\"4\">";
   print " 
   <TR BGCOLOR=\"$theme->bgcolor1\"><TD ALIGN=\"center\"><B><FONT COLOR=\"$theme->fgcolor1\">Site</FONT></B></TD><TD ALIGN=\"center\"><B><FONT COLOR=\"$theme->fgcolor1\">Contact</FONT></B></TD><TD ALIGN=\"center\"><B><FONT COLOR=\"$theme->fgcolor1\">Last updated</FONT></B></TD><TD ALIGN=\"center\" COLSPAN=\"2\"><B><FONT COLOR=\"$theme->fgcolor1\">Operations</FONT></B></TD></TR>";
-  while ($channel = mysql_fetch_object($result)) {
+  while ($channel = db_fetch_object($result)) {
     ### Load backend from database:
     $backend = new backend($channel->id);
     
@@ -95,6 +87,8 @@ function adminMain() {
   print "<BR><BR>";
 }
 
+include "backend.class.php";
+include "theme.inc";
 
 $theme->header();