Index: sandbox/workflow/branches/609/lib/factory/WorkflowFactory.php
===================================================================
--- sandbox/workflow/branches/609/lib/factory/WorkflowFactory.php	(revision 2291)
+++ sandbox/workflow/branches/609/lib/factory/WorkflowFactory.php	(revision 2311)
@@ -54,4 +54,5 @@
 		$this->registerFileInfo('WorkflowMacro', 'class.WorkflowMacro.inc.php', 'inc');
 		$this->registerFileInfo('WorkflowJobManager', 'class.WorkflowJobManager.inc.php', 'inc');
+		$this->registerFileInfo('SecurityUtils', 'class.utils.security.php', 'inc');
 		$this->registerFileInfo('ResourcesRedirector', 'class.ResourcesRedirector.inc.php', 'inc');
 		$this->registerFileInfo('TemplateServer', 'class.TemplateServer.inc.php', 'inc');
@@ -59,7 +60,10 @@
 		$this->registerFileInfo('BrowserInfo', 'class.BrowserInfo.inc.php', 'inc');
 		$this->registerFileInfo('JobScheduler', 'class.JobScheduler.inc.php', 'inc');
+		$this->registerFileInfo('JobRunner', 'class.JobRunner.inc.php', 'inc');
 		$this->registerFileInfo('Thread', 'class.Thread.inc.php', 'inc');
 		$this->registerFileInfo('Paging', 'class.Paging.inc.php', 'inc');
+		$this->registerFileInfo('FsUtils', 'class.fsutils.inc.php', 'inc');
 		$this->registerFileInfo('UserPictureProvider', 'class.UserPictureProvider.inc.php', 'inc');
+		$this->registerFileInfo('powergraphic', 'class.powergraphic.inc.php', 'inc');
 
 		$this->registerFileInfo('run_activity', 'class.run_activity.inc.php', 'inc');
@@ -82,4 +86,48 @@
 
 		$this->registerFileInfo('so_agent_mail_smtp', 'class.so_agent_mail_smtp.inc.php', 'inc');
+		$this->registerFileInfo('so_external_applications', 'class.so_external_applications.inc.php', 'inc');
+		$this->registerFileInfo('so_adminaccess', 'class.so_adminaccess.inc.php', 'inc');
+		$this->registerFileInfo('so_orgchart', 'class.so_orgchart.inc.php', 'inc');
+		$this->registerFileInfo('so_userinterface', 'class.so_userinterface.inc.php', 'inc');
+		$this->registerFileInfo('so_adminjobs', 'class.so_adminjobs.inc.php', 'inc');
+		$this->registerFileInfo('so_move_instances', 'class.so_move_instances.inc.php', 'inc');
+
+		/* job classes */
+		$this->registerFileInfo('AbsoluteDate', 'class.AbsoluteDate.inc.php', 'inc/jobs');
+		$this->registerFileInfo('RelativeDate', 'class.RelativeDate.inc.php', 'inc/jobs');
+		$this->registerFileInfo('WeekDate', 'class.WeekDate.inc.php', 'inc/jobs');
+
+		/* galaxia engine classes */
+		$this->registerFileInfo('GUI', 'GUI.php', 'inc/engine/src/GUI');
+		$this->registerFileInfo('ProcessManager', 'ProcessManager.php', 'inc/engine/src/ProcessManager');
+		$this->registerFileInfo('ActivityManager', 'ActivityManager.php', 'inc/engine/src/ProcessManager');
+		$this->registerFileInfo('InstanceManager', 'InstanceManager.php', 'inc/engine/src/ProcessManager');
+		$this->registerFileInfo('RoleManager', 'RoleManager.php', 'inc/engine/src/ProcessManager');
+		$this->registerFileInfo('JobManager', 'JobManager.php', 'inc/engine/src/ProcessManager');
+		$this->registerFileInfo('Process_GraphViz', 'GraphViz.php', 'inc/engine/src/ProcessManager');
+		$this->registerFileInfo('ProcessMonitor', 'ProcessMonitor.php', 'inc/engine/src/ProcessMonitor');
+		$this->registerFileInfo('Process', 'Process.php', 'inc/engine/src/API');
+		$this->registerFileInfo('Instance', 'Instance.php', 'inc/engine/src/API');
+		$this->registerFileInfo('Start', 'Start.php', 'inc/engine/src/API/activities');
+		$this->registerFileInfo('End', 'End.php', 'inc/engine/src/API/activities');
+		$this->registerFileInfo('Join', 'Join.php', 'inc/engine/src/API/activities');
+		$this->registerFileInfo('Split', 'Split.php', 'inc/engine/src/API/activities');
+		$this->registerFileInfo('Standalone', 'Standalone.php', 'inc/engine/src/API/activities');
+		$this->registerFileInfo('View', 'View.php', 'inc/engine/src/API/activities');
+		$this->registerFileInfo('SwitchActivity', 'SwitchActivity.php', 'inc/engine/src/API/activities');
+		$this->registerFileInfo('Activity', 'Activity.php', 'inc/engine/src/API/activities');
+		$this->registerFileInfo('BaseActivity', 'BaseActivity.php', 'inc/engine/src/API');
+
+		$this->registerFileInfo('ajax_ldap', 'class.ajax_ldap.inc.php', 'inc/engine');
+		$this->registerFileInfo('ajax_config', 'class.ajax_config.inc.php', 'inc/engine');
+		$this->registerFileInfo('WfRuntime', 'WfRuntime.php', 'inc/engine/src/common');
+		$this->registerFileInfo('WfSecurity', 'WfSecurity.php', 'inc/engine/src/common');
+
+		/* nano classes */
+		$this->registerFileInfo('Services_JSON', 'JSON.php', 'inc/nano');
+		$this->registerFileInfo('NanoRequest', 'NanoRequest.class.php', 'inc/nano');
+		$this->registerFileInfo('NanoController', 'NanoController.class.php', 'inc/nano');
+		$this->registerFileInfo('NanoJsonConverter', 'NanoJsonConverter.class.php', 'inc/nano');
+		$this->registerFileInfo('NanoSanitizer', 'NanoSanitizer.class.php', 'inc/nano');
 
 		/* registering egw external classes */
Index: sandbox/workflow/branches/609/lib/factory/ProcessFactory.php
===================================================================
--- sandbox/workflow/branches/609/lib/factory/ProcessFactory.php	(revision 2249)
+++ sandbox/workflow/branches/609/lib/factory/ProcessFactory.php	(revision 2311)
@@ -50,4 +50,5 @@
 		$this->registerFileInfo('wf_orgchart', 'class.wf_orgchart.php', 'inc/local/classes');
 		$this->registerFileInfo('wf_ldap', 'class.wf_ldap.php', 'inc/local/classes');
+		$this->registerFileInfo('wf_cached_ldap', 'class.wf_cached_ldap.php', 'inc/local/classes');
 		$this->registerFileInfo('wf_engine', 'class.wf_engine.php', 'inc/local/classes');
 		$this->registerFileInfo('wf_role', 'class.wf_role.php', 'inc/local/classes');
Index: sandbox/workflow/branches/609/inc/class.bo_utils.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.bo_utils.inc.php	(revision 2233)
+++ sandbox/workflow/branches/609/inc/class.bo_utils.inc.php	(revision 2311)
@@ -88,5 +88,5 @@
 			$ret_name = empty($params['name']) ? 'cn' : $params['name'];
 
-			$ajaxConfig = new ajax_config('contactcenter');
+			$ajaxConfig = &Factory::getInstance('ajax_config', 'contactcenter');
 			$config = $ajaxConfig->read_repository();
 
Index: sandbox/workflow/branches/609/inc/class.run_activity.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.run_activity.inc.php	(revision 2264)
+++ sandbox/workflow/branches/609/inc/class.run_activity.inc.php	(revision 2311)
@@ -14,5 +14,4 @@
 	require_once(dirname(__FILE__) . SEP . 'class.basecontroller.inc.php' ); /* module controller            */
 	require_once(dirname(__FILE__) . SEP . 'class.basemodel.inc.php'      ); /* module logic                 */
-	require_once(dirname(__FILE__) . SEP . 'class.utils.security.php'     ); /* sanitizes input data         */
 
 	/**
@@ -438,5 +437,5 @@
 			$env['instance']      =& $instance;                        //process manager instance
 			$env['activity']      =& $activity;                        //activity manager instance
-			$security             =& new SecurityUtils();              //input sanitizer class
+			$security             =& Factory::newInstance('SecurityUtils');              //input sanitizer class
 			$env['request']       =& $security->process($_REQUEST);    //sanitizes input data from client
 			//$env['factory']       =& new ProcessFactory();             //instantiation controller class
@@ -710,5 +709,5 @@
 			$env['instance']      =& $instance;                        //process manager instance
 			$env['activity']      =& $activity;                        //activity manager instance
-			$security             =& new SecurityUtils();              //input sanitizer class
+			$security             =& Factory::newInstance('SecurityUtils'); //input sanitizer class
 			$env['request']       =& $security->process($_REQUEST); //sanitizes input data from client
 			//$env['factory']       =& new ProcessFactory();			   //instantiation controller class
@@ -738,5 +737,5 @@
 
 			$GLOBALS['workflow_env'] = &$env;
-			$nc = new NanoController();
+			$nc = &Factory::newInstance('NanoController');
 			$nc->setClassPath(GALAXIA_PROCESSES . SEP . $this->process->getNormalizedName(). SEP . 'code');
 			$nc->iterateOverVirtualRequests();
Index: sandbox/workflow/branches/609/inc/local/classes/class.wf_instance.php
===================================================================
--- sandbox/workflow/branches/609/inc/local/classes/class.wf_instance.php	(revision 2292)
+++ sandbox/workflow/branches/609/inc/local/classes/class.wf_instance.php	(revision 2311)
@@ -423,6 +423,5 @@
 
 		/* load the required instance (for the required user) */
-		require_once GALAXIA_LIBRARY . SEP . 'src' . SEP . 'GUI' . SEP . 'GUI.php';
-		$GUI = new GUI($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);
+		$GUI = &Factory::newInstance('GUI');
 		$userInstance = $GUI->gui_list_user_instances($userID, 0, -1, '', '', "(ga.wf_is_interactive = 'y') AND (gia.wf_activity_id = {$activityID}) AND (gia.wf_instance_id = {$instanceID})", false, $this->processID, true, false, true, false, false, false);
 		$userInstance = $userInstance['data'];
Index: sandbox/workflow/branches/609/inc/local/classes/class.wf_engine.php
===================================================================
--- sandbox/workflow/branches/609/inc/local/classes/class.wf_engine.php	(revision 2292)
+++ sandbox/workflow/branches/609/inc/local/classes/class.wf_engine.php	(revision 2311)
@@ -191,5 +191,5 @@
 	function getChildInstances($instanceID = null, $activityID = null)
 	{
-		$WFInstance = Factory::getInstance('wf_instance');
+		$WFInstance = &Factory::getInstance('wf_instance');
 		$preOutput = $WFInstance->getChildren($instanceID, $activityID);
 		$output = array();
Index: sandbox/workflow/branches/609/inc/local/classes/class.wf_ldap.php
===================================================================
--- sandbox/workflow/branches/609/inc/local/classes/class.wf_ldap.php	(revision 2249)
+++ sandbox/workflow/branches/609/inc/local/classes/class.wf_ldap.php	(revision 2311)
@@ -1,4 +1,3 @@
 <?php
-require_once PHPGW_SERVER_ROOT . SEP . 'workflow' . SEP . 'inc' . SEP . 'local' . SEP . 'classes' . SEP . 'class.wf_cached_ldap.php';
 
 /**
@@ -47,5 +46,5 @@
 		$this->ds = &$GLOBALS['workflow']['workflowObjects']->getLDAP();
 
-		$this->cachedLDAP = new wf_cached_ldap();
+		$this->cachedLDAP = &Factory::getInstance('wf_cached_ldap');
 		$this->cachedLDAP->setOperationMode($this->cachedLDAP->OPERATION_MODE_LDAP);
 	}
Index: sandbox/workflow/branches/609/inc/class.bo_adminaccess.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.bo_adminaccess.inc.php	(revision 2233)
+++ sandbox/workflow/branches/609/inc/class.bo_adminaccess.inc.php	(revision 2311)
@@ -11,8 +11,5 @@
 
 require_once('class.bo_ajaxinterface.inc.php');
-require_once('class.so_adminaccess.inc.php');
-require_once(GALAXIA_LIBRARY . SEP . 'src' . SEP . 'ProcessManager' . SEP . 'ProcessManager.php');
 require_once(PHPGW_API_INC . SEP . 'common_functions.inc.php');
-require_once(PHPGW_API_INC . SEP . 'class.acl.inc.php');
 
 /**
@@ -46,5 +43,5 @@
 			exit(serialize(array('error' => 'Você não tem permissão para executar esta operação.')));
 
-		$this->so = new so_adminaccess(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
+		$this->so = &Factory::getInstance('so_adminaccess', Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
 	}
 
@@ -57,5 +54,5 @@
 	function get_all_processes()
 	{
-		$proc_mng = new ProcessManager(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
+		$proc_mng = &Factory::newInstance('ProcessManager');
 		$proc_list = $proc_mng->list_processes(0,-1,'wf_name__ASC');
 
@@ -315,5 +312,5 @@
 	{
 		$GLOBALS['phpgw']->db = $GLOBALS['ajax']->db;
-		$acl = new ACL();
+		$acl = &Factory::getInstance('acl');
 		$output = $this->so->getUserNames($acl->get_ids_for_location('admin_workflow', 1, 'workflow'));
 		unset($GLOBALS['phpgw']->db);
@@ -332,5 +329,5 @@
 		$ids = explode('.', str_replace('g', '', str_replace('u', '', $params['user_ids'])));
 		$GLOBALS['phpgw']->db = $GLOBALS['ajax']->db;
-		$acl = new ACL();
+		$acl = &Factory::getInstance('acl');
 		foreach ($ids as $id)
 			$acl->add_repository('workflow', 'admin_workflow', $id, 1);
@@ -350,5 +347,5 @@
 	{
 		$GLOBALS['phpgw']->db = $GLOBALS['ajax']->db;
-		$acl = new ACL();
+		$acl = &Factory::getInstance('acl');
 		$acl->delete_repository('workflow', 'admin_workflow', (int) $params['admin_id']);
 		unset($GLOBALS['phpgw']->db);
Index: sandbox/workflow/branches/609/inc/class.powergraphic.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.powergraphic.inc.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/class.powergraphic.inc.php	(revision 2311)
@@ -141,5 +141,5 @@
 
 
-$PowerGraphic = new powergraphic;
+$PowerGraphic = &Factory::newInstance('powergraphic');
 
 $PowerGraphic->start();
Index: sandbox/workflow/branches/609/inc/class.ui_userinterface.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.ui_userinterface.inc.php	(revision 2253)
+++ sandbox/workflow/branches/609/inc/class.ui_userinterface.inc.php	(revision 2311)
@@ -129,7 +129,6 @@
 
 		/* create some objects */
-		require_once 'class.so_userinterface.inc.php';
-		$so = new so_userinterface();
-		$smarty = Factory::getInstance('workflow_smarty');
+		$so = &Factory::getInstance('so_userinterface');
+		$smarty = &Factory::getInstance('workflow_smarty');
 
 		/* get the user's organization */
Index: sandbox/workflow/branches/609/inc/class.bo_move_instances.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.bo_move_instances.inc.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/class.bo_move_instances.inc.php	(revision 2311)
@@ -12,6 +12,4 @@
 
 require_once('class.bo_ajaxinterface.inc.php');
-require_once('class.so_move_instances.inc.php');
-require_once('nano/JSON.php');
 
 
@@ -39,5 +37,5 @@
 	{
 		parent::bo_ajaxinterface();
-		$this->so = new so_move_instances();
+		$this->so = &Factory::getInstance('so_move_instances');
 	}
 
@@ -79,5 +77,5 @@
 	function moveInstances($params)
 	{
-		$JSON = new Services_JSON();
+		$JSON = &Factory::newInstance('Services_JSON');
 
 		/* convert the mappgin element to array */
Index: sandbox/workflow/branches/609/inc/class.workflow_processmanager.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.workflow_processmanager.inc.php	(revision 2253)
+++ sandbox/workflow/branches/609/inc/class.workflow_processmanager.inc.php	(revision 2311)
@@ -34,5 +34,5 @@
 		function workflow_processmanager()
 		{
-			parent::ProcessManager(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
+			parent::ProcessManager();
 			$this->workflow_acl = Factory::getInstace('workflow_acl');
 
@@ -62,5 +62,5 @@
 		function import_process(&$data)
 		{
-			if (!(isset($this->activity_manager)))  $this->activity_manager = new ActivityManager($this->db);
+			if (!(isset($this->activity_manager)))  $this->activity_manager = &Factory::newInstance('ActivityManager');
 
 			if (parent::import_process($data))
@@ -121,7 +121,7 @@
 		function serialize_process($pId)
 	  	{
-			if (!(isset($this->activity_manager)))  $this->activity_manager = new ActivityManager($this->db);
+			if (!(isset($this->activity_manager)))  $this->activity_manager = &Factory::newInstance('ActivityManager');
 			if (!isset($this->jobManager))
-				$this->jobManager = new JobManager($this->db);
+				$this->jobManager = &Factory::newInstance('JobManager');
 		
 			//if (!(isset($this->activity_manager)))  $this->activity_manager = new ActivityManager($this->db);
Index: sandbox/workflow/branches/609/inc/class.so_move_instances.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.so_move_instances.inc.php	(revision 2233)
+++ sandbox/workflow/branches/609/inc/class.so_move_instances.inc.php	(revision 2311)
@@ -11,6 +11,4 @@
 \**************************************************************************/
 
-require_once(GALAXIA_LIBRARY . SEP . 'src' . SEP . 'ProcessManager' . SEP . 'ProcessManager.php');
-require_once(GALAXIA_LIBRARY . SEP . 'src' . SEP . 'ProcessManager' . SEP . 'ActivityManager.php');
 
 /**
@@ -113,5 +111,5 @@
 				$where[] = 'wf_p_id IS NULL';
 		}
-		$processManager = new ProcessManager($this->db);
+		$processManager = &Factory::getInstance('ProcessManager', $this->db);
 
 		/* workaround to sort the result using two columns */
@@ -137,5 +135,5 @@
 		$this->_checkAccess($processID);
 
-		$activityManager = new ActivityManager($this->db);
+		$activityManager = &Factory::newInstance('ActivityManager');
 		$activities = $activityManager->list_activities($processID, 0, -1, 'wf_name__ASC', '', 'wf_type <> \'standalone\' AND wf_type <> \'view\'');
 		$output = array();
Index: sandbox/workflow/branches/609/inc/class.bo_ajaxinterface.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.bo_ajaxinterface.inc.php	(revision 2233)
+++ sandbox/workflow/branches/609/inc/class.bo_ajaxinterface.inc.php	(revision 2311)
@@ -37,8 +37,6 @@
 require_once(PHPGW_SERVER_ROOT . SEP . 'workflow' . SEP . 'inc' . SEP . 'common.inc.php');
 require_once(PHPGW_API_INC . SEP . 'class.db.inc.php');
-require_once(PHPGW_SERVER_ROOT . SEP . 'workflow' . SEP . 'inc' . SEP . 'engine' . SEP . 'class.ajax_ldap.inc.php');
 require_once(PHPGW_SERVER_ROOT . SEP . 'workflow' . SEP . 'inc' . SEP . 'engine' . SEP . 'class.ajax_config.inc.php');
 require_once(PHPGW_SERVER_ROOT . SEP . 'workflow' . SEP . 'inc' . SEP . 'engine' . SEP . 'config.ajax.inc.php');
-require_once(PHPGW_SERVER_ROOT . SEP . 'workflow' . SEP . 'inc' . SEP . 'class.so_adminaccess.inc.php');
 
 /**
@@ -66,5 +64,5 @@
 		if (isset($_SESSION['phpgw_info']['workflow']['account_id']))
 		{
-			$GLOBALS['ajax']->ldap = new ajax_ldap();
+			$GLOBALS['ajax']->ldap = &Factory::getInstance('ajax_ldap');
 			$GLOBALS['ajax']->db =& Factory::getInstance('WorkflowObjects')->getDBExpresso();
 			$GLOBALS['ajax']->db->Halt_On_Error = 'no';
@@ -74,5 +72,5 @@
 
 			$GLOBALS['phpgw']->ADOdb = &$GLOBALS['ajax']->db->Link_ID;
-			$GLOBALS['ajax']->acl = new so_adminaccess(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
+			$GLOBALS['ajax']->acl = &Factory::getInstance('so_adminaccess', Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
 		}
 		else
Index: sandbox/workflow/branches/609/inc/engine/config.ajax.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/engine/config.ajax.inc.php	(revision 2233)
+++ sandbox/workflow/branches/609/inc/engine/config.ajax.inc.php	(revision 2311)
@@ -256,5 +256,5 @@
 	function galaxia_get_config_values($parameters=array())
 	{
-			$config = new ajax_config();
+			$config = &Factory::getInstance('ajax_config');
 			$config->read_repository();
 
Index: sandbox/workflow/branches/609/inc/engine/src/GUI/GUI.php
===================================================================
--- sandbox/workflow/branches/609/inc/engine/src/GUI/GUI.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/engine/src/GUI/GUI.php	(revision 2311)
@@ -32,10 +32,9 @@
    * @access public
    */
-  function GUI(&$db) 
+  function GUI()
   {
     $this->child_name = 'GUI';
-    parent::Base($db);
-    require_once(GALAXIA_LIBRARY.SEP.'src'.SEP.'common'.SEP.'WfSecurity.php');
-    $this->wf_security =& new WfSecurity($this->db); 
+    parent::Base();
+    $this->wf_security = &Factory::getInstance('WfSecurity');
   }
 
@@ -703,6 +702,5 @@
       if (!(isset($this->pm)))
       {
-        require_once(GALAXIA_LIBRARY.SEP.'src'.SEP.'ProcessManager'.SEP.'ProcessManager.php');
-        $this->pm =& new ProcessManager($this->db);
+        $this->pm = &Factory::newInstance('ProcessManager');
       }
       $this->process_cache[$pId]['view'] = $this->pm->get_process_view_activity($pId);
@@ -871,5 +869,5 @@
     {
       //the security object said everything was fine
-      $instance = new Instance($this->db);
+      $instance = &Factory::newInstance('Instance');
       $instance->getInstance($instanceId);
       if (!empty($instance->instanceId)) 
@@ -975,5 +973,5 @@
     {
       //the security object said everything was fine
-      $instance =& new Instance($this->db);
+      $instance = &Factory::newInstance('Instance');
       $instance->getInstance($instanceId);
       // we force the execution of the activity
@@ -1012,5 +1010,5 @@
     {
       //the security object said everything was fine
-      $instance =& new Instance($this->db);
+      $instance = &Factory::newInstance('Instance');
       $instance->getInstance($instanceId);
       // we force the continuation of the flow
Index: sandbox/workflow/branches/609/inc/engine/src/ProcessMonitor/ProcessMonitor.php
===================================================================
--- sandbox/workflow/branches/609/inc/engine/src/ProcessMonitor/ProcessMonitor.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/engine/src/ProcessMonitor/ProcessMonitor.php	(revision 2311)
@@ -18,8 +18,8 @@
    * @access public
    */
-  function ProcessMonitor(&$db)
+  function ProcessMonitor()
   {
     $this->child_name = 'ProcessMonitor';
-    parent::Base($db);
+    parent::Base();
     // check the the actual user can really do this
     if ( !(galaxia_user_can_monitor()))
Index: sandbox/workflow/branches/609/inc/engine/src/common/Base.php
===================================================================
--- sandbox/workflow/branches/609/inc/engine/src/common/Base.php	(revision 2165)
+++ sandbox/workflow/branches/609/inc/engine/src/common/Base.php	(revision 2311)
@@ -39,4 +39,12 @@
   	var $child_name = 'Base';
 
+	/**
+	 * @var object $db_shared_obj The database abstraction object shared between
+	 *						      all instances of this class.
+	 * @acess private
+	 * @static
+	 */
+	private static $db_shared_obj = null;
+
   /**
    * Constructor receiving a database abstraction object
@@ -46,14 +54,34 @@
    * @access public
    */
-  function Base(&$db)
+  function Base()
   {
-    if(!$db) {
+  	/**
+	 * New Stuff!
+	 * We decided to get here the database object. In a recent past,
+	 * all the classes that specialize this one passed a db object.
+	 * Now, to simplify and save memory, we store the database object
+	 * into a single and static atribute shared among each instance
+	 * of this class.
+	 *
+	 * To prevent to modify all sub-classes to use "self::$db" instead
+	 * of "this->db", we made a very tiny workaround here. In the first
+	 * instantiation of this class, we instantiate the database object
+	 * and store it into 'self::$db_shared_obj'. Any subsequent
+	 * instantiations will just point to the static one.
+	 */
+	if (!self::$db_shared_obj)
+		self::$db_shared_obj = &Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID;
+
+	$this->db = &self::$db_shared_obj;
+
+
+    if(!$this->db) {
       die('Invalid db object passed to '.$this->child_name.' constructor');
     }
     //Force transactionnal mysql (Innodb) -> mysqlt
-    if ($db->databaseType=='mysql')
+    if ($this->db->databaseType=='mysql')
     {
     	$GLOBALS['phpgw']->db->disconnect();
-    	$db = $GLOBALS['phpgw']->db->connect(
+    	$this->db = $GLOBALS['phpgw']->db->connect(
 			$GLOBALS['phpgw_info']['server']['db_name'],
 			$GLOBALS['phpgw_info']['server']['db_host'],
@@ -64,5 +92,4 @@
 		);
     }
-    $this->db = &$db;
   }
 
Index: sandbox/workflow/branches/609/inc/engine/src/common/WfRuntime.php
===================================================================
--- sandbox/workflow/branches/609/inc/engine/src/common/WfRuntime.php	(revision 2253)
+++ sandbox/workflow/branches/609/inc/engine/src/common/WfRuntime.php	(revision 2311)
@@ -86,18 +86,14 @@
    * @access public
    */
-  function WfRuntime(&$db) 
+  function WfRuntime() 
   {
     $this->child_name = 'WfRuntime';
-    parent::Base($db);
-    require_once(GALAXIA_LIBRARY.SEP.'src'.SEP.'API'.SEP.'BaseActivity.php');
-    require_once(GALAXIA_LIBRARY.SEP.'src'.SEP.'API'.SEP.'Process.php');
-    require_once(GALAXIA_LIBRARY.SEP.'src'.SEP.'API'.SEP.'Instance.php');
-    require_once(GALAXIA_LIBRARY.SEP.'src'.SEP.'common'.SEP.'WfSecurity.php');
-    
+    parent::Base();
+
     //first the activity is not set
     $this->activity = null;
-    $this->instance = new Instance($this->db);
-    $this->process = new Process($this->db);
-    $this->security = new WfSecurity($this->db); 
+    $this->instance = &Factory::newInstance('Instance');
+    $this->process = &Factory::newInstance('Process');
+    $this->security = &Factory::getInstance('WfSecurity');
   }
 
@@ -276,5 +272,5 @@
       return false;
     }
-    $base_activity = new BaseActivity($this->db);
+    $base_activity = &Factory::getInstance('BaseActivity', $this->db);
     $this->activity =& $base_activity->getActivity($activity_id, $with_roles, $with_agents);
     if (!$this->activity)
Index: sandbox/workflow/branches/609/inc/engine/src/common/WfSecurity.php
===================================================================
--- sandbox/workflow/branches/609/inc/engine/src/common/WfSecurity.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/engine/src/common/WfSecurity.php	(revision 2311)
@@ -23,11 +23,14 @@
    * @access public
    */
-  function WfSecurity(&$db) 
+  function WfSecurity() 
   {
     $this->child_name = 'WfSecurity';
-    parent::Base($db);
-    require_once(GALAXIA_LIBRARY.SEP.'src'.SEP.'API'.SEP.'Instance.php');
-    require_once(GALAXIA_LIBRARY.SEP.'src'.SEP.'API'.SEP.'Process.php');
-    require_once(GALAXIA_LIBRARY.SEP.'src'.SEP.'API'.SEP.'BaseActivity.php');
+    parent::Base();
+
+	/* I'm not really sure if we can strip it out. */
+
+    //require_once(GALAXIA_LIBRARY.SEP.'src'.SEP.'API'.SEP.'Instance.php');
+    //require_once(GALAXIA_LIBRARY.SEP.'src'.SEP.'API'.SEP.'Process.php');
+    //require_once(GALAXIA_LIBRARY.SEP.'src'.SEP.'API'.SEP.'BaseActivity.php');
   }
 
@@ -58,5 +61,5 @@
       );
       //check theses values for this process and store the result for this object life duration
-      $myProcess = new Process($this->db);
+      $myProcess = &Factory::newInstance('Process');
       $myProcess->getProcess($pId);
       $this->processesConfig[$pId] = $myProcess->getConfigValues($arrayConf);
@@ -577,6 +580,5 @@
       if (!(isset($this->pm)))
       {
-        require_once(GALAXIA_LIBRARY.SEP.'src'.SEP.'ProcessManager'.SEP.'ProcessManager.php');
-        $this->pm = new ProcessManager($this->db);
+        $this->pm = &Factory::newInstance('ProcessManager');
       }
       //$this->error[] = 'DEBUG: checking to see if there is no view activities on process :'.$pId.':'.$this->pm->get_process_view_activity($pId);
Index: sandbox/workflow/branches/609/inc/engine/src/API/Process.php
===================================================================
--- sandbox/workflow/branches/609/inc/engine/src/API/Process.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/engine/src/API/Process.php	(revision 2311)
@@ -48,8 +48,8 @@
 	 * @access public
 	 */
-	function Process(&$db) 
+	function Process() 
 	{
 		$this->child_name = 'Process';
-		parent::Base($db);
+		parent::Base();
 	}
 
Index: sandbox/workflow/branches/609/inc/engine/src/API/activities/View.php
===================================================================
--- sandbox/workflow/branches/609/inc/engine/src/API/activities/View.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/engine/src/API/activities/View.php	(revision 2311)
@@ -16,7 +16,7 @@
 	 * @access public
 	 */	
-	function View(&$db)
+	function View()
 	{
-	 	parent::Base($db);
+	 	parent::Base();
 		$this->child_name = 'View';
 	}
Index: sandbox/workflow/branches/609/inc/engine/src/API/activities/Split.php
===================================================================
--- sandbox/workflow/branches/609/inc/engine/src/API/activities/Split.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/engine/src/API/activities/Split.php	(revision 2311)
@@ -15,7 +15,7 @@
 	 * @access public
 	 */
-	function Split(&$db)
+	function Split()
 	{
-	 	parent::Base($db);
+	 	parent::Base();
 		$this->child_name = 'Split';
 	}
Index: sandbox/workflow/branches/609/inc/engine/src/API/activities/Activity.php
===================================================================
--- sandbox/workflow/branches/609/inc/engine/src/API/activities/Activity.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/engine/src/API/activities/Activity.php	(revision 2311)
@@ -16,7 +16,7 @@
 	 * @access public
 	 */
-	function Activity(&$db)
+	function Activity()
 	{
-		parent::Base($db);
+		parent::Base();
 		$this->child_name = 'Activity';
 	}
Index: sandbox/workflow/branches/609/inc/engine/src/API/activities/Start.php
===================================================================
--- sandbox/workflow/branches/609/inc/engine/src/API/activities/Start.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/engine/src/API/activities/Start.php	(revision 2311)
@@ -15,7 +15,7 @@
 	 * @access public
 	 */
-	function Start(&$db)
+	function Start()
 	{
-	 	parent::Base($db);
+	 	parent::Base();
 		$this->child_name = 'Start';
 	}
Index: sandbox/workflow/branches/609/inc/engine/src/API/activities/SwitchActivity.php
===================================================================
--- sandbox/workflow/branches/609/inc/engine/src/API/activities/SwitchActivity.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/engine/src/API/activities/SwitchActivity.php	(revision 2311)
@@ -16,7 +16,7 @@
 	 * @access public
 	 */
-	function SwitchActivity(&$db)
+	function SwitchActivity()
 	{
-	   parent::Base($db);
+	   parent::Base();
 	   $this->child_name = 'Switch';
 	}
Index: sandbox/workflow/branches/609/inc/engine/src/API/activities/Join.php
===================================================================
--- sandbox/workflow/branches/609/inc/engine/src/API/activities/Join.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/engine/src/API/activities/Join.php	(revision 2311)
@@ -15,7 +15,7 @@
 	 * @access public
 	 */
-	function Join(&$db)
+	function Join()
 	{
-	 	parent::Base($db);
+	 	parent::Base();
 		$this->child_name = 'Join';
 	}
Index: sandbox/workflow/branches/609/inc/engine/src/API/activities/End.php
===================================================================
--- sandbox/workflow/branches/609/inc/engine/src/API/activities/End.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/engine/src/API/activities/End.php	(revision 2311)
@@ -15,7 +15,7 @@
 	 * @access public
 	 */
-	function End(&$db)
+	function End()
 	{
-	 	parent::Base($db);
+	 	parent::Base();
 		$this->child_name = 'End';
 	}
Index: sandbox/workflow/branches/609/inc/engine/src/API/activities/Standalone.php
===================================================================
--- sandbox/workflow/branches/609/inc/engine/src/API/activities/Standalone.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/engine/src/API/activities/Standalone.php	(revision 2311)
@@ -15,7 +15,7 @@
 	 * @access public
 	 */
-	function Standalone(&$db)
+	function Standalone()
 	{
-	 	parent::Base($db);
+	 	parent::Base();
 		$this->child_name = 'Standalone';
 	}
Index: sandbox/workflow/branches/609/inc/engine/src/API/Instance.php
===================================================================
--- sandbox/workflow/branches/609/inc/engine/src/API/Instance.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/engine/src/API/Instance.php	(revision 2311)
@@ -1,5 +1,4 @@
 <?php
 require_once (GALAXIA_LIBRARY.SEP.'src'.SEP.'common'.SEP.'Base.php');
-require_once(GALAXIA_LIBRARY . SEP . 'src' . SEP . 'common' . SEP . 'WfSecurity.php');
 require_once(GALAXIA_LIBRARY . SEP . 'src' . SEP . 'ProcessManager' . SEP . 'ActivityManager.php');
 
@@ -141,8 +140,8 @@
 
   var $activityID = null;
-  function Instance($db) 
+  function Instance() 
   {
     $this->child_name = 'Instance';
-    parent::Base($db);
+    parent::Base();
   }
 
@@ -1171,5 +1170,5 @@
     
     //lock rows and ensure access is granted
-    if (!(isset($this->security))) $this->security =& new WfSecurity($this->db); 
+    if (!(isset($this->security))) $this->security = &Factory::getInstance('WfSecurity', $this->db);
     if (!($this->security->checkUserAction($activityId,$this->instanceId,'complete')))
     {
@@ -1551,5 +1550,5 @@
     {
       //we check rights for this user on the next activity
-      if (!(isset($this->security))) $this->security =& new WfSecurity($this->db); 
+      if (!(isset($this->security))) $this->security = &Factory::getInstance('WfSecurity');
       if ($this->security->checkUserAccess($the_next_user,$activityId))
       {
@@ -1560,5 +1559,5 @@
     {
       // then check to see if there is a default user
-      $activity_manager =& new ActivityManager($this->db);
+      $activity_manager = &Factory::newInstance('ActivityManager');
       //get_default_user will give us '*' if there is no default_user or if the default user has no role
       //mapped anymore
Index: sandbox/workflow/branches/609/inc/engine/src/API/BaseActivity.php
===================================================================
--- sandbox/workflow/branches/609/inc/engine/src/API/BaseActivity.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/engine/src/API/BaseActivity.php	(revision 2311)
@@ -97,9 +97,9 @@
    * @access public
    */
-  function BaseActivity(&$db)
+  function BaseActivity()
   {
     $this->type='base';
     $this->child_name = 'BaseActivity';
-    parent::Base($db);
+    parent::Base();
   }
 
@@ -122,41 +122,42 @@
     if(!$result || !$result->numRows() ) return false;
     $res = $result->fetchRow();
+
     switch($res['wf_type']) {
       case 'start':
-        require_once(GALAXIA_LIBRARY.SEP.'src'.SEP.'API'.SEP.'activities'.SEP.'Start.php');
-        $act = new Start($this->db);  
-        break;
+        $act = &Factory::newInstance('Start');
+        break;
+
       case 'end':
-        require_once(GALAXIA_LIBRARY.SEP.'src'.SEP.'API'.SEP.'activities'.SEP.'End.php');
-        $act = new End($this->db);
-        break;
+        $act = &Factory::newInstance('End');
+        break;
+
       case 'join':
-        require_once(GALAXIA_LIBRARY.SEP.'src'.SEP.'API'.SEP.'activities'.SEP.'Join.php');
-        $act = new Join($this->db);
-        break;
+        $act = &Factory::newInstance('Join');
+        break;
+
       case 'split':
-        require_once(GALAXIA_LIBRARY.SEP.'src'.SEP.'API'.SEP.'activities'.SEP.'Split.php');
-        $act = new Split($this->db);
-        break;
+        $act = &Factory::newInstance('Split');
+        break;
+
       case 'standalone':
-        require_once(GALAXIA_LIBRARY.SEP.'src'.SEP.'API'.SEP.'activities'.SEP.'Standalone.php');
-        $act = new Standalone($this->db);
-        break;
+        $act = &Factory::newInstance('Standalone');
+        break;
+
       case 'view':
-        require_once(GALAXIA_LIBRARY.SEP.'src'.SEP.'API'.SEP.'activities'.SEP.'View.php');
-        $act = new View($this->db);
-        break;
+        $act = &Factory::newInstance('View');
+        break;
+
       case 'switch':
-        require_once(GALAXIA_LIBRARY.SEP.'src'.SEP.'API'.SEP.'activities'.SEP.'SwitchActivity.php');
-        $act = new SwitchActivity($this->db);
-        break;
+        $act = &Factory::newInstance('SwitchActivity');
+        break;
+
       case 'activity':
-        require_once(GALAXIA_LIBRARY.SEP.'src'.SEP.'API'.SEP.'activities'.SEP.'Activity.php');
-        $act = new Activity($this->db);
-        break;
+        $act = &Factory::newInstance('Activity');
+        break;
+
       default:
         trigger_error('Unknown activity type:'.$res['wf_type'],E_USER_WARNING);
     }
-    
+
     $act->setName($res['wf_name']);
     $act->setProcessId($res['wf_p_id']);
Index: sandbox/workflow/branches/609/inc/engine/src/ProcessManager/ProcessManager.php
===================================================================
--- sandbox/workflow/branches/609/inc/engine/src/ProcessManager/ProcessManager.php	(revision 2165)
+++ sandbox/workflow/branches/609/inc/engine/src/ProcessManager/ProcessManager.php	(revision 2311)
@@ -66,7 +66,7 @@
 	 * @access public
 	 */
-	function ProcessManager(&$db)
-	{
-		parent::BaseManager($db);
+	function ProcessManager()
+	{
+		parent::BaseManager();
 		$this->child_name = 'ProcessManager';
 		require_once(GALAXIA_LIBRARY.SEP.'src'.SEP.'ProcessManager'.SEP.'ActivityManager.php');
@@ -131,5 +131,5 @@
 	function serialize_process($pId)
 	{
-		if (!(isset($this->activity_manager)))  $this->activity_manager = new ActivityManager($this->db);
+		if (!(isset($this->activity_manager)))  $this->activity_manager = &Factory::newInstance('ActivityManager');
 		// <process>
 		$out = '<process>'."\n";
@@ -459,8 +459,8 @@
 	{
 		//Now the show begins
-		if (!(isset($this->activity_manager)))  $this->activity_manager = new ActivityManager($this->db);
-		if (!(isset($this->role_manager))) $this->role_manager = new RoleManager($this->db);
+		if (!(isset($this->activity_manager)))  $this->activity_manager = &Factory::newInstance('ActivityManager');
+		if (!(isset($this->role_manager))) $this->role_manager = &Factory::newInstance('RoleManager');
 		if (!isset($this->jobManager))
-			$this->jobManager = new JobManager($this->db);
+			$this->jobManager = &Factory::newInstance('JobManager');
 
 		// First create the process. Always inactive and inactive first.
@@ -620,5 +620,5 @@
 	function new_process_version($pId, $minor=true)
 	{
-		if (!(isset($this->activity_manager)))  $this->activity_manager = new ActivityManager($this->db);
+		if (!(isset($this->activity_manager)))  $this->activity_manager = &Factory::newInstance('ActivityManager');
 		$oldpid = $pId;
 		//retrieve process info with config rows
@@ -671,5 +671,5 @@
 		}
 		// create roles
-		if (!(isset($this->role_manager))) $this->role_manager = new RoleManager($this->db);
+		if (!(isset($this->role_manager))) $this->role_manager = &Factory::newInstance('RoleManager');
 		$query = 'select * from '.GALAXIA_TABLE_PREFIX.'roles where wf_p_id=?';
 		$result = $this->query($query, array($oldpid));
@@ -853,7 +853,7 @@
 	function remove_process($pId)
 	{
-		if (!(isset($this->activity_manager)))  $this->activity_manager = new ActivityManager($this->db);
+		if (!(isset($this->activity_manager)))  $this->activity_manager = &Factory::newInstance('ActivityManager');
 		if (!isset($this->jobManager))
-			$this->jobManager = new JobManager($this->db);
+			$this->jobManager = &Factory::newInstance('JobManager');
 		$this->deactivate_process($pId);
 		$name = $this->_get_normalized_name($pId);
@@ -919,5 +919,5 @@
 	function replace_process($pId, &$vars, $create = true)
 	{
-		if (!(isset($this->activity_manager)))  $this->activity_manager = new ActivityManager($this->db);
+		if (!(isset($this->activity_manager)))  $this->activity_manager = &Factory::newInstance('ActivityManager');
 		$TABLE_NAME = GALAXIA_TABLE_PREFIX.'processes';
 		$now = date("U");
@@ -1296,5 +1296,5 @@
 		{
 			//Warning: this means you have to include the Process.php from the API
-			$this->Process = new Process($this->db);
+			$this->Process = &Factory::newInstance('Process');
 			$this->Process->getProcess($pId);
 			$result_array = $this->Process->getConfigValues($config_array);
@@ -1316,5 +1316,5 @@
 	{
 		//Warning: this means you have to include the Process.php from the API
-		$this->Process = new Process($this->db);
+		$this->Process = &Factory::newInstance('Process');
 		$this->Process->getProcess($pId);
 		$this->Process->setConfigValues($config_array);
Index: sandbox/workflow/branches/609/inc/engine/src/ProcessManager/RoleManager.php
===================================================================
--- sandbox/workflow/branches/609/inc/engine/src/ProcessManager/RoleManager.php	(revision 2233)
+++ sandbox/workflow/branches/609/inc/engine/src/ProcessManager/RoleManager.php	(revision 2311)
@@ -19,7 +19,7 @@
    * @access public
    */
-  function RoleManager(&$db) 
-  {
-    parent::Base($db);
+  function RoleManager() 
+  {
+    parent::Base();
     $this->child_name = 'RoleManager';
   }
Index: sandbox/workflow/branches/609/inc/engine/src/ProcessManager/InstanceManager.php
===================================================================
--- sandbox/workflow/branches/609/inc/engine/src/ProcessManager/InstanceManager.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/engine/src/ProcessManager/InstanceManager.php	(revision 2311)
@@ -16,7 +16,7 @@
    * @access public
    */
-  function InstanceManager(&$db) 
-  {
-    parent::BaseManager($db);
+  function InstanceManager() 
+  {
+    parent::BaseManager();
     $this->child_name = 'InstanceManager';
   }
Index: sandbox/workflow/branches/609/inc/engine/src/ProcessManager/BaseManager.php
===================================================================
--- sandbox/workflow/branches/609/inc/engine/src/ProcessManager/BaseManager.php	(revision 2165)
+++ sandbox/workflow/branches/609/inc/engine/src/ProcessManager/BaseManager.php	(revision 2311)
@@ -18,8 +18,8 @@
    * @access public
    */
-  function BaseManager(&$db)
+  function BaseManager()
   {
     $this->child_name = 'BaseManager';
-    parent::Base($db);
+    parent::Base();
   }
 
Index: sandbox/workflow/branches/609/inc/engine/src/ProcessManager/JobManager.php
===================================================================
--- sandbox/workflow/branches/609/inc/engine/src/ProcessManager/JobManager.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/engine/src/ProcessManager/JobManager.php	(revision 2311)
@@ -76,12 +76,12 @@
 	 * @access public
 	 */
-	public function JobManager(&$db)
-	{
-		parent::BaseManager($db);
+	public function JobManager()
+	{
+		parent::BaseManager();
 		$this->child_name = 'JobManager';
 
 		$this->jobTable = GALAXIA_TABLE_PREFIX . 'jobs';
 		$this->logTable = GALAXIA_TABLE_PREFIX . 'job_logs';
-		$this->processManager = new ProcessManager($this->db);
+		$this->processManager = &Factory::newInstance('ProcessManager');
 	}
 
Index: sandbox/workflow/branches/609/inc/engine/src/ProcessManager/ActivityManager.php
===================================================================
--- sandbox/workflow/branches/609/inc/engine/src/ProcessManager/ActivityManager.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/engine/src/ProcessManager/ActivityManager.php	(revision 2311)
@@ -26,7 +26,7 @@
    * @access public
    */
-  function ActivityManager(&$db)
-  {
-    parent::BaseManager($db);
+  function ActivityManager()
+  {
+    parent::BaseManager();
     $this->child_name = 'ActivityManager';
     require_once(GALAXIA_LIBRARY.SEP.'src'.SEP.'ProcessManager' .SEP . 'ProcessManager.php');
@@ -370,9 +370,9 @@
   function build_process_graph($pId)
   {
-    if (!(isset($this->process_manager))) $this->process_manager = new ProcessManager($this->db);
+    if (!(isset($this->process_manager))) $this->process_manager = &Factory::newInstance('ProcessManager');
     $attributes = Array(
     
     );
-    $graph = new Process_GraphViz(true,$attributes);
+    $graph = &Factory::newInstance('Process_GraphViz', true, $attributes);
     $name = $this->process_manager->_get_normalized_name($pId);
     $graph->set_pid($name);
@@ -747,5 +747,5 @@
   {
     require_once(GALAXIA_LIBRARY.SEP.'src'.SEP.'API'.SEP . 'BaseActivity.php');
-    $act = new BaseActivity($this->db);
+    $act = &Factory::newInstance('BaseActivity');
     //Warning, we now use the BaseActivity object for it, interactivity and autorouting is now true/fales, not y/n
     return ($act->getActivity($activityId,false,true, true));
@@ -825,5 +825,5 @@
   function remove_activity($pId, $activityId, $transaction = true)
   {
-    if (!(isset($this->process_manager))) $this->process_manager = new ProcessManager($this->db);
+    if (!(isset($this->process_manager))) $this->process_manager = &Factory::newInstance('ProcessManager');
     $proc_info = $this->process_manager->get_process($pId);
     $actname = $this->_get_normalized_name($activityId);
@@ -888,5 +888,5 @@
   function replace_activity($pId, $activityId, $vars, $create_files=true)
   {
-    if (!(isset($this->process_manager))) $this->process_manager = new ProcessManager($this->db);
+    if (!(isset($this->process_manager))) $this->process_manager = &Factory::newInstance('ProcessManager');
     $TABLE_NAME = GALAXIA_TABLE_PREFIX.'activities';
     $now = date("U");
@@ -1195,5 +1195,5 @@
     elseif ( (!($result=='*')) && $performAccessCheck)
     {
-      $wf_security = new WfSecurity($this->db);
+      $wf_security = &Factory::getInstance('WfSecurity', $this->db);
       // perform the check
       if (!($wf_security->checkUserAccess($result,$activityId)))
Index: sandbox/workflow/branches/609/inc/class.JobScheduler.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.JobScheduler.inc.php	(revision 2292)
+++ sandbox/workflow/branches/609/inc/class.JobScheduler.inc.php	(revision 2311)
@@ -11,7 +11,4 @@
 
 require_once 'jobs/class.JobEnum.inc.php';
-require_once 'jobs/class.AbsoluteDate.inc.php';
-require_once 'jobs/class.WeekDate.inc.php';
-require_once 'jobs/class.RelativeDate.inc.php';
 
 /**
@@ -76,14 +73,14 @@
 		{
 			case DateType::ABSOLUTE_DATE:
-				$object = new AbsoluteDate($startDate, $interval);
+				$object = &Factory::getInstance('AbsoluteDate', $startDate, $interval);
 				break;
 
 			case DateType::WEEK_DATE:
-				$object = new WeekDate($startDate, $interval);
+				$object = &Factory::getInstance('WeekDate', $startDate, $interval);
 				$object->setWeekDays($record['week_days']);
 				break;
 
 			case DateType::RELATIVE_DATE:
-				$object = new RelativeDate($startDate, $interval);
+				$object = &Factory::getInstance('RelativeDate', $startDate, $interval);
 				$object->setOffset($record['month_offset']);
 				break;
Index: sandbox/workflow/branches/609/inc/class.WorkflowMacro.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.WorkflowMacro.inc.php	(revision 2233)
+++ sandbox/workflow/branches/609/inc/class.WorkflowMacro.inc.php	(revision 2311)
@@ -48,7 +48,6 @@
 		require_once PHPGW_API_INC . '/functions.inc.php';
 		require_once 'engine/class.ajax_config.inc.php';
-		require_once 'engine/class.ajax_ldap.inc.php';
 		require_once 'engine/config.ajax.inc.php';
-		$GLOBALS['ajax']->ldap = new ajax_ldap();
+		$GLOBALS['ajax']->ldap = &Factory::getInstance('ajax_ldap');
 
 		/* definição de algumas constantes */
@@ -64,8 +63,7 @@
 	public function prepareProcessEnvironment($processID)
 	{
-		require_once GALAXIA_LIBRARY . '/src/common/WfRuntime.php';
 		require_once PHPGW_SERVER_ROOT . '/workflow/inc/local/functions/local.functions.php';
 
-		$runtime = new WfRuntime(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
+		$runtime = &Factory::getInstance('WfRuntime', Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
 		$runtime->loadProcess($processID);
 
Index: sandbox/workflow/branches/609/inc/class.external_bridge.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.external_bridge.inc.php	(revision 2233)
+++ sandbox/workflow/branches/609/inc/class.external_bridge.inc.php	(revision 2311)
@@ -13,5 +13,4 @@
 require_once 'common.inc.php';
 require_once 'engine/config.egw.inc.php';
-require_once 'class.so_adminaccess.inc.php';
 
 /**
@@ -53,5 +52,5 @@
 	{
 		$this->db = Factory::getInstance('WorkflowObjects')->getDBGalaxia();
-		$this->acl = new so_adminaccess(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
+		$this->acl = &Factory::getInstance('so_adminaccess', Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
 	}
 	/**
Index: sandbox/workflow/branches/609/inc/class.so_userinterface.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.so_userinterface.inc.php	(revision 2233)
+++ sandbox/workflow/branches/609/inc/class.so_userinterface.inc.php	(revision 2311)
@@ -1,4 +1,3 @@
 <?php
-require_once($_SESSION['phpgw_info']['workflow']['phpgw_api_inc'] . '/class.config.inc.php');
 
 /**
@@ -61,5 +60,5 @@
 		$oldDB = $GLOBALS['phpgw']->db;
 		$GLOBALS['phpgw']->db = $GLOBALS['ajax']->db;
-		$config = new config('workflow');
+		$config = &Factory::getInstance('config', 'workflow');
 		$configValues = $config->read_repository();
 		$submasksString = $configValues['intranet_subnetworks'];
@@ -596,5 +595,5 @@
 		require_once dirname(__FILE__) . '/class.so_orgchart.inc.php';
 
-		$SOOrgchart = new so_orgchart();
+		$SOOrgchart = &Factory::getInstance('so_orgchart');
 		$SOOrgchart->setExternalCalls(true);
 		$output = $SOOrgchart->getEmployeeInfo($employeeID, $organizationID);
@@ -616,5 +615,5 @@
 		require_once dirname(__FILE__) . '/class.so_orgchart.inc.php';
 
-		$SOOrgchart = new so_orgchart();
+		$SOOrgchart = &Factory::getInstance('so_orgchart');
 		$SOOrgchart->setExternalCalls(true);
 		$output = $SOOrgchart->getAreaInfo($areaID, $organizationID);
Index: sandbox/workflow/branches/609/inc/class.JobRunner.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.JobRunner.inc.php	(revision 2233)
+++ sandbox/workflow/branches/609/inc/class.JobRunner.inc.php	(revision 2311)
@@ -96,5 +96,5 @@
 Factory::getInstance('WorkflowMacro')->prepareEnvironment();
 
-$jobRunner = new JobRunner($argv[1]);
+$jobRunner = &Factory::newInstance('JobRunner', $argv[1]);
 $jobRunner->run();
 ?>
Index: sandbox/workflow/branches/609/inc/class.so_adminjobs.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.so_adminjobs.inc.php	(revision 2233)
+++ sandbox/workflow/branches/609/inc/class.so_adminjobs.inc.php	(revision 2311)
@@ -11,5 +11,4 @@
 
 require_once GALAXIA_LIBRARY . SEP . 'src' . SEP . 'ProcessManager' . SEP . 'ProcessManager.php';
-require_once GALAXIA_LIBRARY . SEP . 'src' . SEP . 'ProcessManager' . SEP . 'JobManager.php';
 require_once GALAXIA_LIBRARY . SEP . 'src' . SEP . 'ProcessManager' . SEP . 'ActivityManager.php';
 
@@ -97,5 +96,5 @@
 		$this->acl = &$GLOBALS['ajax']->acl;
 		$this->db = &Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID;
-		$this->jobManager = new JobManager(&$this->db);
+		$this->jobManager = &Factory::newInstance('JobManager');
 	}
 
Index: sandbox/workflow/branches/609/inc/class.ui_adminactivities.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.ui_adminactivities.inc.php	(revision 2253)
+++ sandbox/workflow/branches/609/inc/class.ui_adminactivities.inc.php	(revision 2311)
@@ -2,5 +2,4 @@
 
 require_once dirname(__FILE__) . SEP . 'class.WorkflowUtils.inc.php';
-require_once dirname(__FILE__) . SEP . 'class.fsutils.inc.php'; /* toolkit for filesystem handling */
 require_once 'engine' . SEP . 'config.egw.inc.php';
 /**
@@ -109,5 +108,5 @@
 		$this->activity_manager	= Factory::getInstance('workflow_activitymanager');
 		$this->role_manager	= Factory::getInstance('workflow_rolemanager');
-		$this->fs = new FsUtils(); /* gets instance */
+		$this->fs = &Factory::newInstance('FsUtils'); /* gets instance */
 
 	}
Index: sandbox/workflow/branches/609/inc/class.bo_userinterface.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.bo_userinterface.inc.php	(revision 2292)
+++ sandbox/workflow/branches/609/inc/class.bo_userinterface.inc.php	(revision 2311)
@@ -10,9 +10,6 @@
 \**************************************************************************/
 
-require_once('class.so_userinterface.inc.php');
 require_once('class.bo_ajaxinterface.inc.php');
 
-require_once(GALAXIA_LIBRARY . SEP . 'src' . SEP . 'GUI' . SEP . 'GUI.php');
-require_once(GALAXIA_LIBRARY . SEP . 'src' . SEP . 'ProcessManager' . SEP . 'ActivityManager.php');
 /**
  * @package Workflow
@@ -43,6 +40,6 @@
 	{
 		parent::bo_ajaxinterface();
-		$this->so = new so_userinterface();
-		$GLOBALS['ajax']->gui = new GUI(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
+		$this->so = &Factory::getInstance('so_userinterface');
+		$GLOBALS['ajax']->gui = &Factory::newInstance('GUI');
 	}
 
@@ -120,5 +117,5 @@
 		$result = array();
 
-		$process = new Process(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
+		$process = &Factory::newInstance('Process');
 		$process->getProcess($pid);
 		$result['wf_procname'] = $process->name;
@@ -126,5 +123,5 @@
 		$result['wf_description'] = $process->description;
 
-		$activ_manager = new ActivityManager(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
+		$activ_manager = &Factory::newInstance('ActivityManager');
 		$result['wf_activities'] = $activ_manager->get_process_activities($pid);
 
@@ -494,8 +491,8 @@
 		}
 
-		$instance = new Instance(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
+		$instance = &Factory::newInstance('Instance');
 		$instance->getInstance($instanceID);
 
-		$process = new Process(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
+		$process = &Factory::newInstance('Process');
 		$process->getProcess($instance->pId);
 
Index: sandbox/workflow/branches/609/inc/class.bo_adminjobs.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.bo_adminjobs.inc.php	(revision 2233)
+++ sandbox/workflow/branches/609/inc/class.bo_adminjobs.inc.php	(revision 2311)
@@ -11,5 +11,4 @@
 
 require_once 'class.bo_ajaxinterface.inc.php';
-require_once 'class.so_adminjobs.inc.php';
 require_once 'nano/JSON.php';
 
@@ -36,5 +35,5 @@
 	{
 		parent::bo_ajaxinterface();
-		$this->so = new so_adminjobs();
+		$this->so = &Factory::getInstance('so_adminjobs');
 	}
 
Index: sandbox/workflow/branches/609/inc/class.bo_adminsource.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.bo_adminsource.inc.php	(revision 2233)
+++ sandbox/workflow/branches/609/inc/class.bo_adminsource.inc.php	(revision 2311)
@@ -12,7 +12,4 @@
 require_once('class.bo_ajaxinterface.inc.php');
 
-require_once(GALAXIA_LIBRARY . SEP . 'src' . SEP . 'ProcessManager' . SEP . 'ProcessManager.php');
-require_once(GALAXIA_LIBRARY . SEP . 'src' . SEP . 'ProcessManager' . SEP . 'RoleManager.php');
-require_once(GALAXIA_LIBRARY . SEP . 'src' . SEP . 'ProcessManager' . SEP . 'ActivityManager.php');
 require_once(GALAXIA_LIBRARY . SEP . 'src' . SEP . 'API' . SEP . 'Process.php');
 
@@ -103,5 +100,5 @@
 	{
 
-		$process_manager = new ProcessManager(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
+		$process_manager = &Factory::newInstance('ProcessManager');
 		$proc_info       = $process_manager->get_process($p['proc_id']);
 
@@ -228,7 +225,7 @@
 	function get_php_files($p)
 	{
-		$process_manager    = new ProcessManager(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
+		$process_manager    = &Factory::newInstance('ProcessManager');
 		$proc_info          = $process_manager->get_process($p['proc_id']);
-		$activity_manager   = new ActivityManager(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
+		$activity_manager   = &Factory::newInstance('ActivityManager');
 		$process_activities = $activity_manager->list_activities($p['proc_id'], 0, -1, 'wf_name__asc', '','',false);
 		$path = GALAXIA_PROCESSES . SEP . $proc_info['wf_normalized_name'] . SEP . 'code' . SEP .'activities' . SEP;
@@ -293,5 +290,5 @@
 		if ((strpos($p['file_name'],'/') !== false) || (strpos($p['file_name'],'/') !== false))
 			return 'Não foi possível executar a operação solicitada';
-		$process_manager = new ProcessManager(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
+		$process_manager = &Factory::newInstance('ProcessManager');
 		$proc_info = $process_manager->get_process($p['proc_id']);
 		$file_name = $p['file_name'];
@@ -351,5 +348,5 @@
 	function create_file($p)
 	{
-		$process_manager = new ProcessManager(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
+		$process_manager = &Factory::newInstance('ProcessManager');
 		$proc_info = $process_manager->get_process($p['proc_id']);
 		$file_name = $p['file_name'];
@@ -432,5 +429,5 @@
 	function get_include_files($p)
 	{
-		$process_manager    = new ProcessManager(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
+		$process_manager    = &Factory::newInstance('ProcessManager');
 		$proc_info          = $process_manager->get_process($p['proc_id']);
 		$path = GALAXIA_PROCESSES . SEP . $proc_info['wf_normalized_name'] . SEP . 'code';
@@ -494,5 +491,5 @@
 	function get_template_files($p)
 	{
-		$process_manager    = new ProcessManager(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
+		$process_manager    = &Factory::newInstance('ProcessManager');
 		$proc_info          = $process_manager->get_process($p['proc_id']);
 		$path = GALAXIA_PROCESSES . SEP . $proc_info['wf_normalized_name'] . SEP . 'code' . SEP .'templates';
@@ -555,5 +552,5 @@
 	function upload_resource($p)
 	{
-		$process_manager = new ProcessManager(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
+		$process_manager = &Factory::newInstance('ProcessManager');
 		$proc_info = $process_manager->get_process($p['proc_id']);
 		$file_name = basename($_FILES['resource_file']['name']);
@@ -587,5 +584,5 @@
 		if (strpos($_REQUEST['file_name'],'/') !== false)
 			return 'Não foi possível executar a operação solicitada';
-		$process_manager    = new ProcessManager(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
+		$process_manager    = &Factory::newInstance('ProcessManager');
 		$proc_info          = $process_manager->get_process($_REQUEST['proc_id']);
 
@@ -630,5 +627,5 @@
 	function get_resource_files($p)
 	{
-		$process_manager    = new ProcessManager(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
+		$process_manager    = &Factory::newInstance('ProcessManager');
 		$proc_info          = $process_manager->get_process($p['proc_id']);
 
Index: sandbox/workflow/branches/609/inc/class.bo_orgchart.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.bo_orgchart.inc.php	(revision 2042)
+++ sandbox/workflow/branches/609/inc/class.bo_orgchart.inc.php	(revision 2311)
@@ -10,5 +10,4 @@
 \**************************************************************************/
 
-require_once('class.so_orgchart.inc.php');
 require_once('class.bo_ajaxinterface.inc.php');
 /**
@@ -47,5 +46,5 @@
 	{
 		parent::bo_ajaxinterface();
-		$this->so = new so_orgchart();
+		$this->so = &Factory:::getInstance('so_orgchart');
 	}
 
Index: sandbox/workflow/branches/609/inc/nano/NanoGuardian.class.php
===================================================================
--- sandbox/workflow/branches/609/inc/nano/NanoGuardian.class.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/nano/NanoGuardian.class.php	(revision 2311)
@@ -32,5 +32,5 @@
     public function __construct()
     {
-        $this->_mObjNanoSanitizer = new NanoSanitizer(new DummyLogger);
+        $this->_mObjNanoSanitizer = &Factory::newInstance('NanoSanitizer', new DummyLogger);
     }
 
Index: sandbox/workflow/branches/609/inc/nano/NanoJsonConverter.class.php
===================================================================
--- sandbox/workflow/branches/609/inc/nano/NanoJsonConverter.class.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/nano/NanoJsonConverter.class.php	(revision 2311)
@@ -118,6 +118,6 @@
         // initialize JSON object
         $this->_mObjJson = ( strtolower($return_type) != 'object' )
-                                ? new Services_JSON( SERVICES_JSON_LOOSE_TYPE )
-                                : new Services_JSON();
+                                ? Factory::getInstance('Services_JSON', SERVICES_JSON_LOOSE_TYPE )
+                                : Factory::getInstance('Services_JSON');
     }
 
Index: sandbox/workflow/branches/609/inc/nano/NanoController.class.php
===================================================================
--- sandbox/workflow/branches/609/inc/nano/NanoController.class.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/nano/NanoController.class.php	(revision 2311)
@@ -59,6 +59,6 @@
     function __construct()
     {
-        $this->_mObjJsonConverter = new NanoJsonConverter();
-        $this->_mObjJson          = new Services_JSON();
+        $this->_mObjJsonConverter = &Factory::newInstance('NanoJsonConverter');
+        $this->_mObjJson          = &Factory::newInstance('Services_JSON');
     }
 
@@ -130,5 +130,5 @@
     public function iterateOverVirtualRequests()
     {
-        $this->_mObjNanoRequest = new NanoRequest( $this->_mStrClassPath, $this->_mStrClassSuffix, $this->_mStrClassPreffix );
+        $this->_mObjNanoRequest = &Factory::newInstance('NanoRequest', $this->_mStrClassPath, $this->_mStrClassSuffix, $this->_mStrClassPreffix );
         $return_data            = array();
 
Index: sandbox/workflow/branches/609/inc/class.bo_monitors.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.bo_monitors.inc.php	(revision 2264)
+++ sandbox/workflow/branches/609/inc/class.bo_monitors.inc.php	(revision 2311)
@@ -12,12 +12,5 @@
 require_once('class.bo_ajaxinterface.inc.php');
 
-require_once(GALAXIA_LIBRARY . SEP . 'src' . SEP . 'GUI' . SEP . 'GUI.php');
-require_once(GALAXIA_LIBRARY . SEP . 'src' . SEP . 'ProcessManager' . SEP . 'ProcessManager.php');
-require_once(GALAXIA_LIBRARY . SEP . 'src' . SEP . 'ProcessManager' . SEP . 'ActivityManager.php');
-require_once(GALAXIA_LIBRARY . SEP . 'src' . SEP . 'ProcessManager' . SEP . 'InstanceManager.php');
-require_once(GALAXIA_LIBRARY . SEP . 'src' . SEP . 'ProcessManager' . SEP . 'RoleManager.php');
-require_once(GALAXIA_LIBRARY . SEP . 'src' . SEP . 'ProcessMonitor' . SEP . 'ProcessMonitor.php');
-require_once(GALAXIA_LIBRARY . SEP . 'src' . SEP . 'API' . SEP . 'Instance.php');
-require_once('class.workflow_acl.inc.php');
+require_once('class.workflow_acl.inc.php'); /* can we remove this? */
 require_once('class.bo_adminaccess.inc.php');
 require_once('class.powergraphic.inc.php');
@@ -134,12 +127,12 @@
 	{
 		parent::bo_ajaxinterface();
-		$GLOBALS['ajax']->gui   = new GUI(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
+		$GLOBALS['ajax']->gui   = &Factory::newInstance('GUI');
 		$this->userID 			= $_SESSION['phpgw_info']['workflow']['account_id'];
 		$this->isWorkflowAdmin  = $GLOBALS['ajax']->acl->checkWorkflowAdmin($this->userID);
-		$this->processManager   = new ProcessManager(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
-		$this->activityManager  = new ActivityManager(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
-		$this->instanceManager  = new InstanceManager(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
-		$this->roleManager 		= new RoleManager(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
-		$this->processMonitor   = new ProcessMonitor(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
+		$this->processManager   = &Factory::newInstance('ProcessManager');
+		$this->activityManager  = &Factory::newInstance('ActivityManager');
+		$this->instanceManager  = &Factory::newInstance('InstanceManager');
+		$this->roleManager 		= &Factory::newInstance('RoleManager');
+		$this->processMonitor   = &Factory::newInstance('ProcessMonitor');
 	}
 
@@ -169,8 +162,7 @@
 	private function convertFiltersToSQL($filters)
 	{
-		require_once 'nano/JSON.php';
 
 		/* desserializa os dados */
-		$JSON = new Services_JSON();
+		$JSON = &Factory::newInstance('Services_JSON');
 		/* desserializa a array principal, depois desserializa cada elemento desta array e, por fim, converte os elementos (que estão em forma de objeto) para array associativa */
 		$filters = array_map('get_object_vars', array_map(array($JSON, 'decode'), $JSON->decode($filters)));
@@ -648,5 +640,5 @@
 		if ($params['ns'] == 'aborted')
 		{
-			$realInstance = new Instance(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
+			$realInstance = &Factory::newInstance('Instance');
 			$realInstance->getInstance($params['iid']);
 			if (!empty($realInstance->instanceId))
@@ -684,5 +676,5 @@
 
 		/* use next user or * for the new instance */
-		$realInstance = new Instance(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
+		$realInstance = &Factory::newInstance('Instance');
 		$realInstance->getInstance($params['iid'], false, false);
 		$user = $realInstance->getNextUser($params['aid']);
@@ -751,5 +743,5 @@
 
 		$maximumDisplaySize = 100;
-		$instance = new Instance(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
+		$instance = &Factory::newInstance('Instance');
 		$instance->getInstance($params['iid']);
 
@@ -783,5 +775,5 @@
 			return "Você não tem permissão para executar este procedimento!";
 
-		$instance = new Instance(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
+		$instance = &Factory::newInstance('Instance');
 		$instance->getInstance($params['iid']);
 		$output = $params;
@@ -804,5 +796,5 @@
 		$maximumDisplaySize = 100;
 
-		$instance = new Instance(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
+		$instance = &Factory::newInstance('Instance');
 		$instance->getInstance($params['iid']);
 		$instance->set($params['name'], $params['value']);
@@ -835,5 +827,5 @@
 			return "Você não tem permissão para executar este procedimento!";
 
-		$instance = new Instance(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
+		$instance = &Factory::newInstance('Instance');
 		$instance->getInstance($params['iid']);
 		$instance->clear($params['name']);
@@ -858,5 +850,5 @@
 		$output = array();
 		$urlPrefix = 'workflow/inc/class.powergraphic.inc.php?';
-		$powergraphic = new powergraphic;
+		$powergraphic = &Factory::getInstance('powergraphic');
 		$powergraphic->graphic_1 = $params['pid'];
 		$powergraphic->skin = 1;
Index: sandbox/workflow/branches/609/inc/class.ui_phpeditor.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.ui_phpeditor.inc.php	(revision 2253)
+++ sandbox/workflow/branches/609/inc/class.ui_phpeditor.inc.php	(revision 2311)
@@ -11,5 +11,4 @@
 
 require_once dirname(__FILE__) . SEP . 'engine' . SEP . 'config.ajax.inc.php';
-require_once GALAXIA_LIBRARY . SEP . 'src' . SEP . 'ProcessManager' . SEP . 'ProcessManager.php';
 require_once dirname(__FILE__) . SEP . 'class.ui_ajaxinterface.inc.php';
 /**
@@ -63,5 +62,5 @@
 	{
 		$smarty = Factory::getInstance('workflow_smarty', false);
-		$processManager = new ProcessManager(Factory::getInstance('WorkflowObjects')->getDBGalaxia()->Link_ID);
+		$processManager = &Factory::newInstance('ProcessManager');
 		$proccessInfo = $processManager->get_process($_GET['proc_id']);
 
Index: sandbox/workflow/branches/609/inc/class.ui_orgchart.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.ui_orgchart.inc.php	(revision 2264)
+++ sandbox/workflow/branches/609/inc/class.ui_orgchart.inc.php	(revision 2311)
@@ -103,6 +103,4 @@
 		else
 			die();
-
-		require_once(dirname(__FILE__) . SEP . 'engine' . SEP . 'src' . SEP . 'ProcessManager' . SEP . 'GraphViz.php');
 
 		$config_values = Factory::getInstance('config', 'workflow');
@@ -122,5 +120,5 @@
 		$attributes['ranksep'] = '1.5 equally';
 		$attributes['rankdir'] = 'LR';
-		$graph = new Process_GraphViz(true, $attributes);
+		$graph = &Factory::getInstance('Process_GraphViz', true, $attributes);
 
 
Index: sandbox/workflow/branches/609/inc/class.bo_editor.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.bo_editor.inc.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/class.bo_editor.inc.php	(revision 2311)
@@ -11,5 +11,4 @@
 
 require_once('class.bo_ajaxinterface.inc.php');
-require_once(GALAXIA_LIBRARY . SEP . 'src' . SEP . 'ProcessManager' . SEP . 'ActivityManager.php');
 require_once(GALAXIA_LIBRARY . SEP . 'src' . SEP . 'ProcessManager' . SEP . 'ProcessManager.php');
 /**
@@ -234,5 +233,5 @@
 		if ($p['tipo_codigo'] != 'include')
 		{
-			$activity_manager   = new ActivityManager($GLOBALS['workflow']['workflowObjects']->getDBGalaxia()->Link_ID);
+			$activity_manager   = &Factory::newInstance('ActivityManager');
 
 			if ($this->check_process($p['proc_id'], &$activity_manager, &$error_str) == 'n')
Index: sandbox/workflow/branches/609/inc/class.bo_external_applications.inc.php
===================================================================
--- sandbox/workflow/branches/609/inc/class.bo_external_applications.inc.php	(revision 795)
+++ sandbox/workflow/branches/609/inc/class.bo_external_applications.inc.php	(revision 2311)
@@ -11,5 +11,4 @@
 \**************************************************************************/
 
-require_once('class.so_external_applications.inc.php');
 require_once('class.bo_ajaxinterface.inc.php');
 /**
@@ -34,5 +33,5 @@
 	{
 		parent::bo_ajaxinterface();
-		$this->so = new so_external_applications();
+		$this->so = &Factory::getInstance('so_external_applications');
 	}
 
Index: sandbox/workflow/branches/609/index.php
===================================================================
--- sandbox/workflow/branches/609/index.php	(revision 2193)
+++ sandbox/workflow/branches/609/index.php	(revision 2311)
@@ -22,5 +22,5 @@
 			require_once dirname(__FILE__) . '/inc/nano/NanoJsonConverter.class.php';
 			require_once dirname(__FILE__) . '/inc/nano/NanoController.class.php';
-			$nanoController = new NanoController();
+			$nanoController = &Factory::newInstance('NanoController');
 			$nanoController->throwErrorOnAllVirtualRequests('__NANOAJAX_SESSION_EXPIRED__');
 			exit;
