diff --git a/includes/main/WebUI.php b/includes/main/WebUI.php
index 6d51fff536e38eb83f028d777cada776ba8f953a..026c7a32749c7a18a8c4a22bfd8dea39449fe510 100644
--- a/includes/main/WebUI.php
+++ b/includes/main/WebUI.php
@@ -66,7 +66,7 @@ class Vtiger_WebUI extends Vtiger_EntryPoint {
 			$handler->checkPermission($request);
 			return;
 		}
-		throw new AppException(vtranslate($moduleName).' '.vtranslate('LBL_NOT_ACCESSIBLE'));
+		throw new AppException(vtranslate($moduleName, $moduleName).' '.vtranslate('LBL_NOT_ACCESSIBLE'));
 	}
 
 	protected function triggerPreProcess($handler, $request) {
diff --git a/layouts/v7/modules/Reports/ScheduleReport.tpl b/layouts/v7/modules/Reports/ScheduleReport.tpl
index fbf5be99ab335cb8c80f2518445c10c712cc9d2f..d60695a0c3015664f520dd5150a29772ab475006 100644
--- a/layouts/v7/modules/Reports/ScheduleReport.tpl
+++ b/layouts/v7/modules/Reports/ScheduleReport.tpl
@@ -163,11 +163,11 @@
                 </div>
             {/if}
             {if $SCHEDULEDREPORTS->get('next_trigger_time')}
-                <div class="col-lg-12">
+                <div class="col-lg-12" style="padding:5px 0px 10px 0px;">
                     <div class='col-lg-3'>
                         <span class=''>{vtranslate('LBL_NEXT_TRIGGER_TIME', $MODULE)}</span>
                     </div>
-                    <div class='span'>
+                    <div class='col-lg-5'>
                         {$SCHEDULEDREPORTS->getNextTriggerTimeInUserFormat()}<span>&nbsp;({$CURRENT_USER->time_zone})</span>
                     </div>
                 </div>
diff --git a/layouts/v7/modules/Settings/Workflows/resources/Edit.js b/layouts/v7/modules/Settings/Workflows/resources/Edit.js
index b35855d0a5e6b0fed08019f25cc8611d3098f327..1a9aa44eded101ed7458d32472b0392a39d0e7f8 100644
--- a/layouts/v7/modules/Settings/Workflows/resources/Edit.js
+++ b/layouts/v7/modules/Settings/Workflows/resources/Edit.js
@@ -888,6 +888,9 @@ Settings_Vtiger_Edit_Js("Settings_Workflows_Edit_Js", {
       var taskType = jQuery('#taskType').val();
       if (taskType == "VTUpdateFieldsTask") {
          fieldValueMappingKey = fieldInfo.workflow_columnname;
+		 if (fieldValueMappingKey === undefined || fieldValueMappingKey === null){
+			fieldValueMappingKey = selectedOption.val();
+		 }
       }
       if (fieldValueMapping != '' && typeof fieldValueMapping[fieldValueMappingKey] != 'undefined') {
          fieldInfo.value = fieldValueMapping[fieldValueMappingKey]['value'];
@@ -896,7 +899,7 @@ Settings_Vtiger_Edit_Js("Settings_Workflows_Edit_Js", {
          fieldInfo.workflow_valuetype = 'rawtext';
       }
       
-      if( fieldInfo.type == 'reference') {
+      if(fieldInfo.type == 'reference' || fieldInfo.type == 'multireference') {
           fieldInfo.referenceLabel = fieldUiHolder.find('[name="referenceValueLabel"]').val();
           fieldInfo.type = 'string';
       }
diff --git a/layouts/v7/resources/Images/vtiger.png b/layouts/v7/resources/Images/vtiger.png
new file mode 100644
index 0000000000000000000000000000000000000000..2890f8fda0098d1f5ea78b757a2b2cadbacc5ddf
Binary files /dev/null and b/layouts/v7/resources/Images/vtiger.png differ
diff --git a/modules/Migration/schema/660_to_700.php b/modules/Migration/schema/660_to_700.php
index 37938e38e16e3254633e7ae4479d5e2a089f9cb6..6c2c8c4ff54bc11ed45462f768f2e77d5512b075 100644
--- a/modules/Migration/schema/660_to_700.php
+++ b/modules/Migration/schema/660_to_700.php
@@ -26,13 +26,39 @@ if(defined('VTIGER_UPGRADE')) {
 		$db->pquery('ALTER TABLE vtiger_crmentity ADD COLUMN smgroupid INT(19)', array());
 	}
 
+	require_once 'modules/com_vtiger_workflow/VTWorkflowManager.inc';
+	$result = $db->pquery('SELECT DISTINCT workflow_id FROM com_vtiger_workflows WHERE summary=?', array('Ticket Creation From Portal : Send Email to Record Owner and Contact'));
+	if ($db->num_rows($result)) {
+		$wfs = new VTWorkflowManager($db);
+		$workflowModel = $wfs->retrieve($db->query_result($result, 0, 'workflow_id'));
+
+		$selectedFields = array();
+		$conditions = Zend_Json::decode(html_entity_decode($workflowModel->test));
+		if ($conditions) {
+			foreach ($conditions as $conditionKey => $condition) {
+				if ($condition['fieldname'] == 'from_portal') {
+					$selectedFieldKeys[] = $conditionKey;
+				}
+			}
+			foreach ($selectedFieldKeys as $key => $conditionKey) {
+				if ($key) {
+					unset($conditions[$conditionKey]);
+				}
+			}
+			$workflowModel->name = $workflowModel->description;
+			$workflowModel->test = Zend_Json::encode($conditions);
+			$wfs->save($workflowModel);
+		}
+	}
+
+	$db->pquery('UPDATE vtiger_def_org_share SET editstatus=? WHERE tabid=?', array(0, getTabid('Contacts')));
 	$db->pquery('UPDATE vtiger_field SET presence=0 WHERE columnname=? AND fieldname=?', array('emailoptout', 'emailoptout'));
 	$db->pquery('UPDATE vtiger_settings_field SET name=? WHERE name=?', array('Configuration Editor', 'LBL_CONFIG_EDITOR'));
 	$db->pquery('UPDATE vtiger_links SET linktype=? WHERE linklabel=?', array('DETAILVIEW', 'LBL_SHOW_ACCOUNT_HIERARCHY'));
-	$db->pquery('UPDATE vtiger_field SET defaultvalue=? WHERE fieldname=?', array('1', 'discontinued'));
 	$db->pquery('UPDATE vtiger_field SET typeofdata=? WHERE fieldname IN (?, ?)', array('DT~O', 'createdtime', 'modifiedtime'));
-	$db->pquery('UPDATE vtiger_field SET defaultvalue=? WHERE fieldname=?', array('.','currency_decimal_separator'));
-	$db->pquery('UPDATE vtiger_field SET defaultvalue=? WHERE fieldname=?', array(',','currency_grouping_separator'));
+	$db->pquery('UPDATE vtiger_field SET defaultvalue=? WHERE fieldname=?', array('1', 'discontinued'));
+	$db->pquery('UPDATE vtiger_field SET defaultvalue=? WHERE fieldname=?', array('.', 'currency_decimal_separator'));
+	$db->pquery('UPDATE vtiger_field SET defaultvalue=? WHERE fieldname=?', array(',', 'currency_grouping_separator'));
 
 	$lineItemModules = array('Products' => 'vtiger_products', 'Services' => 'vtiger_service');
 	foreach ($lineItemModules as $moduleName => $tableName) {
@@ -57,7 +83,7 @@ if(defined('VTIGER_UPGRADE')) {
 	}
 
 	$documentsModuleModel = Vtiger_Module_Model::getInstance('Documents');
-	$noteContentFieldModel = Vtiger_Field_Model::getInstance('notecontent', $userModuleModel);
+	$noteContentFieldModel = Vtiger_Field_Model::getInstance('notecontent', $documentsModuleModel);
 	if ($noteContentFieldModel) {
 		$noteContentFieldModel->set('masseditable', '0');
 		$noteContentFieldModel->save();
@@ -428,19 +454,19 @@ if(defined('VTIGER_UPGRADE')) {
 		$body = '<p>$invitee_name$,<br/><br/>' .
 				vtranslate('LBL_ACTIVITY_INVITATION', $moduleName).'<br/><br/>' .
 				vtranslate('LBL_DETAILS_STRING', $moduleName).' :<br/>
-						&nbsp; '.vtranslate('Subject', $moduleName).' : $events-subject$<br/>
-						&nbsp; '.vtranslate('Start Date & Time', $moduleName).' : $events-date_start$<br/> 
-						&nbsp; '.vtranslate('End Date & Time', $moduleName).' : $events-due_date$<br/>
-						&nbsp; '.vtranslate('LBL_STATUS', $moduleName).' : $events-eventstatus$<br/>
-						&nbsp; '.vtranslate('Priority', $moduleName).' : $events-priority$<br/>
-						&nbsp; '.vtranslate('Related To', $moduleName).' : $events-crmid$<br/>
-						&nbsp; '.vtranslate('LBL_CONTACT_LIST', $moduleName).' : $events-contactid$<br/>
-						&nbsp; '.vtranslate('Location', $moduleName).' : $events-location$<br/>
-						&nbsp; '.vtranslate('LBL_APP_DESCRIPTION', $moduleName).' : $events-description$<br/><br/>
-						'.vtranslate('LBL_REGARDS_STRING', $moduleName).',<br/>
-						$current_user_name$
-						<p/>';
-		$db->pquery('INSERT INTO vtiger_emailtemplates(foldername,templatename,subject,description,body,systemtemplate) values(?,?,?,?,?,?)', array('Public', 'Invite Users', 'Invitation', 'Invite Users', $body, '1'));
+								&nbsp; '.vtranslate('Subject', $moduleName).' : $events-subject$<br/>
+								&nbsp; '.vtranslate('Start Date & Time', $moduleName).' : $events-date_start$<br/> 
+								&nbsp; '.vtranslate('End Date & Time', $moduleName).' : $events-due_date$<br/>
+								&nbsp; '.vtranslate('LBL_STATUS', $moduleName).' : $events-eventstatus$<br/>
+								&nbsp; '.vtranslate('Priority', $moduleName).' : $events-priority$<br/>
+								&nbsp; '.vtranslate('Related To', $moduleName).' : $events-crmid$<br/>
+								&nbsp; '.vtranslate('LBL_CONTACT_LIST', $moduleName).' : $events-contactid$<br/>
+								&nbsp; '.vtranslate('Location', $moduleName).' : $events-location$<br/>
+								&nbsp; '.vtranslate('LBL_APP_DESCRIPTION', $moduleName).' : $events-description$<br/><br/>
+								'.vtranslate('LBL_REGARDS_STRING', $moduleName).',<br/>
+								$current_user_name$
+								<p/>';
+		$db->pquery('INSERT INTO vtiger_emailtemplates(foldername,templatename,subject,description,body,systemtemplate,templateid) values(?,?,?,?,?,?,?)', array('Public', 'Invite Users', 'Invitation', 'Invite Users', $body, '1', $db->getUniqueID('vtiger_emailtemplates')));
 	}
 
 	if (!Vtiger_Utils::CheckTable('vtiger_emailslookup')) {
@@ -1863,6 +1889,9 @@ if(defined('VTIGER_UPGRADE')) {
 		$db->pquery('ALTER TABLE vtiger_mailscanner_ids ADD INDEX messageids_crmid_idx(crmid)',array());
 	}
 
+	$result = $db->pquery('SELECT templateid FROM vtiger_emailtemplates ORDER BY templateid DESC LIMIT 1', array());
+	$db->pquery('UPDATE vtiger_emailtemplates_seq SET id=?', array($db->query_result($result, 0, 'templateid')));
+
 	//Migrating data missed in vtiger_settings_field from file to database.
 	//Start:: user management block
 	$userResult = $db->pquery('SELECT blockid FROM vtiger_settings_blocks WHERE label=?', array('LBL_USER_MANAGEMENT'));
diff --git a/packages/vtiger/optional/EmailTemplates.zip b/packages/vtiger/optional/EmailTemplates.zip
index 7067bee08933e07fc57493687e2390933deb1422..ed7ead222091a8cc6179a6afc2a0e412354c8fc1 100644
Binary files a/packages/vtiger/optional/EmailTemplates.zip and b/packages/vtiger/optional/EmailTemplates.zip differ
diff --git a/packages/vtiger/optional/Google.zip b/packages/vtiger/optional/Google.zip
index c44156b2ef0cde5e1c71ef28807ebe880966765c..1e046d6e2f75180dc633dcc58f7b215fdb1c23f5 100644
Binary files a/packages/vtiger/optional/Google.zip and b/packages/vtiger/optional/Google.zip differ
diff --git a/pkg/vtiger/modules/EmailTemplates/layouts/v7/modules/EmailTemplates/DefaultContentForTemplates.tpl b/pkg/vtiger/modules/EmailTemplates/layouts/v7/modules/EmailTemplates/DefaultContentForTemplates.tpl
index df728714d66e1fe9e71facbfab220659e5360069..c2f176ba48211a124d0d9898c3e050a753e39150 100644
--- a/pkg/vtiger/modules/EmailTemplates/layouts/v7/modules/EmailTemplates/DefaultContentForTemplates.tpl
+++ b/pkg/vtiger/modules/EmailTemplates/layouts/v7/modules/EmailTemplates/DefaultContentForTemplates.tpl
@@ -21,21 +21,6 @@
 			<center>
 				<table border="0" cellpadding="0" cellspacing="0" class="borderGrey" width="600px">
 					<tbody>
-						<tr>
-							<td colspan="6"><!-- Begin Pre header -->
-								<table border="0" cellpadding="5" cellspacing="0" height="52" style="font-family: Helvetica,Verdana,sans-serif; font-size: 10px; color: rgb(102, 102, 102); background-color: rgb(232, 245, 254);" width="597">
-									<tbody>
-										<tr>
-											<td>
-												<div>Use this area to offer a short teaser of your email&#39;s content. Text here will show in the preview area<br />
-													of some email clients.</div>
-											</td>
-											<td><a href="{$VIEW_IN_BROWSER_TAG}" target="_blank">View in browser</a></td>
-										</tr>
-									</tbody>
-								</table>
-								<!-- // End Pre header \ --></td>
-						</tr>
 						<tr style="height:50px;">
 							<td colspan="6" style="border-top: 1px solid #ddd; font-family: Helvetica,Verdana,sans-serif"></td>
 						</tr>
@@ -54,7 +39,7 @@
 										<tr>
 											<td valign="top" width="350px">
 												<center>
-													<div><em>Copyright &copy; 2014 {if !(empty($WEBSITE_URL))}<a href="{$WEBSITE_URL}" target="_blank">{$WEBSITE_URL}</a>{else}your company.com{/if}, All rights reserved.</em></div>
+													<div><em>Copyright &copy; {date('Y')} {if !(empty($WEBSITE_URL))}<a href="{$WEBSITE_URL}" target="_blank">{$WEBSITE_URL}</a>{else}your company.com{/if}, All rights reserved.</em></div>
 												</center>
 											</td>
 										</tr>
diff --git a/pkg/vtiger/modules/Google/modules/Google/connectors/Oauth.php b/pkg/vtiger/modules/Google/modules/Google/connectors/Oauth.php
index cdae95dd145ceb1bb5cf98bfaf92d94b290fa895..537440dd7fdd1412abaaa718063d31a32d60e22a 100644
--- a/pkg/vtiger/modules/Google/modules/Google/connectors/Oauth.php
+++ b/pkg/vtiger/modules/Google/modules/Google/connectors/Oauth.php
@@ -31,6 +31,8 @@ class Google_Oauth_Connector {
     protected $_oauthOptions = array(
         'requestScheme' => Zend_Oauth::REQUEST_SCHEME_HEADER,
         'version' => '1.0',
+        'consumerKey' => '639253257022.apps.googleusercontent.com',
+        'consumerSecret' => 'CxnOsnYx_RNyTWVfzTIenmhQ',
         'signatureMethod' => 'HMAC-SHA1',
         'requestTokenUrl' => 'https://www.google.com/accounts/OAuthGetRequestToken',
         'userAuthorizationUrl' => 'https://www.google.com/accounts/OAuthAuthorizeToken',
@@ -45,8 +47,6 @@ class Google_Oauth_Connector {
         self::initializeSchema();
         $this->userId = $userId;
         $this->_oauthOptions['callbackUrl'] = $callbackUrl;
-        $this->_oauthOptions['consumerKey'] = VtigerConfig::getOD('GOOGLESYNC_CONSUMER_KEY');
-        $this->_oauthOptions['consumerSecret'] = VtigerConfig::getOD('GOOGLESYNC_CONSUMER_SECRET');
         $this->db = PearDatabase::getInstance();
     }
 
@@ -77,15 +77,15 @@ class Google_Oauth_Connector {
             $this->userId = Users_Record_Model::getCurrentUserModel()->getId();
         
         if (!$accessToken && !$requestToken){
-            $query = "SELECT  1 FROM vtiger_app_oauth1 WHERE  userid=? and service=?";
+            $query = "SELECT  1 FROM vtiger_google_oauth WHERE  userid=? and service=?";
             $params = array($this->userId, $service);
         }
         else if ($accessToken){
-            $query = "SELECT  access_token FROM vtiger_app_oauth1 WHERE  userid=? and service=? AND access_token<>? AND access_token IS NOT NULL";
+            $query = "SELECT  access_token FROM vtiger_google_oauth WHERE  userid=? and service=? AND access_token<>? AND access_token IS NOT NULL";
             $params = array($this->userId, $service, '');
         }
         else if ($requestToken){
-            $query = "SELECT  request_token FROM vtiger_app_oauth1 WHERE  userid=? and service=? AND request_token<>? AND request_token IS NOT NULL";
+            $query = "SELECT  request_token FROM vtiger_google_oauth WHERE  userid=? and service=? AND request_token<>? AND request_token IS NOT NULL";
             $params = array($this->userId, $service, '');
         }
         $result = $this->db->pquery($query, $params);
@@ -103,10 +103,10 @@ class Google_Oauth_Connector {
      */
     protected function storeAccessToken($service, $token) {
         $user = Users_Record_Model::getCurrentUserModel();
-        $query = "INSERT INTO vtiger_app_oauth1(service,access_token,userid) VALUES(?,?,?)";
+        $query = "INSERT INTO vtiger_google_oauth(service,access_token,userid) VALUES(?,?,?)";
         $params = array($service, base64_encode(serialize($token)), $user->getid());
         if (self::hasStoredToken($service, false, true)) {
-            $query = "UPDATE vtiger_app_oauth1 SET access_token=? WHERE userid=? AND  service=?";
+            $query = "UPDATE vtiger_google_oauth SET access_token=? WHERE userid=? AND  service=?";
             $params = array(base64_encode(serialize($token)), $user->getId(), $service);
         }
 
@@ -117,7 +117,7 @@ class Google_Oauth_Connector {
         if(!$this->userId)
             $this->userId = Users_Record_Model::getCurrentUserModel()->getId();
         
-        $query = "SELECT access_token FROM vtiger_app_oauth1 WHERE userid=? AND service =?";
+        $query = "SELECT access_token FROM vtiger_google_oauth WHERE userid=? AND service =?";
         $params = array($this->userId, $service);
 
         $result = $this->db->pquery($query, $params);
@@ -128,10 +128,10 @@ class Google_Oauth_Connector {
 
     protected function storeRequestToken($service, $token) {
         $user = Users_Record_Model::getCurrentUserModel();
-        $query = "DELETE FROM vtiger_app_oauth1 where service=? and userid=?";
+        $query = "DELETE FROM vtiger_google_oauth where service=? and userid=?";
         $this->db->pquery($query, array($service, $user->getId()));
 
-        $query = "INSERT INTO vtiger_app_oauth1(service,request_token,userid) values(?,?,?)";
+        $query = "INSERT INTO vtiger_google_oauth(service,request_token,userid) values(?,?,?)";
         $this->db->pquery($query, array($service, base64_encode(serialize($token)), $user->getId()));
 
     }
@@ -139,7 +139,7 @@ class Google_Oauth_Connector {
     protected function retrieveRequestToken($service) {
         $user = Users_Record_Model::getCurrentUserModel();
 
-        $query = "SELECT request_token FROM vtiger_app_oauth1 WHERE userid=? AND service =?";
+        $query = "SELECT request_token FROM vtiger_google_oauth WHERE userid=? AND service =?";
         $params = array($user->getId(), $service);
 
         $result = $this->db->pquery($query, $params);
@@ -180,9 +180,9 @@ class Google_Oauth_Connector {
     
     
 	 public static function initializeSchema(){
-		 if(!Vtiger_Utils::CheckTable('vtiger_app_oauth1')) {
-                Vtiger_Utils::CreateTable('vtiger_app_oauth1',
-                        '(service varchar(64),request_token text,access_token text,userid int, serviceid varchar(255), name varchar(255))',true);
+		 if(!Vtiger_Utils::CheckTable('vtiger_google_oauth')) {
+                Vtiger_Utils::CreateTable('vtiger_google_oauth',
+                        '(service varchar(64),request_token text,access_token text,userid int)',true);
             }
 	 }
 
diff --git a/pkg/vtiger/modules/Google/modules/Google/connectors/Oauth2.php b/pkg/vtiger/modules/Google/modules/Google/connectors/Oauth2.php
index 5b59c6456233328b378a73577cabfa005efd3cd0..58d90bf8e13c7ee75a611f16bd64fe08856ea09e 100644
--- a/pkg/vtiger/modules/Google/modules/Google/connectors/Oauth2.php
+++ b/pkg/vtiger/modules/Google/modules/Google/connectors/Oauth2.php
@@ -54,13 +54,14 @@ class Google_Oauth2_Connector {
     const OAUTH2_REVOKE_URI = 'https://accounts.google.com/o/oauth2/revoke';
     
     public function __construct($module,$userId=false) {
+        global $site_URL;
         $this->source_module = $module;
         if($userId) $this->user_id = $userId;
         $this->service_name = $this->service_provider . $module;
-        $this->client_id = VtigerConfig::getOD('GOOGLE_SYNC_CLIENT_ID');
-        $this->client_secret = VtigerConfig::getOD('GOOGLE_SYNC_CLIENT_SECRET');
-        $this->redirect_uri = VtigerConfig::getOD('OAUTH_SERVER_URL');
-        $this->scope = 'https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile https://www.google.com/m8/feeds https://www.googleapis.com/auth/calendar';
+        $this->client_id = Google_Config_Connector::$clientId;
+        $this->client_secret = Google_Config_Connector::$clientSecret;
+        $this->redirect_uri = rtrim($site_URL, '/').'/index.php?module=Google&view=List&operation=sync&sourcemodule='.$this->source_module.'&service='.$this->service_name;
+        $this->scope = $this->scopes[$this->source_module];
     }
     
     public function getClientId() {
@@ -100,9 +101,6 @@ class Google_Oauth2_Connector {
             'access_type=' . urlencode($this->access_type),
             'approval_prompt=' . urlencode($this->approval_prompt),
         );
-        if (isset($this->state)) {
-            $params[] = 'state=' . urlencode($this->state);
-        }
         $queryString = implode('&', $params);
         return self::OAUTH2_AUTH_URL . "?$queryString";
     }
@@ -119,8 +117,8 @@ class Google_Oauth2_Connector {
     
     public function getState($source) {
         global $site_URL;
-        $callbackUri = $site_URL . '/index.php?module=Google&view=List&operation=sync&sourcemodule=' . 
-                $this->source_module . '&service=' . $source.'&_ignoreOnBoardCompletion=true';
+        $callbackUri = rtrim($site_URL, '/') . '/index.php?module=Google&view=List&operation=sync&sourcemodule=' . 
+                $this->source_module . '&service=' . $source;
         $stateDetails['url'] = $callbackUri;
         $parse = parse_url($site_URL);
         $ipAddr = getHostByName($parse['host']);
@@ -183,11 +181,11 @@ class Google_Oauth2_Connector {
         $modulesSupported = array('Contacts', 'Calendar');
         foreach($modulesSupported as $moduleName) {
             $params = array($this->service_provider.$moduleName,$accessToken,$refresh_token,$this->user_id);
-            $sql = 'INSERT INTO ' . $this->table_name . ' VALUES (' . generateQuestionMarks($params) . ')';
-            $this->db->pquery($sql,$params);
-        }
+			$sql = 'INSERT INTO ' . $this->table_name . ' VALUES (' . generateQuestionMarks($params) . ')';
+			$this->db->pquery($sql,$params);
+		}
 	}
-
+    
     protected function retreiveToken() {
         if(!$this->user_id) $this->user_id = Users_Record_Model::getCurrentUserModel()->getId();
         $query = 'SELECT access_token,refresh_token FROM ' . $this->table_name . ' WHERE userid=? AND service =?';
@@ -232,12 +230,12 @@ class Google_Oauth2_Connector {
         $encodedToken = $this->fireRequest(self::OAUTH2_TOKEN_URI,array(),$params);
         $decodedToken = json_decode($encodedToken,true);
         if(!isset($decodedToken['error'])) {
-            $decodedToken['created'] = time();
-            $token['access_token'] = $decodedToken;
-            $token['refresh_token'] = $this->token['refresh_token'];
-            $this->updateAccessToken(json_encode($decodedToken),$token['refresh_token']);
-            $this->setToken($token);
-        }
+			$decodedToken['created'] = time();
+			$token['access_token'] = $decodedToken;
+			$token['refresh_token'] = $this->token['refresh_token'];
+			$this->updateAccessToken(json_encode($decodedToken),$token['refresh_token']);
+			$this->setToken($token);
+		}
     }
 
     public function authorize() {
diff --git a/pkg/vtiger/modules/Google/modules/Google/helpers/Utils.php b/pkg/vtiger/modules/Google/modules/Google/helpers/Utils.php
index 08da62df1432ef7887c86a2479374230739afcde..68695c71ee587ec8cd007e75301822aba80bb47e 100644
--- a/pkg/vtiger/modules/Google/modules/Google/helpers/Utils.php
+++ b/pkg/vtiger/modules/Google/modules/Google/helpers/Utils.php
@@ -92,7 +92,7 @@ class Google_Utils_Helper {
     static function getCallbackUrl($request, $options = array()) {
         global $site_URL;
 
-        $callback = $site_URL . "/index.php?module=" . $request['module'] . "&view=List&sourcemodule=" . $request['sourcemodule'];
+        $callback = rtrim($site_URL, '/') . "/index.php?module=".$request['module']."&view=List&sourcemodule=".$request['sourcemodule'];
         foreach ($options as $key => $value) {
             $callback.="&" . $key . "=" . $value;
         }
diff --git a/pkg/vtiger/modules/Google/modules/Google/models/Contacts.php b/pkg/vtiger/modules/Google/modules/Google/models/Contacts.php
index 3d06b8ffaae7a0eda1309ea69c5aa3692f87ca61..559f4e0dde023fe780508604f89a10910c4e74d8 100644
--- a/pkg/vtiger/modules/Google/modules/Google/models/Contacts.php
+++ b/pkg/vtiger/modules/Google/modules/Google/models/Contacts.php
@@ -195,6 +195,7 @@ class Google_Contacts_Model extends WSAPP_SyncRecordModel {
                 $recordModel->set('mode', '');
                 $recordModel->set('accountname', $orgName);
                 $recordModel->set('assigned_user_id', $userId);
+				$recordModel->set('source', 'GOOGLE');
                 if($description) {
                     $recordModel->set('description', $description);
                 }   
diff --git a/pkg/vtiger/modules/Google/modules/Google/models/Module.php b/pkg/vtiger/modules/Google/modules/Google/models/Module.php
index 81173edec138529e7515cefec9a619bff9e7b639..f841028d1609e5dc2e7e4d4b246917b6e9bb0410 100755
--- a/pkg/vtiger/modules/Google/modules/Google/models/Module.php
+++ b/pkg/vtiger/modules/Google/modules/Google/models/Module.php
@@ -11,7 +11,7 @@ class Google_Module_Model extends Vtiger_Module_Model {
     
     public static function removeSync($module, $id) {
         $db = PearDatabase::getInstance();
-        $query = "DELETE FROM vtiger_app_oauth1 WHERE service = ? AND userid = ?";
+        $query = "DELETE FROM vtiger_google_oauth WHERE service = ? AND userid = ?";
         $db->pquery($query, array($module, $id));
     }