diff --git a/apps/contacts/ajax/addcard.php b/apps/contacts/ajax/addcard.php
index 24766931d71814da524d3bf469bb342a690d8520..e9f82f1b3e3baf3d379879a0d25f5dc976cec33b 100644
--- a/apps/contacts/ajax/addcard.php
+++ b/apps/contacts/ajax/addcard.php
@@ -32,7 +32,7 @@ if( !OC_User::isLoggedIn()){
 	exit();
 }
 
-$addressbook = OC_Contacts_Addressbook::findAddressbook( $aid );
+$addressbook = OC_Contacts_Addressbook::find( $aid );
 if( $addressbook === false || $addressbook['userid'] != OC_USER::getUser()){
 	echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('This is not your addressbook!'))));
 	exit();
@@ -42,10 +42,10 @@ $fn = $_POST['fn'];
 
 $vcard = new Sabre_VObject_Component('VCARD');
 $vcard->add(new Sabre_VObject_Property('FN',$fn));
-$vcard->add(new Sabre_VObject_Property('UID',OC_Contacts_Addressbook::createUID()));
-$id = OC_Contacts_Addressbook::addCard($aid,$vcard->serialize());
+$vcard->add(new Sabre_VObject_Property('UID',OC_Contacts_VCard::createUID()));
+$id = OC_Contacts_VCard::add($aid,$vcard->serialize());
 
-$details = OC_Contacts_Addressbook::structureContact($vcard);
+$details = OC_Contacts_VCard::structureContact($vcard);
 $tmpl = new OC_Template('contacts','part.details');
 $tmpl->assign('details',$details);
 $tmpl->assign('id',$id);
diff --git a/apps/contacts/ajax/addproperty.php b/apps/contacts/ajax/addproperty.php
index 70b2c8dcf82a6024b2ce096e2278f115133fdfbc..7df67e3d3306c95133f851252eafc062d5ca970b 100644
--- a/apps/contacts/ajax/addproperty.php
+++ b/apps/contacts/ajax/addproperty.php
@@ -32,19 +32,19 @@ if( !OC_User::isLoggedIn()){
 	exit();
 }
 
-$card = OC_Contacts_Addressbook::findCard( $id );
+$card = OC_Contacts_VCard::find( $id );
 if( $card === false ){
 	echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('Can not find Contact!'))));
 	exit();
 }
 
-$addressbook = OC_Contacts_Addressbook::findAddressbook( $card['addressbookid'] );
+$addressbook = OC_Contacts_Addressbook::find( $card['addressbookid'] );
 if( $addressbook === false || $addressbook['userid'] != OC_USER::getUser()){
 	echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('This is not your contact!'))));
 	exit();
 }
 
-$vcard = OC_Contacts_Addressbook::parse($card['carddata']);
+$vcard = OC_Contacts_VCard::parse($card['carddata']);
 // Check if the card is valid
 if(is_null($vcard)){
 	echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('Unable to parse vCard!'))));
@@ -56,7 +56,7 @@ $value = $_POST['value'];
 $parameters = isset($_POST['parameteres'])?$_POST['parameters']:array();
 
 if(is_array($value)){
-	$value = OC_Contacts_Addressbook::escapeSemicolons($value);
+	$value = OC_Contacts_VCard::escapeSemicolons($value);
 }
 $property = new Sabre_VObject_Property( $name, $value );
 $parameternames = array_keys($parameters);
@@ -69,10 +69,10 @@ $vcard->add($property);
 $line = count($vcard->children) - 1;
 $checksum = md5($property->serialize());
 
-OC_Contacts_Addressbook::editCard($id,$vcard->serialize());
+OC_Contacts_VCard::edit($id,$vcard->serialize());
 
 $tmpl = new OC_Template('contacts','part.property');
-$tmpl->assign('property',OC_Contacts_Addressbook::structureProperty($property,$line));
+$tmpl->assign('property',OC_Contacts_VCard::structureProperty($property,$line));
 $page = $tmpl->fetchPage();
 
 echo json_encode( array( 'status' => 'success', 'data' => array( 'page' => $page )));
diff --git a/apps/contacts/ajax/deletebook.php b/apps/contacts/ajax/deletebook.php
index 8506284cc0d1a7d1205ed7d50c07fa55bc699019..9e623120df918fa5f967af973118b2c5b965036e 100644
--- a/apps/contacts/ajax/deletebook.php
+++ b/apps/contacts/ajax/deletebook.php
@@ -33,11 +33,11 @@ if( !OC_User::isLoggedIn()){
 	exit();
 }
 
-$addressbook = OC_Contacts_Addressbook::findAddressbook( $id );
+$addressbook = OC_Contacts_Addressbook::find( $id );
 if( $addressbook === false || $addressbook['userid'] != OC_USER::getUser()){
 	echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('This is not your contact!'))));
 	exit();
 }
 
-OC_Contacts_Addressbook::deleteAddressbook($id);
+OC_Contacts_Addressbook::delete($id);
 echo json_encode( array( 'status' => 'success', 'data' => array( 'id' => $id )));
diff --git a/apps/contacts/ajax/deletecard.php b/apps/contacts/ajax/deletecard.php
index 839936d3fadfadd56221de5402541fc732b248d0..b31c643f5996e62c80ea7119f48066580219e13c 100644
--- a/apps/contacts/ajax/deletecard.php
+++ b/apps/contacts/ajax/deletecard.php
@@ -34,17 +34,17 @@ if( !OC_User::isLoggedIn()){
 }
 
 
-$card = OC_Contacts_Addressbook::findCard( $id );
+$card = OC_Contacts_VCard::find( $id );
 if( $card === false ){
 	echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('Can not find Contact!'))));
 	exit();
 }
 
-$addressbook = OC_Contacts_Addressbook::findAddressbook( $card['addressbookid'] );
+$addressbook = OC_Contacts_Addressbook::find( $card['addressbookid'] );
 if( $addressbook === false || $addressbook['userid'] != OC_USER::getUser()){
 	echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('This is not your contact!'))));
 	exit();
 }
 
-OC_Contacts_Addressbook::deleteCard($id);
+OC_Contacts_VCard::delete($id);
 echo json_encode( array( 'status' => 'success', 'data' => array( 'id' => $id )));
diff --git a/apps/contacts/ajax/deleteproperty.php b/apps/contacts/ajax/deleteproperty.php
index 52adca877f5ac71bf99475a52d27e4d9562fb717..df2ae2e1c0357092fe8b3b64b3b78a65df637db8 100644
--- a/apps/contacts/ajax/deleteproperty.php
+++ b/apps/contacts/ajax/deleteproperty.php
@@ -36,19 +36,19 @@ if( !OC_User::isLoggedIn()){
 }
 
 
-$card = OC_Contacts_Addressbook::findCard( $id );
+$card = OC_Contacts_VCard::find( $id );
 if( $card === false ){
 	echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('Can not find Contact!'))));
 	exit();
 }
 
-$addressbook = OC_Contacts_Addressbook::findAddressbook( $card['addressbookid'] );
+$addressbook = OC_Contacts_Addressbook::find( $card['addressbookid'] );
 if( $addressbook === false || $addressbook['userid'] != OC_USER::getUser()){
 	echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('This is not your contact!'))));
 	exit();
 }
 
-$vcard = OC_Contacts_Addressbook::parse($card['carddata']);
+$vcard = OC_Contacts_VCard::parse($card['carddata']);
 // Check if the card is valid
 if(is_null($vcard)){
 	echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('Unable to parse vCard!'))));
@@ -68,5 +68,5 @@ if(is_null($line)){
 
 unset($vcard->children[$line]);
 
-OC_Contacts_Addressbook::editCard($id,$vcard->serialize());
+OC_Contacts_VCard::edit($id,$vcard->serialize());
 echo json_encode( array( 'status' => 'success', 'data' => array( 'id' => $id )));
diff --git a/apps/contacts/ajax/getdetails.php b/apps/contacts/ajax/getdetails.php
index e13cb9dfe93abf2ce2d7b7fd45f4c0be23b0ac59..1f321fa335b8eb8c949be603f261a4090f0cf94a 100644
--- a/apps/contacts/ajax/getdetails.php
+++ b/apps/contacts/ajax/getdetails.php
@@ -34,26 +34,26 @@ if( !OC_User::isLoggedIn()){
 }
 
 
-$card = OC_Contacts_Addressbook::findCard( $id );
+$card = OC_Contacts_VCard::findCard( $id );
 if( $card === false ){
 	echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('Can not find Contact!'))));
 	exit();
 }
 
-$addressbook = OC_Contacts_Addressbook::findAddressbook( $card['addressbookid'] );
+$addressbook = OC_Contacts_Addressbook::find( $card['addressbookid'] );
 if( $addressbook === false || $addressbook['userid'] != OC_USER::getUser()){
 	echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('This is not your contact!'))));
 	exit();
 }
 
-$vcard = OC_Contacts_Addressbook::parse($card['carddata']);
+$vcard = OC_Contacts_VCard::parse($card['carddata']);
 // Check if the card is valid
 if(is_null($vcard)){
 	echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('Unable to parse vCard!'))));
 	exit();
 }
 
-$details = OC_Contacts_Addressbook::structureContact($vcard);
+$details = OC_Contacts_VCard::structureContact($vcard);
 $tmpl = new OC_Template('contacts','part.details');
 $tmpl->assign('details',$details);
 $tmpl->assign('id',$id);
diff --git a/apps/contacts/ajax/setproperty.php b/apps/contacts/ajax/setproperty.php
index 8b9bc4b3cfe209800ccd917936b5978d4dd192ee..9a4e8eea264d0701346aa9234571de9553a44366 100644
--- a/apps/contacts/ajax/setproperty.php
+++ b/apps/contacts/ajax/setproperty.php
@@ -33,19 +33,19 @@ if( !OC_User::isLoggedIn()){
 	exit();
 }
 
-$card = OC_Contacts_Addressbook::findCard( $id );
+$card = OC_Contacts_VCard::find( $id );
 if( $card === false ){
 	echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('Can not find Contact!'))));
 	exit();
 }
 
-$addressbook = OC_Contacts_Addressbook::findAddressbook( $card['addressbookid'] );
+$addressbook = OC_Contacts_Addressbook::find( $card['addressbookid'] );
 if( $addressbook === false || $addressbook['userid'] != OC_USER::getUser()){
 	echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('This is not your contact!'))));
 	exit();
 }
 
-$vcard = OC_Contacts_Addressbook::parse($card['carddata']);
+$vcard = OC_Contacts_VCard::parse($card['carddata']);
 // Check if the card is valid
 if(is_null($vcard)){
 	echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('Unable to parse vCard!'))));
@@ -66,7 +66,7 @@ if(is_null($line)){
 // Set the value
 $value = $_POST['value'];
 if(is_array($value)){
-	$value = OC_Contacts_Addressbook::escapeSemicolons($value);
+	$value = OC_Contacts_VCard::escapeSemicolons($value);
 }
 $vcard->children[$line]->setValue($value);
 
@@ -94,10 +94,10 @@ foreach($missingparameters as $i){
 // Do checksum and be happy
 $checksum = md5($vcard->children[$line]->serialize());
 
-OC_Contacts_Addressbook::editCard($id,$vcard->serialize());
+OC_Contacts_VCard::edit($id,$vcard->serialize());
 
 $tmpl = new OC_Template('contacts','part.property');
-$tmpl->assign('property',OC_Contacts_Addressbook::structureProperty($vcard->children[$line],$line));
+$tmpl->assign('property',OC_Contacts_VCard::structureProperty($vcard->children[$line],$line));
 $page = $tmpl->fetchPage();
 
 echo json_encode( array( 'status' => 'success', 'data' => array( 'page' => $page, 'line' => $line, 'oldchecksum' => $_POST['checksum'] )));
diff --git a/apps/contacts/ajax/showaddcard.php b/apps/contacts/ajax/showaddcard.php
index 41ebb41d3e9d31bffb2c2e38f8de3d2977bf2090..dea8073a785fdf063b7adadb42b810188e95f597 100644
--- a/apps/contacts/ajax/showaddcard.php
+++ b/apps/contacts/ajax/showaddcard.php
@@ -31,7 +31,7 @@ if( !OC_User::isLoggedIn()){
 	exit();
 }
 
-$addressbooks = OC_Contacts_Addressbook::allAddressbooks(OC_USER::getUser());
+$addressbooks = OC_Contacts_Addressbook::all(OC_USER::getUser());
 $tmpl = new OC_Template('contacts','part.addcardform');
 $tmpl->assign('addressbooks',$addressbooks);
 $page = $tmpl->fetchPage();
diff --git a/apps/contacts/ajax/showaddproperty.php b/apps/contacts/ajax/showaddproperty.php
index becc39b120a01307ae65cfd1d3306defd472519d..75dbe01cfbcbb2af29c87ee325fd97d2468c4599 100644
--- a/apps/contacts/ajax/showaddproperty.php
+++ b/apps/contacts/ajax/showaddproperty.php
@@ -32,13 +32,13 @@ if( !OC_User::isLoggedIn()){
 	exit();
 }
 
-$card = OC_Contacts_Addressbook::findCard( $id );
+$card = OC_Contacts_VCard::find( $id );
 if( $card === false ){
 	echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('Can not find Contact!'))));
 	exit();
 }
 
-$addressbook = OC_Contacts_Addressbook::findAddressbook( $card['addressbookid'] );
+$addressbook = OC_Contacts_Addressbook::find( $card['addressbookid'] );
 if( $addressbook === false || $addressbook['userid'] != OC_USER::getUser()){
 	echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('This is not your contact!'))));
 	exit();
diff --git a/apps/contacts/ajax/showsetproperty.php b/apps/contacts/ajax/showsetproperty.php
index 722ee8d9e3510c713b1952d48599203da10cbe70..51187d505bcf68fc03780907af90ae23c6f1f770 100644
--- a/apps/contacts/ajax/showsetproperty.php
+++ b/apps/contacts/ajax/showsetproperty.php
@@ -33,19 +33,19 @@ if( !OC_User::isLoggedIn()){
 	exit();
 }
 
-$card = OC_Contacts_Addressbook::findCard( $id );
+$card = OC_Contacts_VCard::find( $id );
 if( $card === false ){
 	echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('Can not find Contact!'))));
 	exit();
 }
 
-$addressbook = OC_Contacts_Addressbook::findAddressbook( $card['addressbookid'] );
+$addressbook = OC_Contacts_Addressbook::find( $card['addressbookid'] );
 if( $addressbook === false || $addressbook['userid'] != OC_USER::getUser()){
 	echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('This is not your contact!'))));
 	exit();
 }
 
-$vcard = OC_Contacts_Addressbook::parse($card['carddata']);
+$vcard = OC_Contacts_VCard::parse($card['carddata']);
 // Check if the card is valid
 if(is_null($vcard)){
 	echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => $l10n->t('Unable to parse vCard!'))));
@@ -67,7 +67,7 @@ if(is_null($line)){
 $tmpl = new OC_Template('contacts','part.setpropertyform');
 $tmpl->assign('id',$id);
 $tmpl->assign('checksum',$checksum);
-$tmpl->assign('property',OC_Contacts_Addressbook::structureProperty($vcard->children[$line]));
+$tmpl->assign('property',OC_Contacts_VCard::structureProperty($vcard->children[$line]));
 $page = $tmpl->fetchPage();
 
 echo json_encode( array( 'status' => 'success', 'data' => array( 'page' => $page )));
diff --git a/apps/contacts/appinfo/app.php b/apps/contacts/appinfo/app.php
index 7ae6be5d6e3d3e1590431be9d37ce66b4fe89984..98416ead2fcf432943501a1d16a98869e0ea3ac8 100644
--- a/apps/contacts/appinfo/app.php
+++ b/apps/contacts/appinfo/app.php
@@ -1,16 +1,17 @@
 <?php
 
 OC::$CLASSPATH['OC_Contacts_Addressbook'] = 'apps/contacts/lib/addressbook.php';
+OC::$CLASSPATH['OC_Contacts_VCard'] = 'apps/contacts/lib/vcard.php';
 OC::$CLASSPATH['OC_Contacts_Hooks'] = 'apps/contacts/lib/hooks.php';
 OC::$CLASSPATH['OC_Connector_Sabre_CardDAV'] = 'apps/contacts/lib/connector_sabre.php';
 OC_HOOK::connect('OC_User', 'post_createUser', 'OC_Contacts_Hooks', 'deleteUser');
 
-OC_App::register( array( 
+OC_App::register( array(
   'order' => 10,
   'id' => 'contacts',
   'name' => 'Contacts' ));
 
-OC_App::addNavigationEntry( array( 
+OC_App::addNavigationEntry( array(
   'id' => 'contacts_index',
   'order' => 10,
   'href' => OC_Helper::linkTo( 'contacts', 'index.php' ),
diff --git a/apps/contacts/index.php b/apps/contacts/index.php
index a8926cd96fdc8e0b5f7ae03eb7379bca2d8b2518..8013f19d31ff7401f81de2a0bad560810757f4f1 100644
--- a/apps/contacts/index.php
+++ b/apps/contacts/index.php
@@ -34,10 +34,10 @@ if( !OC_User::isLoggedIn()){
 }
 
 // Check if the user has an addressbook
-$addressbooks = OC_Contacts_Addressbook::allAddressbooks(OC_User::getUser());
+$addressbooks = OC_Contacts_Addressbook::all(OC_User::getUser());
 if( count($addressbooks) == 0){
-	OC_Contacts_Addressbook::addAddressbook(OC_User::getUser(),'default','Default Address Book');
-	$addressbooks = OC_Contacts_Addressbook::allAddressbooks(OC_User::getUser());
+	OC_Contacts_Addressbook::add(OC_User::getUser(),'default','Default Address Book');
+	$addressbooks = OC_Contacts_Addressbook::all(OC_User::getUser());
 }
 $prefbooks = OC_Preferences::getValue(OC_User::getUser(),'contacts','openaddressbooks',null);
 if(is_null($prefbooks)){
@@ -58,7 +58,7 @@ $openaddressbooks = explode(';',$prefbooks);
 
 $contacts = array();
 foreach( $openaddressbooks as $addressbook ){
-	$addressbookcontacts = OC_Contacts_Addressbook::allCards($addressbook);
+	$addressbookcontacts = OC_Contacts_VCard::all($addressbook);
 	foreach( $addressbookcontacts as $contact ){
 		if(is_null($contact['fullname'])){
 			continue;
@@ -73,9 +73,9 @@ $details = array();
 
 if( !is_null($id) || count($contacts)){
 	if(is_null($id)) $id = $contacts[0]['id'];
-	$contact = OC_Contacts_Addressbook::findCard($id);
-	$vcard = Sabre_VObject_Reader::read($contact['carddata']);
-	$details = OC_Contacts_Addressbook::structureContact($vcard);
+	$contact = OC_Contacts_VCard::find($id);
+	$vcard = OC_Contacts_VCard::parse($contact['carddata']);
+	$details = OC_Contacts_VCard::structureContact($vcard);
 }
 
 // Process the template
diff --git a/apps/contacts/lib/addressbook.php b/apps/contacts/lib/addressbook.php
index 06857e52418fd6ff400d578f4d1bf7a61081074b..2e869d7de3bf803b4359f8a1b5b3ef2726491e10 100644
--- a/apps/contacts/lib/addressbook.php
+++ b/apps/contacts/lib/addressbook.php
@@ -33,16 +33,7 @@
  * ctag INT(11) UNSIGNED NOT NULL DEFAULT '1'
  * );
  *
- * CREATE TABLE contacts_cards (
- * id INT(11) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
- * addressbookid INT(11) UNSIGNED NOT NULL,
- * fullname VARCHAR(255),
- * carddata TEXT,
- * uri VARCHAR(100),
- * lastmodified INT(11) UNSIGNED
- * );
  */
-
 /**
  * This class manages our addressbooks.
  */
@@ -52,7 +43,7 @@ class OC_Contacts_Addressbook{
 	 * @param string $uid
 	 * @return array
 	 */
-	public static function allAddressbooks($uid){
+	public static function all($uid){
 		$stmt = OC_DB::prepare( 'SELECT * FROM *PREFIX*contacts_addressbooks WHERE userid = ?' );
 		$result = $stmt->execute(array($uid));
 
@@ -69,9 +60,9 @@ class OC_Contacts_Addressbook{
 	 * @param string $principaluri
 	 * @return array
 	 */
-	public static function allAddressbooksWherePrincipalURIIs($principaluri){
+	public static function allWherePrincipalURIIs($principaluri){
 		$uid = self::extractUserID($principaluri);
-		return self::allAddressbooks($uid);
+		return self::all($uid);
 	}
 
 	/**
@@ -79,7 +70,7 @@ class OC_Contacts_Addressbook{
 	 * @param integer $id
 	 * @return associative array
 	 */
-	public static function findAddressbook($id){
+	public static function find($id){
 		$stmt = OC_DB::prepare( 'SELECT * FROM *PREFIX*contacts_addressbooks WHERE id = ?' );
 		$result = $stmt->execute(array($id));
 
@@ -93,8 +84,8 @@ class OC_Contacts_Addressbook{
 	 * @param string $description
 	 * @return insertid
 	 */
-	public static function addAddressbook($userid,$name,$description){
-		$all = self::allAddressbooks($userid);
+	public static function add($userid,$name,$description){
+		$all = self::all($userid);
 		$uris = array();
 		foreach($all as $i){
 			$uris[] = $i['uri'];
@@ -116,7 +107,7 @@ class OC_Contacts_Addressbook{
 	 * @param string $description
 	 * @return insertid
 	 */
-	public static function addAddressbookFromDAVData($principaluri,$uri,$name,$description){
+	public static function addFromDAVData($principaluri,$uri,$name,$description){
 		$userid = self::extractUserID($principaluri);
 
 		$stmt = OC_DB::prepare( 'INSERT INTO *PREFIX*contacts_addressbooks (userid,displayname,uri,description,ctag) VALUES(?,?,?,?,?)' );
@@ -132,7 +123,7 @@ class OC_Contacts_Addressbook{
 	 * @param string $description
 	 * @return boolean
 	 */
-	public static function editAddressbook($id,$name,$description){
+	public static function edit($id,$name,$description){
 		// Need these ones for checking uri
 		$addressbook = self::find($id);
 
@@ -149,226 +140,35 @@ class OC_Contacts_Addressbook{
 		return true;
 	}
 
-	/**
-	 * @brief Updates ctag for addressbook
-	 * @param integer $id
-	 * @return boolean
-	 */
-	public static function touchAddressbook($id){
-		$stmt = OC_DB::prepare( 'UPDATE *PREFIX*contacts_addressbooks SET ctag = ctag + 1 WHERE id = ?' );
-		$stmt->execute(array($id));
-
-		return true;
-	}
-
 	/**
 	 * @brief removes an address book
 	 * @param integer $id
 	 * @return boolean
 	 */
-	public static function deleteAddressbook($id){
+	public static function delete($id){
 		$stmt = OC_DB::prepare( 'DELETE FROM *PREFIX*contacts_addressbooks WHERE id = ?' );
 		$stmt->execute(array($id));
 
-		$stmt = OC_DB::prepare( 'DELETE FROM *PREFIX*contacts_cards WHERE addressbookid = ?' );
-		$stmt->execute(array($id));
-
-		return true;
-	}
-
-	/**
-	 * @brief Returns all cards of an address book
-	 * @param integer $id
-	 * @return array
-	 *
-	 * The cards are associative arrays. You'll find the original vCard in
-	 * ['carddata']
-	 */
-	public static function allCards($id){
-		$stmt = OC_DB::prepare( 'SELECT * FROM *PREFIX*contacts_cards WHERE addressbookid = ?' );
-		$result = $stmt->execute(array($id));
-
-		$addressbooks = array();
-		while( $row = $result->fetchRow()){
-			$addressbooks[] = $row;
-		}
-
-		return $addressbooks;
-	}
-
-	/**
-	 * @brief Returns a card
-	 * @param integer $id
-	 * @return associative array
-	 */
-	public static function findCard($id){
-		$stmt = OC_DB::prepare( 'SELECT * FROM *PREFIX*contacts_cards WHERE id = ?' );
-		$result = $stmt->execute(array($id));
-
-		return $result->fetchRow();
-	}
-
-	/**
-	 * @brief finds a card by its DAV Data
-	 * @param integer $aid Addressbook id
-	 * @param string $uri the uri ('filename')
-	 * @return associative array
-	 */
-	public static function findCardWhereDAVDataIs($aid,$uri){
-		$stmt = OC_DB::prepare( 'SELECT * FROM *PREFIX*contacts_cards WHERE addressbookid = ? AND uri = ?' );
-		$result = $stmt->execute(array($aid,$uri));
-
-		return $result->fetchRow();
-	}
-
-	/**
-	 * @brief Adds a card
-	 * @param integer $id Addressbook id
-	 * @param string $data  vCard file
-	 * @return insertid
-	 */
-	public static function addCard($id,$data){
-		$fn = null;
-		$uri = null;
-
-		$card = self::parse($data);
-		if(!is_null($card)){
-			foreach($card->children as $property){
-				if($property->name == 'FN'){
-					$fn = $property->value;
-				}
-				elseif(is_null($uri) && $property->name == 'UID' ){
-					$uri = $property->value.'.vcf';
-				}
-			}
-			if(is_null($uri)){
-				$uid = self::createUID();
-				$uri = $uid.'.vcf';
-				$card->add(new Sabre_VObject_Property('UID',$uid));
-				$data = $card->serialize();
-			};
-		}
-		else{
-			// that's hard. Creating a UID and not saving it
-			$uid = self::createUID();
-			$uri = $uid.'.vcf';
-		};
-
-		$stmt = OC_DB::prepare( 'INSERT INTO *PREFIX*contacts_cards (addressbookid,fullname,carddata,uri,lastmodified) VALUES(?,?,?,?,?)' );
-		$result = $stmt->execute(array($id,$fn,$data,$uri,time()));
-
-		self::touchAddressbook($id);
-
-		return OC_DB::insertid();
-	}
-
-	/**
-	 * @brief Adds a card with the data provided by sabredav
-	 * @param integer $id Addressbook id
-	 * @param string $uri   the uri the card will have
-	 * @param string $data  vCard file
-	 * @return insertid
-	 */
-	public static function addCardFromDAVData($id,$uri,$data){
-		$fn = null;
-		$card = self::parse($data);
-		if(!is_null($card)){
-			foreach($card->children as $property){
-				if($property->name == 'FN'){
-					$fn = $property->value;
-				}
-			}
-		}
-
-		$stmt = OC_DB::prepare( 'INSERT INTO *PREFIX*contacts_cards (addressbookid,fullname,carddata,uri,lastmodified) VALUES(?,?,?,?,?)' );
-		$result = $stmt->execute(array($id,$fn,$data,$uri,time()));
-
-		self::touchAddressbook($id);
-
-		return OC_DB::insertid();
-	}
-
-	/**
-	 * @brief edits a card
-	 * @param integer $id id of card
-	 * @param string $data  vCard file
-	 * @return boolean
-	 */
-	public static function editCard($id, $data){
-		$oldcard = self::findCard($id);
-		$fn = null;
-
-		$card = self::parse($data);
-		if(!is_null($card)){
-			foreach($card->children as $property){
-				if($property->name == 'FN'){
-					$fn = $property->value;
-				}
-			}
+		$cards = OC_Contacts_VCard::all($id);
+		foreach($cards as $card){
+			OC_Contacts_VCard::delete($card['id']);
 		}
 
-		$stmt = OC_DB::prepare( 'UPDATE *PREFIX*contacts_cards SET fullname = ?,carddata = ?, lastmodified = ? WHERE id = ?' );
-		$result = $stmt->execute(array($fn,$data,time(),$id));
-
-		self::touchAddressbook($oldcard['addressbookid']);
-
 		return true;
 	}
 
 	/**
-	 * @brief edits a card with the data provided by sabredav
-	 * @param integer $id Addressbook id
-	 * @param string $uri   the uri of the card
-	 * @param string $data  vCard file
-	 * @return boolean
-	 */
-	public static function editCardFromDAVData($aid,$uri,$data){
-		$oldcard = self::findCardWhereDAVDataIs($aid,$uri);
-
-		$fn = null;
-		$card = self::parse($data);
-		if(!is_null($card)){
-			$card = Sabre_VObject_Reader::read($data);
-			foreach($card->children as $property){
-				if($property->name == 'FN'){
-					$fn = $property->value;
-				}
-			}
-		}
-
-		$stmt = OC_DB::prepare( 'UPDATE *PREFIX*contacts_cards SET fullname = ?,carddata = ?, lastmodified = ? WHERE id = ?' );
-		$result = $stmt->execute(array($fn,$data,time(),$oldcard['id']));
-
-		self::touchAddressbook($oldcard['addressbookid']);
-
-		return true;
-	}
-
-	/**
-	 * @brief deletes a card
-	 * @param integer $id id of card
+	 * @brief Updates ctag for addressbook
+	 * @param integer $id
 	 * @return boolean
 	 */
-	public static function deleteCard($id){
-		$stmt = OC_DB::prepare( 'DELETE FROM *PREFIX*contacts_cards WHERE id = ?' );
+	public static function touch($id){
+		$stmt = OC_DB::prepare( 'UPDATE *PREFIX*contacts_addressbooks SET ctag = ctag + 1 WHERE id = ?' );
 		$stmt->execute(array($id));
 
 		return true;
 	}
 
-	/**
-	 * @brief deletes a card with the data provided by sabredav
-	 * @param integer $aid Addressbook id
-	 * @param string $uri the uri of the card
-	 * @return boolean
-	 */
-	public static function deleteCardFromDAVData($aid,$uri){
-		$stmt = OC_DB::prepare( 'DELETE FROM *PREFIX*contacts_cards WHERE addressbookid = ? AND uri=?' );
-		$stmt->execute(array($aid,$uri));
-
-		return true;
-	}
-
 	/**
 	 * @brief Creates a URI for Addressbook
 	 * @param string $name name of the addressbook
@@ -386,14 +186,6 @@ class OC_Contacts_Addressbook{
 		return $newname;
 	}
 
-	/**
-	 * @brief Creates a UID
-	 * @return string
-	 */
-	public static function createUID(){
-		return substr(md5(rand().time()),0,10);
-	}
-
 	/**
 	 * @brief gets the userid from a principal path
 	 * @return string
@@ -402,108 +194,4 @@ class OC_Contacts_Addressbook{
 		list($prefix,$userid) = Sabre_DAV_URLUtil::splitPath($principaluri);
 		return $userid;
 	}
-
-	/**
-	 * @brief Escapes semicolons
-	 * @param string $value
-	 * @return string
-	 */
-	public static function escapeSemicolons($value){
-		foreach($value as &$i ){
-			$i = implode("\\\\;", explode(';', $i));
-		} unset($i);
-		return implode(';',$value);
-	}
-
-	/**
-	 * @brief Creates an array out of a multivalue property
-	 * @param string $value
-	 * @return array
-	 */
-	public static function unescapeSemicolons($value){
-		$array = explode(';',$value);
-		for($i=0;$i<count($array);$i++){
-			if(substr($array[$i],-2,2)=="\\\\"){
-				if(isset($array[$i+1])){
-					$array[$i] = substr($array[$i],0,count($array[$i])-2).';'.$array[$i+1];
-					unset($array[$i+1]);
-				}
-				else{
-					$array[$i] = substr($array[$i],0,count($array[$i])-2).';';
-				}
-				$i = $i - 1;
-			}
-		}
-		return $array;
-	}
-
-	/**
-	 * @brief Data structure of vCard
-	 * @param object $property
-	 * @return associative array
-	 *
-	 * look at code ...
-	 */
-	public static function structureContact($object){
-		$details = array();
-		foreach($object->children as $property){
-			$temp = self::structureProperty($property);
-			if(array_key_exists($property->name,$details)){
-				$details[$property->name][] = $temp;
-			}
-			else{
-				$details[$property->name] = array($temp);
-			}
-		}
-		return $details;
-	}
-
-	/**
-	 * @brief Data structure of properties
-	 * @param object $property
-	 * @return associative array
-	 *
-	 * returns an associative array with
-	 * ['name'] name of property
-	 * ['value'] htmlspecialchars escaped value of property
-	 * ['parameters'] associative array name=>value
-	 * ['checksum'] checksum of whole property
-	 */
-	public static function structureProperty($property){
-		$value = $property->value;
-		$value = htmlspecialchars($value);
-		if($property->name == 'ADR' || $property->name == 'N'){
-			$value = self::unescapeSemicolons($value);
-		}
-		$temp = array(
-			'name' => $property->name,
-			'value' => $value,
-			'parameters' => array(),
-			'checksum' => md5($property->serialize()));
-		foreach($property->parameters as $parameter){
-			// Faulty entries by kaddressbook
-			if($parameter->name == 'TYPE' && $parameter->value == 'PREF'){
-				$parameter->name = 'PREF';
-				$parameter->value = '1';
-			}
-			$temp['parameters'][$parameter->name] = $parameter->value;
-		}
-		return $temp;
-	}
-
-	/**
-	 * @brief Parses a vcard file
-	 * @param string vCard
-	 * @return Sabre_VObject or null
-	 *
-	 * Will retun the vobject if sabre DAV is able to parse the file.
-	 */
-	public static function parse($data){
-		try {
-			$card = Sabre_VObject_Reader::read($data);
-			return $card;
-		} catch (Exception $e) {
-			return null;
-		}
-	}
 }
diff --git a/apps/contacts/lib/connector_sabre.php b/apps/contacts/lib/connector_sabre.php
index 96a90dfc5deed343f5e43552d6934f67b8a4df39..c967e906601c2c10af30ab06932f5bd71d8146f8 100644
--- a/apps/contacts/lib/connector_sabre.php
+++ b/apps/contacts/lib/connector_sabre.php
@@ -31,9 +31,9 @@ class OC_Connector_Sabre_CardDAV extends Sabre_CardDAV_Backend_Abstract {
 	 * @return array
 	 */
 	public function getAddressBooksForUser($principaluri) {
-		$data = OC_Contacts_Addressbook::allAddressbooksWherePrincipalURIIs($principaluri);
+		$data = OC_Contacts_Addressbook::allWherePrincipalURIIs($principaluri);
 		$addressbooks = array();
-		
+
 		foreach($data as $i) {
 			$addressbooks[] = array(
 				'id'  => $i['id'],
@@ -79,7 +79,7 @@ class OC_Connector_Sabre_CardDAV extends Sabre_CardDAV_Backend_Abstract {
 			}
 		}
 
-		OC_Contacts_Addressbook::editAddressbook($addressbookid,$name,$description);
+		OC_Contacts_Addressbook::edit($addressbookid,$name,$description);
 
 		return true;
 
@@ -113,7 +113,7 @@ class OC_Connector_Sabre_CardDAV extends Sabre_CardDAV_Backend_Abstract {
 
 		}
 
-		OC_Contacts_Addressbook::addAddressbookFromDAVData($principaluri,$url,$name,$description);
+		OC_Contacts_Addressbook::addFromDAVData($principaluri,$url,$name,$description);
 	}
 
 	/**
@@ -123,7 +123,7 @@ class OC_Connector_Sabre_CardDAV extends Sabre_CardDAV_Backend_Abstract {
 	 * @return void
 	 */
 	public function deleteAddressBook($addressbookid) {
-		OC_Contacts_Addressbook::deleteAddressbook($addressbookid);
+		OC_Contacts_Addressbook::delete($addressbookid);
 	}
 
 	/**
@@ -133,7 +133,7 @@ class OC_Connector_Sabre_CardDAV extends Sabre_CardDAV_Backend_Abstract {
 	 * @return array
 	 */
 	public function getCards($addressbookid) {
-		$data = OC_Contacts_Addressbook::allCards($addressbookid);
+		$data = OC_Contacts_VCard::all($addressbookid);
 		$cards = array();
 		foreach($data as $i){
 			$cards[] = array(
@@ -145,7 +145,7 @@ class OC_Connector_Sabre_CardDAV extends Sabre_CardDAV_Backend_Abstract {
 
 		return $cards;
 	}
-	
+
 	/**
 	 * Returns a specfic card
 	 *
@@ -154,7 +154,7 @@ class OC_Connector_Sabre_CardDAV extends Sabre_CardDAV_Backend_Abstract {
 	 * @return array
 	 */
 	public function getCard($addressbookid, $carduri) {
-		return OC_Contacts_Addressbook::findCardWhereDAVDataIs($addressbookid,$carduri);
+		return OC_Contacts_VCard::findWhereDAVDataIs($addressbookid,$carduri);
 
 	}
 
@@ -167,7 +167,7 @@ class OC_Connector_Sabre_CardDAV extends Sabre_CardDAV_Backend_Abstract {
 	 * @return bool
 	 */
 	public function createCard($addressbookid, $carduri, $carddata) {
-		OC_Contacts_Addressbook::addCardFromDAVData($addressbookid, $carduri, $carddata);
+		OC_Contacts_VCard::addFromDAVData($addressbookid, $carduri, $carddata);
 		return true;
 	}
 
@@ -180,7 +180,7 @@ class OC_Connector_Sabre_CardDAV extends Sabre_CardDAV_Backend_Abstract {
 	 * @return bool
 	 */
 	public function updateCard($addressbookid, $carduri, $carddata) {
-		return OC_Contacts_Addressbook::editCardFromDAVData($addressbookid, $carduri, $carddata);
+		return OC_Contacts_VCard::editFromDAVData($addressbookid, $carduri, $carddata);
 	}
 
 	/**
@@ -191,6 +191,6 @@ class OC_Connector_Sabre_CardDAV extends Sabre_CardDAV_Backend_Abstract {
 	 * @return bool
 	 */
 	public function deleteCard($addressbookid, $carduri) {
-		return OC_Contacts_Addressbook::deleteCardFromDAVData($addressbookid, $carduri);
+		return OC_Contacts_VCard::deleteFromDAVData($addressbookid, $carduri);
 	}
 }
diff --git a/apps/contacts/lib/hooks.php b/apps/contacts/lib/hooks.php
index 70f1fe185187b1caceca034dede5466d547973f4..155cf40f914c5b65796c363ede154010dc6d985b 100644
--- a/apps/contacts/lib/hooks.php
+++ b/apps/contacts/lib/hooks.php
@@ -30,10 +30,10 @@ class OC_Contacts_Hooks{
 	 * @return array
 	 */
 	public function deleteUser($parameters) {
-		$addressbooks = OC_Contacts_Addressbook::allAddressbooks($parameters['uid']);
-		
+		$addressbooks = OC_Contacts_Addressbook::all($parameters['uid']);
+
 		foreach($addressbooks as $addressbook) {
-			OC_Contacts_Addressbook::deleteAddressbook($addressbook['id']);
+			OC_Contacts_Addressbook::delete($addressbook['id']);
 		}
 
 		return true;
diff --git a/apps/contacts/lib/vcard.php b/apps/contacts/lib/vcard.php
new file mode 100644
index 0000000000000000000000000000000000000000..1c9a8049f7310df62cc371ef2a00d343ca1fac74
--- /dev/null
+++ b/apps/contacts/lib/vcard.php
@@ -0,0 +1,344 @@
+<?php
+/**
+ * ownCloud - Addressbook
+ *
+ * @author Jakob Sack
+ * @copyright 2011 Jakob Sack mail@jakobsack.de
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+/*
+ *
+ * The following SQL statement is just a help for developers and will not be
+ * executed!
+ *
+ * CREATE TABLE contacts_cards (
+ * id INT(11) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
+ * addressbookid INT(11) UNSIGNED NOT NULL,
+ * fullname VARCHAR(255),
+ * carddata TEXT,
+ * uri VARCHAR(100),
+ * lastmodified INT(11) UNSIGNED
+ * );
+ */
+
+/**
+ * This class manages our vCards
+ */
+class OC_Contacts_VCard{
+	/**
+	 * @brief Returns all cards of an address book
+	 * @param integer $id
+	 * @return array
+	 *
+	 * The cards are associative arrays. You'll find the original vCard in
+	 * ['carddata']
+	 */
+	public static function all($id){
+		$stmt = OC_DB::prepare( 'SELECT * FROM *PREFIX*contacts_cards WHERE addressbookid = ?' );
+		$result = $stmt->execute(array($id));
+
+		$addressbooks = array();
+		while( $row = $result->fetchRow()){
+			$addressbooks[] = $row;
+		}
+
+		return $addressbooks;
+	}
+
+	/**
+	 * @brief Returns a card
+	 * @param integer $id
+	 * @return associative array
+	 */
+	public static function find($id){
+		$stmt = OC_DB::prepare( 'SELECT * FROM *PREFIX*contacts_cards WHERE id = ?' );
+		$result = $stmt->execute(array($id));
+
+		return $result->fetchRow();
+	}
+
+	/**
+	 * @brief finds a card by its DAV Data
+	 * @param integer $aid Addressbook id
+	 * @param string $uri the uri ('filename')
+	 * @return associative array
+	 */
+	public static function findWhereDAVDataIs($aid,$uri){
+		$stmt = OC_DB::prepare( 'SELECT * FROM *PREFIX*contacts_cards WHERE addressbookid = ? AND uri = ?' );
+		$result = $stmt->execute(array($aid,$uri));
+
+		return $result->fetchRow();
+	}
+
+	/**
+	 * @brief Adds a card
+	 * @param integer $id Addressbook id
+	 * @param string $data  vCard file
+	 * @return insertid
+	 */
+	public static function add($id,$data){
+		$fn = null;
+		$uri = null;
+
+		$card = self::parse($data);
+		if(!is_null($card)){
+			foreach($card->children as $property){
+				if($property->name == 'FN'){
+					$fn = $property->value;
+				}
+				elseif(is_null($uri) && $property->name == 'UID' ){
+					$uri = $property->value.'.vcf';
+				}
+			}
+			if(is_null($uri)){
+				$uid = self::createUID();
+				$uri = $uid.'.vcf';
+				$card->add(new Sabre_VObject_Property('UID',$uid));
+				$data = $card->serialize();
+			};
+		}
+		else{
+			// that's hard. Creating a UID and not saving it
+			$uid = self::createUID();
+			$uri = $uid.'.vcf';
+		};
+
+		$stmt = OC_DB::prepare( 'INSERT INTO *PREFIX*contacts_cards (addressbookid,fullname,carddata,uri,lastmodified) VALUES(?,?,?,?,?)' );
+		$result = $stmt->execute(array($id,$fn,$data,$uri,time()));
+
+		OC_Contacts_Addressbook::touch($id);
+
+		return OC_DB::insertid();
+	}
+
+	/**
+	 * @brief Adds a card with the data provided by sabredav
+	 * @param integer $id Addressbook id
+	 * @param string $uri   the uri the card will have
+	 * @param string $data  vCard file
+	 * @return insertid
+	 */
+	public static function addFromDAVData($id,$uri,$data){
+		$fn = null;
+		$card = self::parse($data);
+		if(!is_null($card)){
+			foreach($card->children as $property){
+				if($property->name == 'FN'){
+					$fn = $property->value;
+				}
+			}
+		}
+
+		$stmt = OC_DB::prepare( 'INSERT INTO *PREFIX*contacts_cards (addressbookid,fullname,carddata,uri,lastmodified) VALUES(?,?,?,?,?)' );
+		$result = $stmt->execute(array($id,$fn,$data,$uri,time()));
+
+		OC_Contacts_Addressbook::touch($id);
+
+		return OC_DB::insertid();
+	}
+
+	/**
+	 * @brief edits a card
+	 * @param integer $id id of card
+	 * @param string $data  vCard file
+	 * @return boolean
+	 */
+	public static function edit($id, $data){
+		$oldcard = self::find($id);
+		$fn = null;
+
+		$card = self::parse($data);
+		if(!is_null($card)){
+			foreach($card->children as $property){
+				if($property->name == 'FN'){
+					$fn = $property->value;
+				}
+			}
+		}
+
+		$stmt = OC_DB::prepare( 'UPDATE *PREFIX*contacts_cards SET fullname = ?,carddata = ?, lastmodified = ? WHERE id = ?' );
+		$result = $stmt->execute(array($fn,$data,time(),$id));
+
+		OC_Contacts_Addressbook::touch($oldcard['addressbookid']);
+
+		return true;
+	}
+
+	/**
+	 * @brief edits a card with the data provided by sabredav
+	 * @param integer $id Addressbook id
+	 * @param string $uri   the uri of the card
+	 * @param string $data  vCard file
+	 * @return boolean
+	 */
+	public static function editFromDAVData($aid,$uri,$data){
+		$oldcard = self::findWhereDAVDataIs($aid,$uri);
+
+		$fn = null;
+		$card = self::parse($data);
+		if(!is_null($card)){
+			foreach($card->children as $property){
+				if($property->name == 'FN'){
+					$fn = $property->value;
+				}
+			}
+		}
+
+		$stmt = OC_DB::prepare( 'UPDATE *PREFIX*contacts_cards SET fullname = ?,carddata = ?, lastmodified = ? WHERE id = ?' );
+		$result = $stmt->execute(array($fn,$data,time(),$oldcard['id']));
+
+		OC_Contacts_Addressbook::touch($oldcard['addressbookid']);
+
+		return true;
+	}
+
+	/**
+	 * @brief deletes a card
+	 * @param integer $id id of card
+	 * @return boolean
+	 */
+	public static function delete($id){
+		$stmt = OC_DB::prepare( 'DELETE FROM *PREFIX*contacts_cards WHERE id = ?' );
+		$stmt->execute(array($id));
+
+		return true;
+	}
+
+	/**
+	 * @brief Creates a UID
+	 * @return string
+	 */
+	public static function createUID(){
+		return substr(md5(rand().time()),0,10);
+	}
+
+	/**
+	 * @brief deletes a card with the data provided by sabredav
+	 * @param integer $aid Addressbook id
+	 * @param string $uri the uri of the card
+	 * @return boolean
+	 */
+	public static function deleteCardFromDAVData($aid,$uri){
+		$stmt = OC_DB::prepare( 'DELETE FROM *PREFIX*contacts_cards WHERE addressbookid = ? AND uri=?' );
+		$stmt->execute(array($aid,$uri));
+
+		return true;
+	}
+
+	/**
+	 * @brief Escapes semicolons
+	 * @param string $value
+	 * @return string
+	 */
+	public static function escapeSemicolons($value){
+		foreach($value as &$i ){
+			$i = implode("\\\\;", explode(';', $i));
+		} unset($i);
+		return implode(';',$value);
+	}
+
+	/**
+	 * @brief Creates an array out of a multivalue property
+	 * @param string $value
+	 * @return array
+	 */
+	public static function unescapeSemicolons($value){
+		$array = explode(';',$value);
+		for($i=0;$i<count($array);$i++){
+			if(substr($array[$i],-2,2)=="\\\\"){
+				if(isset($array[$i+1])){
+					$array[$i] = substr($array[$i],0,count($array[$i])-2).';'.$array[$i+1];
+					unset($array[$i+1]);
+				}
+				else{
+					$array[$i] = substr($array[$i],0,count($array[$i])-2).';';
+				}
+				$i = $i - 1;
+			}
+		}
+		return $array;
+	}
+
+	/**
+	 * @brief Data structure of vCard
+	 * @param object $property
+	 * @return associative array
+	 *
+	 * look at code ...
+	 */
+	public static function structureContact($object){
+		$details = array();
+		foreach($object->children as $property){
+			$temp = self::structureProperty($property);
+			if(array_key_exists($property->name,$details)){
+				$details[$property->name][] = $temp;
+			}
+			else{
+				$details[$property->name] = array($temp);
+			}
+		}
+		return $details;
+	}
+
+	/**
+	 * @brief Data structure of properties
+	 * @param object $property
+	 * @return associative array
+	 *
+	 * returns an associative array with
+	 * ['name'] name of property
+	 * ['value'] htmlspecialchars escaped value of property
+	 * ['parameters'] associative array name=>value
+	 * ['checksum'] checksum of whole property
+	 */
+	public static function structureProperty($property){
+		$value = $property->value;
+		$value = htmlspecialchars($value);
+		if($property->name == 'ADR' || $property->name == 'N'){
+			$value = self::unescapeSemicolons($value);
+		}
+		$temp = array(
+			'name' => $property->name,
+			'value' => $value,
+			'parameters' => array(),
+			'checksum' => md5($property->serialize()));
+		foreach($property->parameters as $parameter){
+			// Faulty entries by kaddressbook
+			if($parameter->name == 'TYPE' && $parameter->value == 'PREF'){
+				$parameter->name = 'PREF';
+				$parameter->value = '1';
+			}
+			$temp['parameters'][$parameter->name] = $parameter->value;
+		}
+		return $temp;
+	}
+
+	/**
+	 * @brief Parses a vcard file
+	 * @param string vCard
+	 * @return Sabre_VObject or null
+	 *
+	 * Will retun the vobject if sabre DAV is able to parse the file.
+	 */
+	public static function parse($data){
+		try {
+			$card = Sabre_VObject_Reader::read($data);
+			return $card;
+		} catch (Exception $e) {
+			return null;
+		}
+	}
+}
diff --git a/apps/contacts/photo.php b/apps/contacts/photo.php
index 62386421cdcff836cefe5c2464409ae7c6e7b2db..ac49d6c31a8d5b138c089ebe391be4f4a0fc46e8 100644
--- a/apps/contacts/photo.php
+++ b/apps/contacts/photo.php
@@ -34,20 +34,25 @@ if( !OC_User::isLoggedIn()){
 }
 
 
-$card = OC_Contacts_Addressbook::findCard( $id );
+$card = OC_Contacts_VCard::find( $id );
 if( $card === false ){
 	echo $l10n->t('Can not find Contact!');
 	exit();
 }
 
-$addressbook = OC_Contacts_Addressbook::findAddressbook( $card['addressbookid'] );
+$addressbook = OC_Contacts_Addressbook::find( $card['addressbookid'] );
 if( $addressbook === false || $addressbook['userid'] != OC_USER::getUser()){
 	echo $l10n->t('This is not your contact!');
 	exit();
 }
 
-$content = Sabre_VObject_Reader::read($card['carddata']);
+$content = OC_Contacts_Card::parse($card['carddata']);
 
+// invalid vcard
+if( is_null($content)){
+	echo $l10n->t('This card is not RFC compatible!');
+	exit();
+}
 // Photo :-)
 foreach($content->children as $child){
 	if($child->name == 'PHOTO'){