diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php
index 3d7b84ce49d16882462197d8fe4626f44538c10d..f007cbdbf81c52a8fdb9425dc046c52cc6d2e735 100644
--- a/htdocs/comm/propal/class/propal.class.php
+++ b/htdocs/comm/propal/class/propal.class.php
@@ -3502,7 +3502,7 @@ class Propal extends CommonObject
 /**
  *	Class to manage commercial proposal lines
  */
-class PropaleLigne  extends CommonObjectLine
+class PropaleLigne extends CommonObjectLine
 {
     public $element='propaldet';
     public $table_element='propaldet';
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index ab6013b74eef6a59750d8b5b5bbdc7256521f870..ddfb2780f3f83153c1aff506e69935e36c991fee 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -4655,18 +4655,17 @@ abstract class CommonObject
 
 	/**
 	 * Get buy price to use for margin calculation. This function is called when buy price is unknown.
-	 *	set buy price = sell price if ForceBuyingPriceIfNull configured,
+	 *	 Set buy price = sell price if ForceBuyingPriceIfNull configured,
 	 *   else if calculation MARGIN_TYPE = 'costprice' and costprice is defined, use costprice as buyprice
 	 *	 else if calculation MARGIN_TYPE = 'pmp' and pmp is calculated, use pmp as buyprice
 	 *	 else set min buy price as buy price
 	 *
-	 * @param float		$unitPrice		 product unit price
-	 * @param float		$discountPercent line discount percent
-	 * @param int		$fk_product		 product id
-	 *
-	 * @return	float <0 if ko, buyprice if ok
+	 * @param float		$unitPrice		 Product unit price
+	 * @param float		$discountPercent Line discount percent
+	 * @param int		$fk_product		 Product id
+	 * @return	float                    <0 if KO, buyprice if OK
 	 */
-	public function defineBuyPrice($unitPrice = 0, $discountPercent = 0, $fk_product = 0)
+	public function defineBuyPrice($unitPrice = 0.0, $discountPercent = 0.0, $fk_product = 0)
 	{
 		global $conf;
 
@@ -4973,6 +4972,8 @@ abstract class CommonObject
 
 	    $fields = array_merge(array('datec'=>$this->db->idate(dol_now())), $this->set_save_query());
 
+	    $keys=array();
+	    $values = array();
 	    foreach ($fields as $k => $v) {
 	    	$keys[] = $k;
 	    	$values[] = $this->quote($v);
diff --git a/htdocs/core/class/html.formmailing.class.php b/htdocs/core/class/html.formmailing.class.php
index 9fb4e4eea86566132632d7e5d3badc1af881a3e1..e3e6ce4cbf93f8d3e175192ba21bedd437577323 100644
--- a/htdocs/core/class/html.formmailing.class.php
+++ b/htdocs/core/class/html.formmailing.class.php
@@ -25,13 +25,13 @@ require_once DOL_DOCUMENT_ROOT .'/core/class/html.form.class.php';
 /**
  *	Class to offer components to list and upload files
  */
-class FormMailing  extends Form
+class FormMailing extends Form
 {
 	public $errors=array();
 
 	/**
 	 * Output a select with destinaries status
-	 * 
+	 *
 	 * @param string   $selectedid     The selected id
 	 * @param string   $htmlname       Name of controm
 	 * @param integer  $show_empty     Show empty option
@@ -46,7 +46,7 @@ class FormMailing  extends Form
 		$mailing = new Mailing($this->db);
 
 		$options = array();
-        
+
 		if ($show_empty) {
 			$options[-2] = '';   // Note -1 is used for error
 		}
diff --git a/htdocs/core/lib/modulebuilder.lib.php b/htdocs/core/lib/modulebuilder.lib.php
index cb5d143cff963ff3ec4bb35be2e496ae3361463e..af9ab67d8fe16731c3605076ccce727600987b99 100644
--- a/htdocs/core/lib/modulebuilder.lib.php
+++ b/htdocs/core/lib/modulebuilder.lib.php
@@ -55,6 +55,7 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask)
     {
         include_once $pathoffiletoeditsrc;
         if (class_exists($objectname)) $object=new $objectname($db);
+        else return -1;
 
         // Backup old file
         dol_copy($pathoffiletoeditsrc, $pathoffiletoeditsrc.'.back', $newmask, 1);
@@ -109,7 +110,7 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask)
 
         //file_put_contents($pathoffiletoedittmp, $contentclass);
         file_put_contents(dol_osencode($pathoffiletoedittarget), $contentclass);
-        @chmod($pathoffiletoedit, octdec($newmask));
+        @chmod($pathoffiletoedittarget, octdec($newmask));
 
         return 1;
     }
@@ -139,6 +140,7 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask)
     {
         dol_include_once(strtolower($module).'/class/'.strtolower($objectname).'.class.php');
         if (class_exists($objectname)) $object=new $objectname($db);
+        else return -1;
     }
     catch(Exception $e)
     {
@@ -171,7 +173,7 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask)
     $contentsql = preg_replace('/-- BEGIN MODULEBUILDER FIELDS.*END MODULEBUILDER FIELDS/ims', $texttoinsert, $contentsql);
 
     file_put_contents($pathoffiletoedittarget, $contentsql);
-    @chmod($pathoffiletoedit, octdec($newmask));
+    @chmod($pathoffiletoedittarget, octdec($newmask));
 
 
     // Edit .key.sql file
@@ -199,7 +201,7 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask)
     $contentsql = preg_replace('/-- BEGIN MODULEBUILDER INDEXES.*END MODULEBUILDER INDEXES/ims', $texttoinsert, $contentsql);
 
     file_put_contents($pathoffiletoedittarget, $contentsql);
-    @chmod($pathoffiletoedit, octdec($newmask));
+    @chmod($pathoffiletoedittarget, octdec($newmask));
 
     return 1;
 }
diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php
index 1d27e7c49862b2f72e5f927470ca45ff8f9288a9..61ad1401dc2d116bd8a40236a19f30ce7a59a4c6 100644
--- a/htdocs/supplier_proposal/class/supplier_proposal.class.php
+++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php
@@ -2563,10 +2563,9 @@ class SupplierProposal extends CommonObject
 
 
 /**
- *	\class      SupplierProposalLine
- *	\brief      Class to manage supplier_proposal lines
+ *	Class to manage supplier_proposal lines
  */
-class SupplierProposalLine  extends CommonObjectLine
+class SupplierProposalLine extends CommonObjectLine
 {
     var $db;
     var $error;