diff --git a/apps/contacts/ajax/activation.php b/apps/contacts/ajax/activation.php
index 74cb738ab8fccb39fce648f033d6692151442475..69173c54c44a4e04b13933beaf660939d0f7855a 100644
--- a/apps/contacts/ajax/activation.php
+++ b/apps/contacts/ajax/activation.php
@@ -16,8 +16,12 @@ $bookid = $_POST['bookid'];
 $book = OC_Contacts_App::getAddressbook($bookid);// is owner access check
 
 if(!OC_Contacts_Addressbook::setActive($bookid, $_POST['active'])) {
-	OCP\Util::writeLog('contacts','ajax/activation.php: Error activating addressbook: '.$bookid, OCP\Util::ERROR);
-	OCP\JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Error (de)activating addressbook.'))));
+	OCP\Util::writeLog('contacts',
+		'ajax/activation.php: Error activating addressbook: '. $bookid, 
+		OCP\Util::ERROR);
+	OCP\JSON::error(array(
+		'data' => array(
+			'message' => OC_Contacts_App::$l10n->t('Error (de)activating addressbook.'))));
 	exit();
 }
 
diff --git a/apps/contacts/ajax/addaddressbook.php b/apps/contacts/ajax/addaddressbook.php
index 3d7885fe468da9320d2c560d84e4902683cfa75d..40773704bb47da76bac054a49480ac0cdeb6833e 100644
--- a/apps/contacts/ajax/addaddressbook.php
+++ b/apps/contacts/ajax/addaddressbook.php
@@ -12,13 +12,15 @@
 OCP\JSON::checkLoggedIn();
 OCP\JSON::checkAppEnabled('contacts');
 OCP\JSON::callCheck();
-require_once('loghandler.php');
+require_once 'loghandler.php';
 
 debug('name: '.$_POST['name']);
 
 $userid = OCP\USER::getUser();
 $name = isset($_POST['name'])?trim(strip_tags($_POST['name'])):null;
-$description = isset($_POST['description'])?trim(strip_tags($_POST['description'])):null;
+$description = isset($_POST['description'])
+	? trim(strip_tags($_POST['description']))
+	: null;
 
 if(is_null($name)) {
 	bailOut('Cannot add addressbook with an empty name.');
diff --git a/apps/contacts/ajax/addcontact.php b/apps/contacts/ajax/addcontact.php
index 12f7bb9db969d705ac77fc6d8d4022ea1e0d39bc..6aaf5a9df35a6b7fca6f8a9ec5282ff25bff9dc2 100644
--- a/apps/contacts/ajax/addcontact.php
+++ b/apps/contacts/ajax/addcontact.php
@@ -37,13 +37,15 @@ $n = trim($_POST['n']);
 
 $vcard = new OC_VObject('VCARD');
 $vcard->setUID();
-$vcard->setString('FN',$fn);
-$vcard->setString('N',$n);
+$vcard->setString('FN', $fn);
+$vcard->setString('N', $n);
 
 $id = OC_Contacts_VCard::add($aid, $vcard, null, $isnew);
 if(!$id) {
-	OCP\JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('There was an error adding the contact.'))));
-	OCP\Util::writeLog('contacts','ajax/addcontact.php: Recieved non-positive ID on adding card: '.$id, OCP\Util::ERROR);
+	OCP\JSON::error(array(
+		'data' => array(
+			'message' => OC_Contacts_App::$l10n->t('There was an error adding the contact.'))));
+	OCP\Util::writeLog('contacts', 'ajax/addcontact.php: Recieved non-positive ID on adding card: '.$id, OCP\Util::ERROR);
 	exit();
 }
 
diff --git a/apps/contacts/ajax/addproperty.php b/apps/contacts/ajax/addproperty.php
index 1b6db0c8f81ac2b20e8ccbf4cec92e7623e74308..96f27b2b9bb51744e1816380423332af5413dc5e 100644
--- a/apps/contacts/ajax/addproperty.php
+++ b/apps/contacts/ajax/addproperty.php
@@ -25,7 +25,7 @@ OCP\JSON::checkLoggedIn();
 OCP\JSON::checkAppEnabled('contacts');
 OCP\JSON::callCheck();
 
-require_once('loghandler.php');
+require_once 'loghandler.php';
 
 $id = isset($_POST['id'])?$_POST['id']:null;
 $name = isset($_POST['name'])?$_POST['name']:null;
@@ -33,22 +33,26 @@ $value = isset($_POST['value'])?$_POST['value']:null;
 $parameters = isset($_POST['parameters'])?$_POST['parameters']:array();
 
 $vcard = OC_Contacts_App::getContactVCard($id);
+$l10n = OC_Contacts_App::$l10n;
 
 if(!$name) {
-	bailOut(OC_Contacts_App::$l10n->t('element name is not set.'));
+	bailOut($l10n->t('element name is not set.'));
 }
 if(!$id) {
-	bailOut(OC_Contacts_App::$l10n->t('id is not set.'));
+	bailOut($l10n->t('id is not set.'));
 }
 
 if(!$vcard) {
-	bailOut(OC_Contacts_App::$l10n->t('Could not parse contact: ').$id);
+	bailOut($l10n->t('Could not parse contact: ').$id);
 }
 
-if(!is_array($value)){
+if(!is_array($value)) {
 	$value = trim($value);
-	if(!$value && in_array($name, array('TEL', 'EMAIL', 'ORG', 'BDAY', 'URL', 'NICKNAME', 'NOTE'))) {
-		bailOut(OC_Contacts_App::$l10n->t('Cannot add empty property.'));
+	if(!$value && in_array(
+			$name, 
+			array('TEL', 'EMAIL', 'ORG', 'BDAY', 'URL', 'NICKNAME', 'NOTE'))
+		) {
+		bailOut($l10n->t('Cannot add empty property.'));
 	}
 } elseif($name === 'ADR') { // only add if non-empty elements.
 	$empty = true;
@@ -59,7 +63,7 @@ if(!is_array($value)){
 		}
 	}
 	if($empty) {
-		bailOut(OC_Contacts_App::$l10n->t('At least one of the address fields has to be filled out.'));
+		bailOut($l10n->t('At least one of the address fields has to be filled out.'));
 	}
 }
 
@@ -68,12 +72,14 @@ $current = $vcard->select($name);
 foreach($current as $item) {
 	$tmpvalue = (is_array($value)?implode(';', $value):$value);
 	if($tmpvalue == $item->value) {
-		bailOut(OC_Contacts_App::$l10n->t('Trying to add duplicate property: '.$name.': '.$tmpvalue));
+		bailOut($l10n->t('Trying to add duplicate property: '.$name.': '.$tmpvalue));
 	}
 }
 
 if(is_array($value)) {
-	ksort($value);  // NOTE: Important, otherwise the compound value will be set in the order the fields appear in the form!
+	// NOTE: Important, otherwise the compound value will 
+	// be set in the order the fields appear in the form!
+	ksort($value);  
 	$value = array_map('strip_tags', $value);
 } else {
 	$value = strip_tags($value);
@@ -116,24 +122,25 @@ switch($name) {
 
 $line = count($vcard->children) - 1;
 
-// Apparently Sabre_VObject_Parameter doesn't do well with multiple values or I don't know how to do it. Tanghus.
+// Apparently Sabre_VObject_Parameter doesn't do well with 
+// multiple values or I don't know how to do it. Tanghus.
 foreach ($parameters as $key=>$element) {
 	if(is_array($element) && strtoupper($key) == 'TYPE') { 
 		// NOTE: Maybe this doesn't only apply for TYPE?
 		// And it probably shouldn't be done here anyways :-/
-		foreach($element as $e){
+		foreach($element as $e) {
 			if($e != '' && !is_null($e)){
-				$vcard->children[$line]->parameters[] = new Sabre_VObject_Parameter($key,$e);
+				$vcard->children[$line]->parameters[] = new Sabre_VObject_Parameter($key, $e);
 			}
 		}
 	} else {
-			$vcard->children[$line]->parameters[] = new Sabre_VObject_Parameter($key,$element);
+			$vcard->children[$line]->parameters[] = new Sabre_VObject_Parameter($key, $element);
 	}
 }
 $checksum = md5($vcard->children[$line]->serialize());
 
-if(!OC_Contacts_VCard::edit($id,$vcard)) {
-	bailOut(OC_Contacts_App::$l10n->t('Error adding contact property: '.$name));
+if(!OC_Contacts_VCard::edit($id, $vcard)) {
+	bailOut($l10n->t('Error adding contact property: '.$name));
 }
 
 OCP\JSON::success(array('data' => array( 'checksum' => $checksum )));
diff --git a/apps/contacts/ajax/categories/categoriesfor.php b/apps/contacts/ajax/categories/categoriesfor.php
index 6b6fcad0ebb50a0b9f3629f478ccdccb75a411ed..8391b14b5450f7ab1db0face6bc40714510da632 100644
--- a/apps/contacts/ajax/categories/categoriesfor.php
+++ b/apps/contacts/ajax/categories/categoriesfor.php
@@ -12,16 +12,23 @@ OCP\JSON::checkAppEnabled('contacts');
 
 $id = isset($_GET['id'])?$_GET['id']:null;
 if(is_null($id)) {
-	OCP\JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('No ID provided'))));
+	OCP\JSON::error(array(
+		'data' => array(
+			'message' => OC_Contacts_App::$l10n->t('No ID provided'))));
 	exit();
 }
 $vcard = OC_Contacts_App::getContactVCard( $id );
 foreach($vcard->children as $property){
-	//OCP\Util::writeLog('contacts','ajax/categories/checksumfor.php: '.$property->name, OCP\Util::DEBUG);
 	if($property->name == 'CATEGORIES') {
 		$checksum = md5($property->serialize());
-		OCP\JSON::success(array('data' => array('value'=>$property->value, 'checksum'=>$checksum)));
+		OCP\JSON::success(array(
+			'data' => array(
+				'value' => $property->value, 
+				'checksum' => $checksum,
+				)));
 		exit();
 	}
 }
-OCP\JSON::error(array('data' => array('message' => OC_Contacts_App::$l10n->t('Error setting checksum.'))));
+OCP\JSON::error(array(
+	'data' => array(
+		'message' => OC_Contacts_App::$l10n->t('Error setting checksum.'))));
diff --git a/apps/contacts/ajax/categories/delete.php b/apps/contacts/ajax/categories/delete.php
index f53d852d603df7613d05f41c8f0c044e4a5977e1..bc9f3e14e876fd1598d87d205a0c961b115d733b 100644
--- a/apps/contacts/ajax/categories/delete.php
+++ b/apps/contacts/ajax/categories/delete.php
@@ -11,7 +11,7 @@ OCP\JSON::checkLoggedIn();
 OCP\JSON::checkAppEnabled('contacts');
 OCP\JSON::callCheck();
 
-require_once(__DIR__.'/../loghandler.php');
+require_once __DIR__.'/../loghandler.php';
 
 $categories = isset($_POST['categories'])?$_POST['categories']:null;
 
diff --git a/apps/contacts/ajax/contactdetails.php b/apps/contacts/ajax/contactdetails.php
index d438f708b46391baa6c61a49cc1af600cef575c0..27d7611ade904d33cab70f9a3aa5caf1fe3dba49 100644
--- a/apps/contacts/ajax/contactdetails.php
+++ b/apps/contacts/ajax/contactdetails.php
@@ -20,7 +20,7 @@
  *
  */
  
-require_once('loghandler.php');
+require_once 'loghandler.php';
 
 // Check if we are a user
 OCP\JSON::checkLoggedIn();
diff --git a/apps/contacts/ajax/createaddressbook.php b/apps/contacts/ajax/createaddressbook.php
index 2ec5f542bb39805cdc3c8944e6e670f2eebf06a3..8dbd63f6425deb10695c62e4891b05c83df61ec7 100644
--- a/apps/contacts/ajax/createaddressbook.php
+++ b/apps/contacts/ajax/createaddressbook.php
@@ -12,7 +12,7 @@
 OCP\JSON::checkLoggedIn();
 OCP\JSON::checkAppEnabled('contacts');
 OCP\JSON::callCheck();
-require_once('loghandler.php');
+require_once 'loghandler.php';
 
 $userid = OCP\USER::getUser();
 $name = trim(strip_tags($_POST['name']));
diff --git a/apps/contacts/ajax/currentphoto.php b/apps/contacts/ajax/currentphoto.php
index 8f60eca08ec43b8d0cdf9bf6648a2d851bf270b4..96080e661ef2012840e5cadce0801afbda2c3f05 100644
--- a/apps/contacts/ajax/currentphoto.php
+++ b/apps/contacts/ajax/currentphoto.php
@@ -24,7 +24,7 @@
 OCP\JSON::setContentTypeHeader('text/plain');
 OCP\JSON::checkLoggedIn();
 OCP\JSON::checkAppEnabled('contacts');
-require_once('loghandler.php');
+require_once 'loghandler.php';
 
 if (!isset($_GET['id'])) {
 	bailOut(OC_Contacts_App::$l10n->t('No contact ID was submitted.'));
diff --git a/apps/contacts/ajax/deletecard.php b/apps/contacts/ajax/deletecard.php
index 1161c18abda22808f022333d184846d9d310d4ce..9777046fc829585ad9dd8ad8e218cc7503d2378d 100644
--- a/apps/contacts/ajax/deletecard.php
+++ b/apps/contacts/ajax/deletecard.php
@@ -23,17 +23,7 @@
 OCP\JSON::checkLoggedIn();
 OCP\JSON::checkAppEnabled('contacts');
 OCP\JSON::callCheck();
-require_once('loghandler.php');
-
-// foreach($_SERVER as $key=>$value) {
-// 	OCP\Util::writeLog('contacts','ajax/saveproperty.php: _SERVER: '.$key.'=>'.$value, OCP\Util::DEBUG);
-// }
-// foreach($_POST as $key=>$value) {
-// 	debug($key.'=>'.print_r($value, true));
-// }
-// foreach($_GET as $key=>$value) {
-// 	debug($key.'=>'.print_r($value, true));
-// }
+require_once 'loghandler.php';
 
 $id = isset($_POST['id'])?$_POST['id']:null;
 if(!$id) {
diff --git a/apps/contacts/ajax/deleteproperty.php b/apps/contacts/ajax/deleteproperty.php
index 90e5e64903e5058e75fdec6479858be6d57ee3a8..6c81dc52b3809c1256e68f91187a5b4196885623 100644
--- a/apps/contacts/ajax/deleteproperty.php
+++ b/apps/contacts/ajax/deleteproperty.php
@@ -24,22 +24,23 @@
 OCP\JSON::checkLoggedIn();
 OCP\JSON::checkAppEnabled('contacts');
 OCP\JSON::callCheck();
-require_once('loghandler.php');
+require_once 'loghandler.php';
 
 $id = $_POST['id'];
 $checksum = $_POST['checksum'];
+$l10n = OC_Contacts_App::$l10n
 
 $vcard = OC_Contacts_App::getContactVCard( $id );
 $line = OC_Contacts_App::getPropertyLineByChecksum($vcard, $checksum);
-if(is_null($line)){
-	bailOut(OC_Contacts_App::$l10n->t('Information about vCard is incorrect. Please reload the page.'));
+if(is_null($line)) {
+	bailOut($l10n->t('Information about vCard is incorrect. Please reload the page.'));
 	exit();
 }
 
 unset($vcard->children[$line]);
 
-if(!OC_Contacts_VCard::edit($id,$vcard)) {
-	bailOut(OC_Contacts_App::$l10n->t('Error deleting contact property.'));
+if(!OC_Contacts_VCard::edit($id, $vcard)) {
+	bailOut($l10n->t('Error deleting contact property.'));
 }
 
 OCP\JSON::success(array('data' => array( 'id' => $id )));
diff --git a/apps/contacts/ajax/editaddress.php b/apps/contacts/ajax/editaddress.php
index 1eb9429d79c041cc94ae74512f4787eb9928a71e..b5e4b72ed57d85607d7ab05ad92c80d7c8954b58 100644
--- a/apps/contacts/ajax/editaddress.php
+++ b/apps/contacts/ajax/editaddress.php
@@ -34,8 +34,8 @@ if($checksum) {
 	$tmpl->assign('adr', $adr, false);
 }
 
-$tmpl->assign('id',$id);
-$tmpl->assign('adr_types',$adr_types);
+$tmpl->assign('id', $id);
+$tmpl->assign('adr_types', $adr_types);
 
 $page = $tmpl->fetchPage();
 OCP\JSON::success(array('data' => array('page'=>$page, 'checksum'=>$checksum)));
diff --git a/apps/contacts/ajax/editname.php b/apps/contacts/ajax/editname.php
index 9e7c090eeed6919ecbd1e41c5f7a62c48caed6e9..eb55634011df5b6ec00bc456bd7aaad17b2c3c9d 100644
--- a/apps/contacts/ajax/editname.php
+++ b/apps/contacts/ajax/editname.php
@@ -9,7 +9,7 @@
  
 OCP\JSON::checkLoggedIn();
 OCP\JSON::checkAppEnabled('contacts');
-require_once('loghandler.php');
+require_once 'loghandler.php';
 
 $tmpl = new OCP\Template("contacts", "part.edit_name_dialog");
 
@@ -25,8 +25,8 @@ if($id) {
 		}
 	}
 	$name = array_map('htmlspecialchars', $name['value']);
-	$tmpl->assign('name',$name, false);
-	$tmpl->assign('id',$id, false);
+	$tmpl->assign('name', $name, false);
+	$tmpl->assign('id', $id, false);
 } else {
 	bailOut(OC_Contacts_App::$l10n->t('Contact ID is missing.'));
 }
diff --git a/apps/contacts/ajax/loadcard.php b/apps/contacts/ajax/loadcard.php
index 1309faaa7a2a7a9a77beb6aa7713135eb3f3253e..75fe33ada6f06b520ebe6be694dfdda1b0d4bac9 100644
--- a/apps/contacts/ajax/loadcard.php
+++ b/apps/contacts/ajax/loadcard.php
@@ -30,20 +30,20 @@ $maxUploadFilesize = min($upload_max_filesize, $post_max_size);
 $requesttoken = $_GET['requesttoken'];
 
 $freeSpace=OC_Filesystem::free_space('/');
-$freeSpace=max($freeSpace,0);
-$maxUploadFilesize = min($maxUploadFilesize ,$freeSpace);
+$freeSpace=max($freeSpace, 0);
+$maxUploadFilesize = min($maxUploadFilesize, $freeSpace);
 $adr_types = OC_Contacts_App::getTypesOfProperty('ADR');
 $phone_types = OC_Contacts_App::getTypesOfProperty('TEL');
 $email_types = OC_Contacts_App::getTypesOfProperty('EMAIL');
 
-$tmpl = new OCP\Template('contacts','part.contact');
+$tmpl = new OCP\Template('contacts', 'part.contact');
 $tmpl->assign('uploadMaxFilesize', $maxUploadFilesize);
 $tmpl->assign('uploadMaxHumanFilesize', OCP\Util::humanFileSize($maxUploadFilesize));
-$tmpl->assign('adr_types',$adr_types);
-$tmpl->assign('phone_types',$phone_types);
-$tmpl->assign('email_types',$email_types);
+$tmpl->assign('adr_types', $adr_types);
+$tmpl->assign('phone_types', $phone_types);
+$tmpl->assign('email_types', $email_types);
 $tmpl->assign('requesttoken', $requesttoken);
-$tmpl->assign('id','');
+$tmpl->assign('id', '');
 $page = $tmpl->fetchPage();
 
 OCP\JSON::success(array('data' => array( 'page' => $page )));
diff --git a/apps/contacts/ajax/loadintro.php b/apps/contacts/ajax/loadintro.php
index 6e8fcc4b04903769f8b41374263ca921af2c5391..1da08950ca0d001618aaf6d568dad8cf80cabd6f 100644
--- a/apps/contacts/ajax/loadintro.php
+++ b/apps/contacts/ajax/loadintro.php
@@ -25,7 +25,7 @@ OCP\JSON::checkLoggedIn();
 OCP\JSON::checkAppEnabled('contacts');
 
 
-$tmpl = new OCP\Template('contacts','part.no_contacts');
+$tmpl = new OCP\Template('contacts', 'part.no_contacts');
 $page = $tmpl->fetchPage();
 
 OCP\JSON::success(array('data' => array( 'page' => $page )));
diff --git a/apps/contacts/ajax/loadphoto.php b/apps/contacts/ajax/loadphoto.php
index a35631055eba7f82b657c49b13c761888f2d0eb1..be924b5db4d6c1cac7db4a1949564c7639b4ef01 100644
--- a/apps/contacts/ajax/loadphoto.php
+++ b/apps/contacts/ajax/loadphoto.php
@@ -24,7 +24,7 @@
 OCP\JSON::checkLoggedIn();
 OCP\JSON::checkAppEnabled('contacts');
 
-require_once('loghandler.php');
+require_once 'loghandler.php';
 
 $id = isset($_GET['id']) ? $_GET['id'] : '';
 $refresh = isset($_GET['refresh']) ? true : false;
diff --git a/apps/contacts/ajax/loghandler.php b/apps/contacts/ajax/loghandler.php
index 831b2e50c1eb7639601d5e779ba0868ecb454c2b..be4b98c111221eddf4683d629bf05e49fe1ba4a1 100644
--- a/apps/contacts/ajax/loghandler.php
+++ b/apps/contacts/ajax/loghandler.php
@@ -20,13 +20,15 @@
  *
  */
 
-function bailOut($msg, $tracelevel=1, $debuglevel=OCP\Util::ERROR) {
+function bailOut($msg, $tracelevel=1, $debuglevel=OCP\Util::ERROR) 
+{
 	OCP\JSON::error(array('data' => array('message' => $msg)));
 	debug($msg, $tracelevel, $debuglevel);
 	exit();
 }
 
-function debug($msg, $tracelevel=0, $debuglevel=OCP\Util::DEBUG) {
+function debug($msg, $tracelevel=0, $debuglevel=OCP\Util::DEBUG) 
+{
 	if(PHP_VERSION >= "5.4") {
 		$call = debug_backtrace(false, $tracelevel+1);
 	} else {
@@ -35,6 +37,8 @@ function debug($msg, $tracelevel=0, $debuglevel=OCP\Util::DEBUG) {
 	error_log('trace: '.print_r($call, true));
 	$call = $call[$tracelevel];
 	if($debuglevel !== false) {
-		OCP\Util::writeLog('contacts', $call['file'].'. Line: '.$call['line'].': '.$msg, $debuglevel);
+		OCP\Util::writeLog('contacts', 
+			$call['file'].'. Line: '.$call['line'].': '.$msg, 
+			$debuglevel);
 	}
 }
diff --git a/apps/contacts/ajax/oc_photo.php b/apps/contacts/ajax/oc_photo.php
index 710179fffcc2f305a3301102935cd71ac1e1bd1d..fe37b530f82501ee26bc98044083b5c1e072ad0f 100644
--- a/apps/contacts/ajax/oc_photo.php
+++ b/apps/contacts/ajax/oc_photo.php
@@ -22,7 +22,7 @@
 // Check if we are a user
 OCP\JSON::checkLoggedIn();
 OCP\JSON::checkAppEnabled('contacts');
-require_once('loghandler.php');
+require_once 'loghandler.php';
 
 if(!isset($_GET['id'])) {
 	bailOut(OC_Contacts_App::$l10n->t('No contact ID was submitted.'));
@@ -50,7 +50,9 @@ if($image->width() > 400 || $image->height() > 400) {
 	$image->resize(400); // Prettier resizing than with browser and saves bandwidth.
 }
 if(!$image->fixOrientation()) { // No fatal error so we don't bail out.
-	OCP\Util::writeLog('contacts','ajax/oc_photo.php: Couldn\'t save correct image orientation: '.$localpath, OCP\Util::DEBUG);
+	OCP\Util::writeLog('contacts', 
+		'ajax/oc_photo.php: Couldn\'t save correct image orientation: '.$localpath, 
+		OCP\Util::DEBUG);
 }
 if(OC_Cache::set($tmpkey, $image->data(), 600)) {
 	OCP\JSON::success(array('data' => array('id'=>$_GET['id'], 'tmp'=>$tmpkey)));
diff --git a/apps/contacts/ajax/savecrop.php b/apps/contacts/ajax/savecrop.php
index adce6be3b39fa2755a9594a902df6168373e3fd5..3958af5c07c6db592573d792cb4367a449d6bd05 100644
--- a/apps/contacts/ajax/savecrop.php
+++ b/apps/contacts/ajax/savecrop.php
@@ -27,7 +27,7 @@ OCP\JSON::callCheck();
 // Firefox and Konqueror tries to download application/json for me.  --Arthur
 OCP\JSON::setContentTypeHeader('text/plain');
 
-require_once('loghandler.php');
+require_once 'loghandler.php';
 
 $image = null;
 
@@ -48,7 +48,7 @@ if($id == '') {
 	bailOut('Missing contact id.');
 }
 
-OCP\Util::writeLog('contacts','savecrop.php: key: '.$tmpkey, OCP\Util::DEBUG);
+OCP\Util::writeLog('contacts', 'savecrop.php: key: '.$tmpkey, OCP\Util::DEBUG);
 
 $data = OC_Cache::get($tmpkey);
 if($data) {
@@ -56,7 +56,9 @@ if($data) {
 	if($image->loadFromdata($data)) {
 		$w = ($w != -1 ? $w : $image->width());
 		$h = ($h != -1 ? $h : $image->height());
-		OCP\Util::writeLog('contacts','savecrop.php, x: '.$x1.' y: '.$y1.' w: '.$w.' h: '.$h, OCP\Util::DEBUG);
+		OCP\Util::writeLog('contacts',
+			'savecrop.php, x: '.$x1.' y: '.$y1.' w: '.$w.' h: '.$h, 
+			OCP\Util::DEBUG);
 		if($image->crop($x1, $y1, $w, $h)) {
 			if(($image->width() <= 200 && $image->height() <= 200) || $image->resize(200)) {
 				$card = OC_Contacts_App::getContactVCard($id);
@@ -65,7 +67,9 @@ if($data) {
 					bailOut(OC_Contacts_App::$l10n->t('Error getting contact object.'));
 				}
 				if($card->__isset('PHOTO')) {
-					OCP\Util::writeLog('contacts','savecrop.php: PHOTO property exists.', OCP\Util::DEBUG);
+					OCP\Util::writeLog('contacts',
+						'savecrop.php: PHOTO property exists.', 
+						OCP\Util::DEBUG);
 					$property = $card->__get('PHOTO');
 					if(!$property) {
 						OC_Cache::remove($tmpkey);
@@ -76,8 +80,12 @@ if($data) {
 					$property->parameters[] = new Sabre_VObject_Parameter('TYPE', $image->mimeType());
 					$card->__set('PHOTO', $property);
 				} else {
-					OCP\Util::writeLog('contacts','savecrop.php: files: Adding PHOTO property.', OCP\Util::DEBUG);
-					$card->addProperty('PHOTO', $image->__toString(), array('ENCODING' => 'b', 'TYPE' => $image->mimeType()));
+					OCP\Util::writeLog('contacts',
+						'savecrop.php: files: Adding PHOTO property.', 
+						OCP\Util::DEBUG);
+					$card->addProperty('PHOTO', 
+						$image->__toString(), array('ENCODING' => 'b', 
+						'TYPE' => $image->mimeType()));
 				}
 				$now = new DateTime;
 				$card->setString('REV', $now->format(DateTime::W3C));
diff --git a/apps/contacts/ajax/saveproperty.php b/apps/contacts/ajax/saveproperty.php
index 5a0a7c14882f2212747299d5dbff5664764b972b..c3aaf5a95965740cf43e846dd21e8319f7b699b8 100644
--- a/apps/contacts/ajax/saveproperty.php
+++ b/apps/contacts/ajax/saveproperty.php
@@ -19,7 +19,7 @@
  * License along with this library.  If not, see <http://www.gnu.org/licenses/>.
  *
  */
-require_once('loghandler.php');
+require_once 'loghandler.php';
 // Check if we are a user
 OCP\JSON::checkLoggedIn();
 OCP\JSON::checkAppEnabled('contacts');
@@ -39,9 +39,11 @@ if(!$id) {
 if(!$checksum) {
 	bailOut(OC_Contacts_App::$l10n->t('checksum is not set.'));
 }
-if(is_array($value)){
+if(is_array($value)) {
 	$value = array_map('strip_tags', $value);
-	ksort($value); // NOTE: Important, otherwise the compound value will be set in the order the fields appear in the form!
+	// NOTE: Important, otherwise the compound value will be 
+	// set in the order the fields appear in the form!
+	ksort($value); 
 	//if($name == 'CATEGORIES') {
 	//	$value = OC_Contacts_VCard::escapeDelimiters($value, ',');
 	//} else {
diff --git a/apps/contacts/ajax/updateaddressbook.php b/apps/contacts/ajax/updateaddressbook.php
index d3a772c727f71a6dd3b913caa66f5ee6ffbfbf85..a14b215843144bc105203c45bd49bcac4ad96156 100644
--- a/apps/contacts/ajax/updateaddressbook.php
+++ b/apps/contacts/ajax/updateaddressbook.php
@@ -11,7 +11,7 @@
 // Check if we are a user
 OCP\JSON::checkLoggedIn();
 OCP\JSON::checkAppEnabled('contacts');
-require_once('loghandler.php');
+require_once 'loghandler.php';
 
 $bookid = $_POST['id'];
 OC_Contacts_App::getAddressbook($bookid); // is owner access check
diff --git a/apps/contacts/ajax/uploadimport.php b/apps/contacts/ajax/uploadimport.php
index 3c5a2d750ed32914590e212a17c73a49f10bdf4a..9fb271f54e8c138d964b05e0bd3f19a10961184d 100644
--- a/apps/contacts/ajax/uploadimport.php
+++ b/apps/contacts/ajax/uploadimport.php
@@ -24,7 +24,9 @@
 OCP\JSON::checkLoggedIn();
 OCP\JSON::checkAppEnabled('contacts');
 OCP\JSON::callCheck();
-require_once('loghandler.php');
+require_once 'loghandler.php';
+
+$l10n = OC_Contacts_App::$l10n
 
 $view = OCP\Files::getStorage('contacts');
 if(!$view->file_exists('imports')) {
@@ -39,25 +41,29 @@ if($fn) {
 		OCP\JSON::success(array('data' => array('file'=>$tmpfile, 'name'=>$fn)));
 		exit();
 	} else {
-		bailOut(OC_Contacts_App::$l10n->t('Error uploading contacts to storage.'));
+		bailOut($l10n->t('Error uploading contacts to storage.'));
 	}
 }
 
 // File input transfers are handled here
 if (!isset($_FILES['importfile'])) {
-	OCP\Util::writeLog('contacts','ajax/uploadphoto.php: No file was uploaded. Unknown error.', OCP\Util::DEBUG);
-	OCP\JSON::error(array('data' => array( 'message' => 'No file was uploaded. Unknown error' )));
+	OCP\Util::writeLog('contacts',
+		'ajax/uploadphoto.php: No file was uploaded. Unknown error.', 
+		OCP\Util::DEBUG);
+	OCP\JSON::error(array('
+		data' => array(
+			'message' => 'No file was uploaded. Unknown error' )));
 	exit();
 }
 $error = $_FILES['importfile']['error'];
 if($error !== UPLOAD_ERR_OK) {
 	$errors = array(
-		0=>OC_Contacts_App::$l10n->t("There is no error, the file uploaded with success"),
-		1=>OC_Contacts_App::$l10n->t("The uploaded file exceeds the upload_max_filesize directive in php.ini").ini_get('upload_max_filesize'),
-		2=>OC_Contacts_App::$l10n->t("The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form"),
-		3=>OC_Contacts_App::$l10n->t("The uploaded file was only partially uploaded"),
-		4=>OC_Contacts_App::$l10n->t("No file was uploaded"),
-		6=>OC_Contacts_App::$l10n->t("Missing a temporary folder")
+		0=>$l10n->t("There is no error, the file uploaded with success"),
+		1=>$l10n->t("The uploaded file exceeds the upload_max_filesize directive in php.ini").ini_get('upload_max_filesize'),
+		2=>$l10n->t("The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form"),
+		3=>$l10n->t("The uploaded file was only partially uploaded"),
+		4=>$l10n->t("No file was uploaded"),
+		6=>$l10n->t("Missing a temporary folder")
 	);
 	bailOut($errors[$error]);
 }
@@ -67,7 +73,7 @@ if(file_exists($file['tmp_name'])) {
 	if($view->file_put_contents('/imports/'.$file['name'], file_get_contents($file['tmp_name']))) {
 		OCP\JSON::success(array('data' => array('file'=>$file['name'], 'name'=>$file['name'])));
 	} else {
-		bailOut(OC_Contacts_App::$l10n->t('Error uploading contacts to storage.'));
+		bailOut($l10n->t('Error uploading contacts to storage.'));
 	}
 } else {
 	bailOut('Temporary file: \''.$file['tmp_name'].'\' has gone AWOL?');
diff --git a/apps/contacts/ajax/uploadphoto.php b/apps/contacts/ajax/uploadphoto.php
index 6bb3fe8a5e0d125ce8fc5fdca278c42fbb86a58b..4cd38db8c72a8407e917ec455a4303806ad0119f 100644
--- a/apps/contacts/ajax/uploadphoto.php
+++ b/apps/contacts/ajax/uploadphoto.php
@@ -27,13 +27,13 @@ OCP\JSON::callCheck();
 
 // Firefox and Konqueror tries to download application/json for me.  --Arthur
 OCP\JSON::setContentTypeHeader('text/plain');
-require_once('loghandler.php');
-
+require_once 'loghandler.php';
+$l10n = OC_Contacts_App::$l10n;
 // If it is a Drag'n'Drop transfer it's handled here.
 $fn = (isset($_SERVER['HTTP_X_FILE_NAME']) ? $_SERVER['HTTP_X_FILE_NAME'] : false);
 if ($fn) {
 	if (!isset($_GET['id'])) {
-		bailOut(OC_Contacts_App::$l10n->t('No contact ID was submitted.'));
+		bailOut($l10n->t('No contact ID was submitted.'));
 	}
 	$id = $_GET['id'];
 	$tmpkey = 'contact-photo-'.md5($fn);
@@ -48,33 +48,38 @@ if ($fn) {
 			debug('Couldn\'t save correct image orientation: '.$tmpkey);
 		}
 		if(OC_Cache::set($tmpkey, $image->data(), 600)) {
-			OCP\JSON::success(array('data' => array('mime'=>$_SERVER['CONTENT_TYPE'], 'name'=>$fn, 'id'=>$id, 'tmp'=>$tmpkey)));
+			OCP\JSON::success(array(
+				'data' => array(
+					'mime'=>$_SERVER['CONTENT_TYPE'], 
+					'name'=>$fn, 
+					'id'=>$id, 
+					'tmp'=>$tmpkey)));
 			exit();
 		} else {
-			bailOut(OC_Contacts_App::$l10n->t('Couldn\'t save temporary image: ').$tmpkey);
+			bailOut($l10n->t('Couldn\'t save temporary image: ').$tmpkey);
 		}
 	} else {
-		bailOut(OC_Contacts_App::$l10n->t('Couldn\'t load temporary image: ').$tmpkey);
+		bailOut($l10n->t('Couldn\'t load temporary image: ').$tmpkey);
 	}
 }
 
 // Uploads from file dialog are handled here.
 if (!isset($_POST['id'])) {
-	bailOut(OC_Contacts_App::$l10n->t('No contact ID was submitted.'));
+	bailOut($l10n->t('No contact ID was submitted.'));
 }
 if (!isset($_FILES['imagefile'])) {
-	bailOut(OC_Contacts_App::$l10n->t('No file was uploaded. Unknown error'));
+	bailOut($l10n->t('No file was uploaded. Unknown error'));
 }
 
 $error = $_FILES['imagefile']['error'];
 if($error !== UPLOAD_ERR_OK) {
 	$errors = array(
-		0=>OC_Contacts_App::$l10n->t("There is no error, the file uploaded with success"),
-		1=>OC_Contacts_App::$l10n->t("The uploaded file exceeds the upload_max_filesize directive in php.ini").ini_get('upload_max_filesize'),
-		2=>OC_Contacts_App::$l10n->t("The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form"),
-		3=>OC_Contacts_App::$l10n->t("The uploaded file was only partially uploaded"),
-		4=>OC_Contacts_App::$l10n->t("No file was uploaded"),
-		6=>OC_Contacts_App::$l10n->t("Missing a temporary folder")
+		0=>$l10n->t("There is no error, the file uploaded with success"),
+		1=>$l10n->t("The uploaded file exceeds the upload_max_filesize directive in php.ini").ini_get('upload_max_filesize'),
+		2=>$l10n->t("The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form"),
+		3=>$l10n->t("The uploaded file was only partially uploaded"),
+		4=>$l10n->t("No file was uploaded"),
+		6=>$l10n->t("Missing a temporary folder")
 	);
 	bailOut($errors[$error]);
 }
@@ -91,13 +96,20 @@ if(file_exists($file['tmp_name'])) {
 			debug('Couldn\'t save correct image orientation: '.$tmpkey);
 		}
 		if(OC_Cache::set($tmpkey, $image->data(), 600)) {
-			OCP\JSON::success(array('data' => array('mime'=>$file['type'],'size'=>$file['size'],'name'=>$file['name'], 'id'=>$_POST['id'], 'tmp'=>$tmpkey)));
+			OCP\JSON::success(array(
+				'data' => array(
+					'mime'=>$file['type'],
+					'size'=>$file['size'],
+					'name'=>$file['name'], 
+					'id'=>$_POST['id'], 
+					'tmp'=>$tmpkey,
+					)));
 			exit();
 		} else {
-			bailOut(OC_Contacts_App::$l10n->t('Couldn\'t save temporary image: ').$tmpkey);
+			bailOut($l10n->t('Couldn\'t save temporary image: ').$tmpkey);
 		}
 	} else {
-		bailOut(OC_Contacts_App::$l10n->t('Couldn\'t load temporary image: ').$file['tmp_name']);
+		bailOut($l10n->t('Couldn\'t load temporary image: ').$file['tmp_name']);
 	}
 } else {
 	bailOut('Temporary file: \''.$file['tmp_name'].'\' has gone AWOL?');