diff --git a/db_structure.xml b/db_structure.xml
index 144298c8b386c9e103becd21b293e2f7cd26bef6..59f3aec0c7eb7e07c21c2e72966d73c2ba0eb645 100644
--- a/db_structure.xml
+++ b/db_structure.xml
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="ISO-8859-1" ?>
 <database>
 
- <name>owncloud</name>
+   <name>*dbname*</name>
  <create>true</create>
  <overwrite>false</overwrite>
 
@@ -9,7 +9,7 @@
 
  <table>
 
-  <name>appconfig</name>
+   <name>*dbprefix*appconfig</name>
 
   <declaration>
 
@@ -43,7 +43,7 @@
 
  <table>
 
-  <name>foldersize</name>
+   <name>*dbprefix*foldersize</name>
 
   <declaration>
 
@@ -52,7 +52,7 @@
     <type>text</type>
     <default></default>
     <notnull>true</notnull>
-    <length>512</length>
+    <length>128</length>
    </field>
 
    <field>
@@ -78,7 +78,7 @@
 
  <table>
 
-  <name>group_user</name>
+   <name>*dbprefix*group_user</name>
 
   <declaration>
 
@@ -104,7 +104,7 @@
 
  <table>
 
-  <name>groups</name>
+   <name>*dbprefix*groups</name>
 
   <declaration>
 
@@ -131,7 +131,7 @@
 
  <table>
 
-  <name>locks</name>
+   <name>*dbprefix*locks</name>
 
   <declaration>
 
@@ -267,7 +267,7 @@
 
  <table>
 
-  <name>log</name>
+   <name>*dbprefix*log</name>
 
   <declaration>
 
@@ -324,7 +324,7 @@
 
  <table>
 
-  <name>preferences</name>
+   <name>*dbprefix*preferences</name>
 
   <declaration>
 
@@ -366,7 +366,7 @@
 
  <table>
 
-  <name>properties</name>
+   <name>*dbprefix*properties</name>
 
   <declaration>
 
@@ -431,7 +431,7 @@
 
  <table>
 
-  <name>publiclink</name>
+   <name>*dbprefix*publiclink</name>
 
   <declaration>
 
@@ -481,7 +481,7 @@
 
  <table>
 
-  <name>users</name>
+   <name>*dbprefix*users</name>
 
   <declaration>
 
diff --git a/index.php b/index.php
index b8e1cb24dd59ae6ed606a910ae136c450ede5dbf..c582cbdaace328058aeec4f9b990aa361046f31c 100644
--- a/index.php
+++ b/index.php
@@ -25,6 +25,7 @@ require_once( 'lib/base.php' );
 require_once( 'appconfig.php' );
 require_once( 'template.php' );
 
+
 // check if the server is correctly configured for ownCloud
 $errors=OC_UTIL::checkServer();
 if(count($errors)>0){
diff --git a/lib/User/database.php b/lib/User/database.php
index 5b68d3ff7c2d23e1da9fb995629a4bdde9f2975d..c413b18058906e1c1e3eb3d5ffd43f656baaa800 100644
--- a/lib/User/database.php
+++ b/lib/User/database.php
@@ -51,7 +51,6 @@ class OC_USER_DATABASE extends OC_USER_BACKEND {
 	public static function createUser( $uid, $password ){
 		$query = OC_DB::prepare( "SELECT * FROM `*PREFIX*users` WHERE `uid` = ?" );
 		$result = $query->execute( array( $uid ));
-
 		// Check if the user already exists
 		if ( $result->numRows() > 0 ){
 			return false;
diff --git a/lib/database.php b/lib/database.php
index b620009bf50887056e408c0045eec616be469778..970e43c12272164caf76e39977ee554707337cc1 100644
--- a/lib/database.php
+++ b/lib/database.php
@@ -279,7 +279,7 @@ class OC_DB {
 		// Connect if this did not happen before
 		if(!self::$schema){
 			require_once('MDB2/Schema.php');
-			self::$schema=&MDB2_Schema::factory(self::$DBConnection);
+			self::$schema=MDB2_Schema::factory(self::$DBConnection);
 		}
 
 		return true;
diff --git a/lib/installer.php b/lib/installer.php
index a87e7541fc4bcae60dab4a150dbfd8ac31e8e371..3be3cb44f22a39a6ba6a6a520ffa7760e5823902 100644
--- a/lib/installer.php
+++ b/lib/installer.php
@@ -65,34 +65,45 @@ class OC_INSTALLER{
 				}else{
 					$query="SELECT user FROM mysql.user WHERE user='$dbuser'";//this should be enough to check for admin rights in mysql
 					if(mysql_query($query,$connection)){
+						self::createDBUser($username,$password,$connection);
 						//use the admin login data for the new database user
-						self::createDBUser($username,$password);
 						OC_CONFIG::setValue('dbuser',$username);
 						OC_CONFIG::setValue('dbpass',$password);
+						
+						//create the database
+						self::createDatabase($dbname,$username,$connection);
 					}else{
 						OC_CONFIG::setValue('dbuser',$dbuser);
-						OC_CONFIG::setValue('dbpass',$dbpass);
+						OC_CONFIG::setValue('dbpassword',$dbpass);
 						
 						//create the database
-						self::createDatabase($dbname,$dbuser);
+						self::createDatabase($dbname,$dbuser,$connection);
 					}
 				}
+				//fill the database if needed
+				$query="SELECT * FROM $dbname.{$dbtableprefix}users";
+				$result = mysql_query($query,$connection);
+				if (!$result) {
+					OC_DB::createDbFromStructure('db_structure.xml');
+				}
 				mysql_close($connection);
+			}else{
+				//in case of sqlite, we can always fill the database
+				OC_DB::createDbFromStructure('db_structure.xml');
 			}
+			
+			//create the user and group
 			OC_USER::createUser($username,$password);
 			OC_GROUP::createGroup('admin');
 			OC_GROUP::addToGroup($username,'admin');
+			
+			//and we are done
 			OC_CONFIG::setValue('installed',true);
 		}
 		return $error;
 	}
 	
-	public static function createDatabase($name,$adminUser,$adminPwd){//TODO refactoring this
-		$CONFIG_DBHOST=$options['host'];
-		$CONFIG_DBNAME=$options['name'];
-		$CONFIG_DBUSER=$options['user'];
-		$CONFIG_DBPWD=$options['pass'];
-		$CONFIG_DBTYPE=$options['type'];
+	public static function createDatabase($name,$user,$connection){
 		//we cant user OC_BD functions here because we need to connect as the administrative user.
 		$query="CREATE DATABASE IF NOT EXISTS  `$name`";
 		$result = mysql_query($query,$connection);
@@ -102,18 +113,13 @@ class OC_INSTALLER{
 			echo($entry);
 		}
 		$query="GRANT ALL PRIVILEGES ON  `$name` . * TO  '$user'";
-		$result = mysql_query($query,$connection);
-		if (!$result) {
-			$entry='DB Error: "'.mysql_error($connection).'"<br />';
-			$entry.='Offending command was: '.$query.'<br />';
-			echo($entry);
-		}
+		$result = mysql_query($query,$connection);//this query will fail if there aren't the right permissons, ignore the error
 	}
 	
-	private static function createDBUser($name,$password){
+	private static function createDBUser($name,$password,$connection){
 		//we need to create 2 accounts, one for global use and one for local user. if we don't speccify the local one,
 				//  the anonymous user would take precedence when there is one.
-		$query="CREATE USER 'name'@'localhost' IDENTIFIED BY '$password'";
+		$query="CREATE USER '$name'@'localhost' IDENTIFIED BY '$password'";
 		$result = mysql_query($query,$connection);
 		$query="CREATE USER '$name'@'%' IDENTIFIED BY '$password'";
 		$result = mysql_query($query,$connection);