diff --git a/CHANGELOG.TXT b/CHANGELOG.TXT
index b35a577..0ea8cc6 100755
--- a/CHANGELOG.TXT
+++ b/CHANGELOG.TXT
@@ -1,3 +1,6 @@
+5.9.187 (2012-09-15)
+	- A datamatrix barcode bug was fixed.
+
 5.9.187 (2012-09-14)
 	- Subset feature was extended to include the first 256 characters.
 
diff --git a/README.TXT b/README.TXT
index d7655a0..96c0360 100755
--- a/README.TXT
+++ b/README.TXT
@@ -8,8 +8,8 @@ http://sourceforge.net/donate/index.php?group_id=128076
 ------------------------------------------------------------
 
 Name: TCPDF
-Version: 5.9.187
-Release date: 2012-09-14
+Version: 5.9.188
+Release date: 2012-09-15
 Author:	Nicola Asuni
 
 Copyright (c) 2002-2012:
diff --git a/composer.json b/composer.json
index 65276fa..203cf8a 100644
--- a/composer.json
+++ b/composer.json
@@ -1,6 +1,6 @@
 {
 	"name": "tcpdf/tcpdf",
-	"version": "5.9.187",
+	"version": "5.9.188",
 	"homepage": "http://www.tcpdf.org/",
 	"type": "library",
 	"description": "TCPDF is a PHP class for generating PDF files on-the-fly without requiring external extensions.",
diff --git a/datamatrix.php b/datamatrix.php
index ff92011..28208c4 100755
--- a/datamatrix.php
+++ b/datamatrix.php
@@ -1,9 +1,9 @@
 <?php
 //============================================================+
 // File name   : datamatrix.php
-// Version     : 1.0.001
+// Version     : 1.0.003
 // Begin       : 2010-06-07
-// Last Update : 2011-09-14
+// Last Update : 2012-09-15
 // Author      : Nicola Asuni - Tecnick.com LTD - Manor Coach House, Church Hill, Aldershot, Hants, GU12 4RQ, UK - www.tecnick.com - info@tecnick.com
 // License     : GNU-LGPL v3 (http://www.gnu.org/copyleft/lesser.html)
 // -------------------------------------------------------------------
@@ -40,7 +40,7 @@
  *
  * @package com.tecnick.tcpdf
  * @author Nicola Asuni
- * @version 1.0.001
+ * @version 1.0.003
  */
 
 // custom definitions
@@ -105,7 +105,7 @@ define('ENC_ASCII_NUM', 7);
  *
  * @package com.tecnick.tcpdf
  * @author Nicola Asuni
- * @version 1.0.001
+ * @version 1.0.003
  */
 class Datamatrix {
 
@@ -184,7 +184,7 @@ class Datamatrix {
 	protected $chset_id = array(ENC_C40 => 'C40', ENC_TXT => 'TXT', ENC_X12 =>'X12');
 
 	/**
-	 * Basic set of charactes for each encodation mode.
+	 * Basic set of characters for each encodation mode.
 	 * @protected
 	 */
 	protected $chset = array(
@@ -270,7 +270,7 @@ class Datamatrix {
 				$cw[] = 129;
 				++$nd;
 				// add remaining pads
-				for ($i = $nd; $i <= $params[11]; ++$i) {
+				for ($i = $nd; $i < $params[11]; ++$i) {
 					$cw[] = $this->get253StateCodeword(129, $i);
 				}
 			}
@@ -280,7 +280,7 @@ class Datamatrix {
 		// initialize empty arrays
 		$grid = array_fill(0, ($params[2] * $params[3]), 0);
 		// get placement map
-		$places = $this->getPlacemetMap($params[2], $params[3]);
+		$places = $this->getPlacementMap($params[2], $params[3]);
 		// fill the grid with data
 		$grid = array();
 		$i = 0;
@@ -365,7 +365,7 @@ class Datamatrix {
 		if (($a == 0) OR ($b == 0)) {
 			return 0;
 		}
-		return $alog[($log[$a] + $log[$b]) % ($gf - 1)];
+		return ($alog[($log[$a] + $log[$b]) % ($gf - 1)]);
 	}
 
 	/**
@@ -872,23 +872,23 @@ class Datamatrix {
 							$pos = $epos;
 							$field_lenght = 0;
 						}
-						// 1. If the EDIFACT encoding is at the point of starting a new triple symbol character and if the look-ahead test (starting at step J) indicates another mode, switch to that mode.
-						if ($field_lenght == 0) {
-							// get remaining number of data symbols
-							$cwr = ($this->getMaxDataCodewords($cw_num + 2) - $cw_num);
-							if ($cwr < 3) {
-								// return to ascii without unlatch
-								$enc = ENC_ASCII;
+					}
+					// 1. If the EDIFACT encoding is at the point of starting a new triple symbol character and if the look-ahead test (starting at step J) indicates another mode, switch to that mode.
+					if ($field_lenght == 0) {
+						// get remaining number of data symbols
+						$cwr = ($this->getMaxDataCodewords($cw_num + 2) - $cw_num);
+						if ($cwr < 3) {
+							// return to ascii without unlatch
+							$enc = ENC_ASCII;
+							break; // exit from EDIFACT mode
+						} else {
+							$newenc = $this->lookAheadTest($data, $pos, $enc);
+							if ($newenc != $enc) {
+								// 1. If the look-ahead test (starting at step J) indicates another mode, switch to that mode.
+								$enc = $newenc;
+								$cw[] = $this->getSwitchEncodingCodeword($enc);
+								++$cw_num;
 								break; // exit from EDIFACT mode
-							} else {
-								$newenc = $this->lookAheadTest($data, $pos, $enc);
-								if ($newenc != $enc) {
-									// 1. If the look-ahead test (starting at step J) indicates another mode, switch to that mode.
-									$enc = $newenc;
-									$cw[] = $this->getSwitchEncodingCodeword($enc);
-									++$cw_num;
-									break; // exit from EDIFACT mode
-								}
 							}
 						}
 					}
@@ -1076,7 +1076,6 @@ class Datamatrix {
 		return $marr;
 	}
 
-
 	/**
 	 * Build a placement map.
 	 * (Annex F - ECC 200 symbol character placement)
@@ -1085,7 +1084,7 @@ class Datamatrix {
 	 * @return array
 	 * @protected
 	 */
-	protected function getPlacemetMap($nrow, $ncol) {
+	protected function getPlacementMap($nrow, $ncol) {
 		// initialize array with zeros
 		$marr = array_fill(0, ($nrow * $ncol), 0);
 		// set starting values
diff --git a/tcpdf.php b/tcpdf.php
index e7ecfbe..69ad558 100755
--- a/tcpdf.php
+++ b/tcpdf.php
@@ -1,9 +1,9 @@
 <?php
 //============================================================+
 // File name   : tcpdf.php
-// Version     : 5.9.187
+// Version     : 5.9.188
 // Begin       : 2002-08-03
-// Last Update : 2012-09-14
+// Last Update : 2012-09-15
 // Author      : Nicola Asuni - Tecnick.com LTD - Manor Coach House, Church Hill, Aldershot, Hants, GU12 4RQ, UK - www.tecnick.com - info@tecnick.com
 // License     : http://www.tecnick.com/pagefiles/tcpdf/LICENSE.TXT GNU-LGPLv3
 // -------------------------------------------------------------------
@@ -139,7 +139,7 @@
  * Tools to encode your unicode fonts are on fonts/utils directory.</p>
  * @package com.tecnick.tcpdf
  * @author Nicola Asuni
- * @version 5.9.187
+ * @version 5.9.188
  */
 
 // Main configuration file. Define the K_TCPDF_EXTERNAL_CONFIG constant to skip this file.
@@ -151,7 +151,7 @@ require_once(dirname(__FILE__).'/config/tcpdf_config.php');
  * TCPDF project (http://www.tcpdf.org) has been originally derived in 2002 from the Public Domain FPDF class by Olivier Plathey (http://www.fpdf.org), but now is almost entirely rewritten.<br>
  * @package com.tecnick.tcpdf
  * @brief PHP class for generating PDF documents without requiring external extensions.
- * @version 5.9.187
+ * @version 5.9.188
  * @author Nicola Asuni - info@tecnick.com
  */
 class TCPDF {
@@ -162,7 +162,7 @@ class TCPDF {
 	 * Current TCPDF version.
 	 * @private
 	 */
-	private $tcpdf_version = '5.9.187';
+	private $tcpdf_version = '5.9.188';
 
 	// Protected properties