 	public override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) {
 		if self.currentAction == .Draw {
 			if self.currentTool == .Pencil {
-				// This is to generate a template
-				
-				var minX = CGFloat(HUGE)
-				var minY = CGFloat(HUGE)
-				
-				for point in self.pointsBuffer {
-					if point.x < minX {
-						minX = point.x
-					}
-					if point.y < minY {
-						minY = point.y
-					}
-				}
-				
-//				NSLog("BEGIN")
-//				for point in self.pointsBuffer {
-//					NSLog("%f, %f", point.x - minX, point.y - minY)
-//				}
-//				NSLog("END")
+
+				self.printTemplateSource(self.pointsBuffer)
+			
 				let smartPath = ATSmartBezierPath(withPoints: self.pointsBuffer)
 				var pathAppended = false
 				
 				if self.recognizeDrawing {
 					let recognizedPathInfo = smartPath.recognizedPath()
-
+					
 					if recognizedPathInfo != nil {
 						
 						var recognizedPathIsAccepted = false

				self.layer.setNeedsDisplay()
			}
		}
	}
	
	public override func touchesCancelled(touches: Set<UITouch>?, withEvent event: UIEvent?) {

		
		if event != nil {
		}
		
		let touchPoint = touches.first!.preciseLocationInView(self)
		
		self.touchDownPoint = touchPoint
