diff --git a/modules/Migration/schema/540_to_600RC.php b/modules/Migration/schema/540_to_600RC.php
index 3aeac82e2cd62ba368a466abc298bb70c91e7e63..47b365403fddffa1d64a7a450386c2d6e071e894 100644
--- a/modules/Migration/schema/540_to_600RC.php
+++ b/modules/Migration/schema/540_to_600RC.php
@@ -744,13 +744,31 @@ Migration_Index_View::ExecuteQuery('ALTER TABLE vtiger_links MODIFY column linkt
 Migration_Index_View::ExecuteQuery('ALTER TABLE vtiger_links MODIFY column linklabel VARCHAR(50)', array());
 Migration_Index_View::ExecuteQuery('ALTER TABLE vtiger_links MODIFY column handler_class VARCHAR(50)', array());
 Migration_Index_View::ExecuteQuery('ALTER TABLE vtiger_links MODIFY column handler VARCHAR(50)', array());
+
 //--
 //Add ModComments to HelpDesk and Faq module
+
+$moduleInstance = Vtiger_Module::getInstance('ModComments');
+$customer = Vtiger_Field::getInstance('customer', $moduleInstance);
+if (!$customer) {
+	$customer = new Vtiger_Field();
+	$customer->name = 'customer';
+	$customer->label = 'Customer';
+	$customer->uitype = '10';
+	$customer->displaytype = '3';
+	$blockInstance = Vtiger_Block::getInstance('LBL_MODCOMMENTS_INFORMATION', $moduleInstance);
+	$blockInstance->addField($customer);
+	$customer->setRelatedModules(array('Contacts'));
+}
+
 require_once 'modules/ModComments/ModComments.php';
 ModComments::addWidgetTo(array("HelpDesk", "Faq"));
 global $current_user, $VTIGER_BULK_SAVE_MODE;
 $VTIGER_BULK_SAVE_MODE = true;
 
+$customerPortalSettings = new Settings_CustomerPortal_Module_Model();
+$portal_user_id = $customerPortalSettings->getCurrentPortalUser();
+
 $stopLoop = false;
 $pageCount = 0;
 do {
@@ -763,12 +781,21 @@ do {
 	for($i=0; $i<$rows; $i++) {
 		$modComments = CRMEntity::getInstance('ModComments');
 		$modComments->column_fields['commentcontent'] = decode_html($adb->query_result($ticketComments, $i, 'comments'));
-		$ownerId = $adb->query_result($ticketComments, $i, 'ownerid');
-		$current_user->id = $ownerId;
-		$modComments->column_fields['assigned_user_id'] = $modComments->column_fields['creator'] = $ownerId;
 		$modComments->column_fields['createdtime'] = $adb->query_result($ticketComments, $i, 'createdtime');
 		$modComments->column_fields['modifiedtime'] = $adb->query_result($ticketComments, $i, 'createdtime');
 		$modComments->column_fields['related_to'] = $adb->query_result($ticketComments, $i, 'ticketid');
+		
+		// Contact linked comments should be carried over (http://code.vtiger.com/vtiger/vtigercrm/issues/130)
+		$ownerId = $adb->query_result($ticketComments, $i, 'ownerid');
+		$ownerType = $adb->query_result($ticketComments, $i, 'ownertype');
+		if ($ownerType == 'customer') {
+			$modComments->column_fields['customer'] = $ownerId;
+			$current_user->id = $ownerId = $portal_user_id; // Owner of record marked to PortalUser, reference marked to Contact.
+		} else {
+			$current_user->id = $ownerId;
+		}
+		$modComments->column_fields['assigned_user_id'] = $modComments->column_fields['creator'] = $ownerId;
+		
 		$modComments->save('ModComments');
 		Migration_Index_View::ExecuteQuery('UPDATE vtiger_crmentity SET modifiedtime = ?, smcreatorid = ?, modifiedby = ? WHERE crmid = ?',
 			array($modComments->column_fields['createdtime'], $ownerId, $ownerId, $modComments->id));
@@ -776,6 +803,9 @@ do {
 	++$pageCount;
 } while (!$stopLoop);
 
+// Restore the UserId
+$current_user->id = Users::getActiveAdminId();
+
 $stopLoop = false;
 $pageCount = 0;
 do {
@@ -794,7 +824,7 @@ do {
 		$modComments->column_fields['related_to'] = $adb->query_result($faqComments, $i, 'faqid');
 		$modComments->save('ModComments');
 		Migration_Index_View::ExecuteQuery('UPDATE vtiger_crmentity SET modifiedtime = ?, smcreatorid = ?, modifiedby = ? WHERE crmid = ?',
-			array($modComments->column_fields['createdtime'], '6', '6', $modComments->id));
+			array($modComments->column_fields['createdtime'], $current_user->id, $current_user->id, $modComments->id));
 	}
 	++$pageCount;
 } while (!$stopLoop);
@@ -836,18 +866,7 @@ Migration_Index_View::ExecuteQuery('CREATE INDEX vtiger_crmentity_labelidx ON vt
 $homeModule = Vtiger_Module::getInstance('Home');
 Vtiger_Event::register($homeModule, 'vtiger.entity.aftersave', 'Vtiger_RecordLabelUpdater_Handler', 'modules/Vtiger/RecordLabelUpdater.php');
 
-$moduleInstance = Vtiger_Module::getInstance('ModComments');
-$customer = Vtiger_Field::getInstance('customer', $moduleInstance);
-if (!$customer) {
-	$customer = new Vtiger_Field();
-	$customer->name = 'customer';
-	$customer->label = 'Customer';
-	$customer->uitype = '10';
-	$customer->displaytype = '3';
-	$blockInstance = Vtiger_Block::getInstance('LBL_MODCOMMENTS_INFORMATION', $moduleInstance);
-	$blockInstance->addField($customer);
-	$customer->setRelatedModules(array('Contacts'));
-}
+
 
 $moduleInstance = Vtiger_Module::getInstance('Potentials');
 $filter = Vtiger_Filter::getInstance('All', $moduleInstance);