Index: /sandbox/workflow/branches/993/lib/factory/WorkflowFactory.php
===================================================================
--- /sandbox/workflow/branches/993/lib/factory/WorkflowFactory.php	(revision 2372)
+++ /sandbox/workflow/branches/993/lib/factory/WorkflowFactory.php	(revision 2533)
@@ -134,4 +134,9 @@
 		$this->registerFileInfo('NanoSanitizer', 'NanoSanitizer.class.php', 'inc/nano');
 
+		/* natural classes */
+		$this->registerFileInfo('PosString', 'pos_string.php', 'inc/natural');
+		$this->registerFileInfo('NatType', 'nat_types.php', 'inc/natural');
+		$this->registerFileInfo('NaturalResultSet', 'class.natural_resultset.php', 'inc/natural');
+
 		/* registering egw external classes */
 		$this->registerFileInfo('db', 'class.db.inc.php', '', EGW_INC_ROOT);
Index: /sandbox/workflow/branches/993/inc/class.run_activity.inc.php
===================================================================
--- /sandbox/workflow/branches/993/inc/class.run_activity.inc.php	(revision 2492)
+++ /sandbox/workflow/branches/993/inc/class.run_activity.inc.php	(revision 2533)
@@ -168,5 +168,4 @@
 		var $agents = Array();
 
-		/* CELEPAR */
 		/**
 		 * @var object $smarty holds a Smarty instance
@@ -194,7 +193,10 @@
          */
 		var $isChildInstance = false;
-
+		/**
+		 * @var object Stores a 'workflow_smarty' object
+         * @access private
+         */
 		private $workflowSmarty = null;
-		/* CELEPAR */
+
 		/**
 		 * Constructor
@@ -212,12 +214,10 @@
 			$this->runtime			= &Factory::newInstance('workflow_wfruntime');
 			$this->runtime->setDebug(_DEBUG);
-			//$this->base_activity	= Factory::getInstance('workflow_baseactivity');
-			//$this->process		= Factory::getInstance('workflow_process');
 			$this->GUI				= &Factory::getInstance('workflow_gui');
 			$this->categories 		= &Factory::getInstance('categories');
 
 			$this->workflowSmarty 	= &Factory::getInstance('workflow_smarty', false);
+
 			// TODO: open a new connection to the database under a different username to allow privilege handling on tables
-			/* CELEPAR */
 			unset($this->db);
 		}
@@ -335,5 +335,4 @@
 			$wf =& $GLOBALS['workflow'];
 
-			/* CELEPAR */
 			/* path to the local functions developed by Celepar */
 			$functions = PHPGW_SERVER_ROOT . SEP . 'workflow' . SEP . 'inc' . SEP . 'local' . SEP . 'functions' . SEP . 'local.functions.php';
@@ -341,5 +340,4 @@
 			/* activate local functions */
 			require_once($functions);
-			/* CELEPAR */
 
 			//get configuration options with default values if no init was done before
@@ -405,6 +403,4 @@
 				$this->download_mode = get_var('download_mode', array('POST','GET'), false);
 
-				/* #celepar# smarty code*/
-
 				$smarty = Factory::getInstance('process_smarty');
 
@@ -427,5 +423,5 @@
 				$smarty->assign('wf_back_link',$GLOBALS['workflow']['wf_back_link']);
 				$smarty->assign('wf_activity_url',$GLOBALS['workflow']['wf_activity_url']);
-				
+
 				/* register the prefilter smarty plugin wf_default_template */
 				$smarty->load_filter('pre', 'wf_default_template');
@@ -448,5 +444,4 @@
 			$security             =& Factory::newInstance('SecurityUtils');              //input sanitizer class
 			$env['request']       =& $security->process($_REQUEST);    //sanitizes input data from client
-			//$env['factory']       =& new ProcessFactory();             //instantiation controller class
 			$env['factory']       =& Factory::getInstance('ProcessWrapperFactory');  //instantiation controller class
 			$env['natural']		  =& wf_create_object('wf_natural');   //data access object instance for mainframe
@@ -454,9 +449,11 @@
 
 			$GLOBALS['workflow_env'] = &$env;
-			//echo "<br><br><br><br><br>Including $source <br>In request: <pre>";print_r($_REQUEST);echo "</pre>";
-			//[__leave_activity] is setted if needed in the xxx_pre code or by the user in his code
-			// HERE the user code is 'executed'. Note that we do not use include_once or require_once because
-			//it could the same code several times with automatic activities looping in the graph and it still
-			//need to be executed
+
+			/**
+			 * [__leave_activity] is setted if needed in the xxx_pre code or by the user in his code
+			 * HERE the user code is 'executed'. Note that we do not use include_once or require_once because
+			 * it could the same code several times with automatic activities looping in the graph and it still
+			 * need to be executed
+			 */
 			$_engineProcessCodeDirectory = GALAXIA_PROCESSES . SEP . $this->process->getNormalizedName(). SEP . 'code';
 			$_engineCompilerDirectory = GALAXIA_LIBRARY . SEP . 'compiler';
@@ -484,10 +481,8 @@
 
 			/**
-			 * XXX
-			 * here we are going to use our new Security static class.
+			 * Here we are going to use our new Security static class.
 			 * From now, the factory frontend (static) will forward
 			 * the messages for the process factory instead of Workflow
 			 * factory.
-			 * XXX
 			*/
 			Security::enable();
@@ -692,8 +687,6 @@
 				unset($GLOBALS['workflow']['wf_instance_url']);
 
-			/* CELEPAR */
 			/* activate local functions */
 			require_once(PHPGW_SERVER_ROOT . SEP . 'workflow' . SEP . 'inc' . SEP . 'local' . SEP . 'functions' . SEP . 'local.functions.php');
-			/* CELEPAR */
 
 			//get configuration options with default values if no init was done before
@@ -720,5 +713,4 @@
 			$security             =& Factory::newInstance('SecurityUtils'); //input sanitizer class
 			$env['request']       =& $security->process($_REQUEST); //sanitizes input data from client
-			//$env['factory']       =& new ProcessFactory();			   //instantiation controller class
 			$env['factory']       =& Factory::newInstance('ProcessWrapperFactory');  //instantiation controller class
 			$env['natural']		  =& wf_create_object('wf_natural');   //data access object instance for mainframe
@@ -735,5 +727,4 @@
 
 			/**
-			 * XXX
 			 * here we are going to use our new Security static class.
 			 * From now, the factory frontend (static) will forward
@@ -741,6 +732,5 @@
 			 * factory. Note that this is the same comment as the previous
 			 * function... boooring.. =}
-			 * XXX
-			*/
+			 */
 			Security::enable();
 
Index: /sandbox/workflow/branches/993/inc/local/classes/class.wf_workitem.php
===================================================================
--- /sandbox/workflow/branches/993/inc/local/classes/class.wf_workitem.php	(revision 795)
+++ /sandbox/workflow/branches/993/inc/local/classes/class.wf_workitem.php	(revision 2533)
@@ -29,5 +29,5 @@
 	public function wf_workitem()
 	{
-		$this->db = &$GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID;
+		$this->db = &Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID;
 		$this->processID = (int) $GLOBALS['workflow']['wf_runtime']->activity->getProcessId();
 	}
Index: /sandbox/workflow/branches/993/inc/local/classes/class.wf_role.php
===================================================================
--- /sandbox/workflow/branches/993/inc/local/classes/class.wf_role.php	(revision 2372)
+++ /sandbox/workflow/branches/993/inc/local/classes/class.wf_role.php	(revision 2533)
@@ -57,5 +57,5 @@
 			$this->processID = (int) $GLOBALS['workflow']['job']['processID'];
 
-		$this->db = &$GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID;
+		$this->db = &Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID;
 		$this->roleManager = Factory::getInstance('workflow_rolemanager');
 		$this->activityManager = Factory::getInstance('workflow_activitymanager');
Index: /sandbox/workflow/branches/993/inc/local/classes/class.wf_instance.php
===================================================================
--- /sandbox/workflow/branches/993/inc/local/classes/class.wf_instance.php	(revision 2372)
+++ /sandbox/workflow/branches/993/inc/local/classes/class.wf_instance.php	(revision 2533)
@@ -92,5 +92,5 @@
 	{
 		/* load the DB */
-		$this->db = &$GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID;
+		$this->db = &Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID;
 
 		/* load the process ID from the runtime */
Index: /sandbox/workflow/branches/993/inc/local/classes/class.wf_engine.php
===================================================================
--- /sandbox/workflow/branches/993/inc/local/classes/class.wf_engine.php	(revision 2372)
+++ /sandbox/workflow/branches/993/inc/local/classes/class.wf_engine.php	(revision 2533)
@@ -282,5 +282,5 @@
 		/* build the SQL query */
 		$query = "SELECT wf_activity_id, wf_name, wf_normalized_name, wf_type, wf_description FROM egw_wf_activities WHERE (wf_activity_id = ?) AND (wf_p_id = ?)";
-		$db = &$GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID;
+		$db = &Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID;
 		$resultSet = $db->query($query, array($activityID, $processID));
 
@@ -310,5 +310,5 @@
 		/* build the SQL query */
 		$query = "SELECT wf_activity_id, wf_name, wf_normalized_name, wf_type, wf_description FROM egw_wf_activities WHERE (wf_name = ?) AND (wf_p_id = ?)";
-		$db = &$GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID;
+		$db = &Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID;
 		$resultSet = $db->query($query, array($activityName, $processID));
 
Index: /sandbox/workflow/branches/993/inc/local/classes/class.wf_location.php
===================================================================
--- /sandbox/workflow/branches/993/inc/local/classes/class.wf_location.php	(revision 2160)
+++ /sandbox/workflow/branches/993/inc/local/classes/class.wf_location.php	(revision 2533)
@@ -36,5 +36,5 @@
 	function initialize()
 	{
-		$this->db = &$GLOBALS['workflow']['workflowObjects']->getDBExpresso()->Link_ID;
+		$this->db = &Factory::getInstance('WorkflowObjects')->getDBExpresso()->Link_ID;
 		$this->db->setFetchMode(ADODB_FETCH_ASSOC);
 		$this->cityInfo = array();
Index: /sandbox/workflow/branches/993/inc/local/classes/class.wf_orgchart.php
===================================================================
--- /sandbox/workflow/branches/993/inc/local/classes/class.wf_orgchart.php	(revision 2371)
+++ /sandbox/workflow/branches/993/inc/local/classes/class.wf_orgchart.php	(revision 2533)
@@ -24,5 +24,5 @@
 	function wf_orgchart()
 	{
-		$this->db = &$GLOBALS['workflow']['workflowObjects']->getDBWorkflow()->Link_ID;
+		$this->db = &Factory::getInstance('WorkflowObjects')->getDBWorkflow()->Link_ID;
 		$this->db->setFetchMode(ADODB_FETCH_ASSOC);
 	}
Index: /sandbox/workflow/branches/993/inc/local/classes/class.wf_ldap.php
===================================================================
--- /sandbox/workflow/branches/993/inc/local/classes/class.wf_ldap.php	(revision 2372)
+++ /sandbox/workflow/branches/993/inc/local/classes/class.wf_ldap.php	(revision 2533)
@@ -44,5 +44,5 @@
 		$this->group_context = $tmpLDAP->getGroupContext();
 
-		$this->ds = &$GLOBALS['workflow']['workflowObjects']->getLDAP();
+		$this->ds = &Factory::getInstance('WorkflowObjects')->getLDAP();
 
 		$this->cachedLDAP = &Factory::getInstance('wf_cached_ldap');
Index: /sandbox/workflow/branches/993/inc/natural/class.natural.php
===================================================================
--- /sandbox/workflow/branches/993/inc/natural/class.natural.php	(revision 795)
+++ /sandbox/workflow/branches/993/inc/natural/class.natural.php	(revision 2533)
@@ -196,5 +196,5 @@
 			try
 			{
-				$str = new PosString(new NatType);
+				$str = Factory::newInstance('PosString', Factory::newInstance('NatType'));
 				$this->strInputParameter = $str->mountString(array_merge($this->obj->input, $this->obj->output), $inputParams);
 
@@ -409,5 +409,5 @@
 	 	if (!empty($this->resultSet))
 	 		unset($this->resultSet);
-	 	$this->resultSet = new NaturalResultSet($result);
+	 	$this->resultSet = &Factory::newInstance('NaturalResultSet', $result);
 	 }
 }
Index: /sandbox/workflow/branches/993/inc/class.ui_adminprocesses.inc.php
===================================================================
--- /sandbox/workflow/branches/993/inc/class.ui_adminprocesses.inc.php	(revision 2492)
+++ /sandbox/workflow/branches/993/inc/class.ui_adminprocesses.inc.php	(revision 2533)
@@ -1,4 +1,3 @@
 <?php
-require_once 'common.inc.php';
 require_once(dirname(__FILE__) . SEP . 'class.bo_workflow_forms.inc.php');
 require_once('engine' . SEP . 'config.egw.inc.php');
Index: /sandbox/workflow/branches/993/inc/class.so_move_instances.inc.php
===================================================================
--- /sandbox/workflow/branches/993/inc/class.so_move_instances.inc.php	(revision 2372)
+++ /sandbox/workflow/branches/993/inc/class.so_move_instances.inc.php	(revision 2533)
@@ -111,5 +111,5 @@
 				$where[] = 'wf_p_id IS NULL';
 		}
-		$processManager = &Factory::getInstance('ProcessManager', $this->db);
+		$processManager = &Factory::getInstance('ProcessManager');
 
 		/* workaround to sort the result using two columns */
Index: /sandbox/workflow/branches/993/inc/engine/src/API/Instance.php
===================================================================
--- /sandbox/workflow/branches/993/inc/engine/src/API/Instance.php	(revision 2372)
+++ /sandbox/workflow/branches/993/inc/engine/src/API/Instance.php	(revision 2533)
@@ -1170,5 +1170,5 @@
     
     //lock rows and ensure access is granted
-    if (!(isset($this->security))) $this->security = &Factory::getInstance('WfSecurity', $this->db);
+    if (!(isset($this->security))) $this->security = &Factory::getInstance('WfSecurity');
     if (!($this->security->checkUserAction($activityId,$this->instanceId,'complete')))
     {
Index: /sandbox/workflow/branches/993/inc/engine/src/ProcessManager/ActivityManager.php
===================================================================
--- /sandbox/workflow/branches/993/inc/engine/src/ProcessManager/ActivityManager.php	(revision 2372)
+++ /sandbox/workflow/branches/993/inc/engine/src/ProcessManager/ActivityManager.php	(revision 2533)
@@ -1195,5 +1195,5 @@
     elseif ( (!($result=='*')) && $performAccessCheck)
     {
-      $wf_security = &Factory::getInstance('WfSecurity', $this->db);
+      $wf_security = &Factory::getInstance('WfSecurity');
       // perform the check
       if (!($wf_security->checkUserAccess($result,$activityId)))
Index: /sandbox/workflow/branches/993/inc/common.inc.php
===================================================================
--- /sandbox/workflow/branches/993/inc/common.inc.php	(revision 2492)
+++ /sandbox/workflow/branches/993/inc/common.inc.php	(revision 2533)
@@ -101,6 +101,3 @@
  */
 define('WF_BASE_URL', EGW_BASE_URL . "/workflow/");
-
-
-$GLOBALS['workflow']['workflowObjects'] = Factory::getInstance('WorkflowObjects');
 ?>
Index: /sandbox/workflow/branches/993/inc/class.WorkflowMacro.inc.php
===================================================================
--- /sandbox/workflow/branches/993/inc/class.WorkflowMacro.inc.php	(revision 2492)
+++ /sandbox/workflow/branches/993/inc/class.WorkflowMacro.inc.php	(revision 2533)
@@ -65,5 +65,5 @@
 		require_once PHPGW_SERVER_ROOT . '/workflow/inc/local/functions/local.functions.php';
 
-		$runtime = &Factory::getInstance('WfRuntime', Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
+		$runtime = &Factory::getInstance('WfRuntime');
 		$runtime->loadProcess($processID);
 
Index: /sandbox/workflow/branches/993/inc/class.so_userinterface.inc.php
===================================================================
--- /sandbox/workflow/branches/993/inc/class.so_userinterface.inc.php	(revision 2418)
+++ /sandbox/workflow/branches/993/inc/class.so_userinterface.inc.php	(revision 2533)
@@ -349,5 +349,5 @@
 	{
 		/* get ldap connection */
-		$ldap = &$GLOBALS['workflow']['workflowObjects']->getLDAP();
+		$ldap = &Factory::getInstance('WorkflowObjects')->getLDAP();
 
 		$searchTermExploded = explode(" ", $searchTerm);
@@ -429,5 +429,5 @@
 	{
 		/* get ldap connection */
-		$ldap = &$GLOBALS['workflow']['workflowObjects']->getLDAP();
+		$ldap = &Factory::getInstance('WorkflowObjects')->getLDAP();
 
 		/* makes no sense search for an area if the string has more than one word */
@@ -525,5 +525,5 @@
 
 		/* get ldap connection */
-		$ldap = &$GLOBALS['workflow']['workflowObjects']->getLDAP();
+		$ldap = &Factory::getInstance('WorkflowObjects')->getLDAP();
 
 		/* searching employees by telephoneNumber in the ldap server */
Index: /sandbox/workflow/branches/993/inc/nano/NanoGuardian.class.php
===================================================================
--- /sandbox/workflow/branches/993/inc/nano/NanoGuardian.class.php	(revision 2372)
+++ /sandbox/workflow/branches/993/inc/nano/NanoGuardian.class.php	(revision 2533)
@@ -32,5 +32,5 @@
     public function __construct()
     {
-        $this->_mObjNanoSanitizer = &Factory::newInstance('NanoSanitizer', new DummyLogger);
+        $this->_mObjNanoSanitizer = new NanoSanitizer(new DummyLogger);
     }
 
Index: /sandbox/workflow/branches/993/inc/nano/NanoJsonConverter.class.php
===================================================================
--- /sandbox/workflow/branches/993/inc/nano/NanoJsonConverter.class.php	(revision 2372)
+++ /sandbox/workflow/branches/993/inc/nano/NanoJsonConverter.class.php	(revision 2533)
@@ -118,6 +118,6 @@
         // initialize JSON object
         $this->_mObjJson = ( strtolower($return_type) != 'object' )
-                                ? Factory::getInstance('Services_JSON', SERVICES_JSON_LOOSE_TYPE )
-                                : Factory::getInstance('Services_JSON');
+                                ? new Services_JSON( SERVICES_JSON_LOOSE_TYPE )
+                                : new Services_JSON();
     }
 
Index: /sandbox/workflow/branches/993/inc/nano/NanoController.class.php
===================================================================
--- /sandbox/workflow/branches/993/inc/nano/NanoController.class.php	(revision 2372)
+++ /sandbox/workflow/branches/993/inc/nano/NanoController.class.php	(revision 2533)
@@ -59,6 +59,6 @@
     function __construct()
     {
-        $this->_mObjJsonConverter = &Factory::newInstance('NanoJsonConverter');
-        $this->_mObjJson          = &Factory::newInstance('Services_JSON');
+        $this->_mObjJsonConverter = new NanoJsonConverter();
+        $this->_mObjJson          = new Services_JSON();
     }
 
@@ -130,5 +130,5 @@
     public function iterateOverVirtualRequests()
     {
-        $this->_mObjNanoRequest = &Factory::newInstance('NanoRequest', $this->_mStrClassPath, $this->_mStrClassSuffix, $this->_mStrClassPreffix );
+        $this->_mObjNanoRequest = new NanoRequest( $this->_mStrClassPath, $this->_mStrClassSuffix, $this->_mStrClassPreffix );
         $return_data            = array();
 
