Index: DCWoRMS/trunk/src/schedframe/scheduling/UsedResourcesList.java
===================================================================
--- DCWoRMS/trunk/src/schedframe/scheduling/UsedResourcesList.java	(revision 490)
+++ DCWoRMS/trunk/src/schedframe/scheduling/UsedResourcesList.java	(revision 490)
@@ -0,0 +1,12 @@
+package schedframe.scheduling;
+
+import java.util.LinkedList;
+
+public class UsedResourcesList extends LinkedList<ResourceHistoryItem>{
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 1L;
+	
+}
Index: DCWoRMS/trunk/src/schedframe/scheduling/manager/tasks/JobRegistry.java
===================================================================
--- DCWoRMS/trunk/src/schedframe/scheduling/manager/tasks/JobRegistry.java	(revision 481)
+++ DCWoRMS/trunk/src/schedframe/scheduling/manager/tasks/JobRegistry.java	(revision 490)
@@ -1,7 +1,8 @@
 package schedframe.scheduling.manager.tasks;
 
-import gssim.schedframe.scheduling.ExecTask;
 
 import java.util.List;
+
+import dcworms.schedframe.scheduling.ExecTask;
 
 import schedframe.ExecutablesList;
Index: DCWoRMS/trunk/src/schedframe/scheduling/manager/tasks/JobRegistryImpl.java
===================================================================
--- DCWoRMS/trunk/src/schedframe/scheduling/manager/tasks/JobRegistryImpl.java	(revision 481)
+++ DCWoRMS/trunk/src/schedframe/scheduling/manager/tasks/JobRegistryImpl.java	(revision 490)
@@ -2,5 +2,4 @@
 
 import gridsim.gssim.DCWormsTags;
-import gssim.schedframe.scheduling.ExecTask;
 
 import java.util.ArrayList;
@@ -12,4 +11,6 @@
 import org.qcg.broker.schemas.resreqs.ParentType;
 import org.qcg.broker.schemas.resreqs.types.TaskStatesName;
+
+import dcworms.schedframe.scheduling.ExecTask;
 
 import qcg.shared.constants.BrokerConstants;
@@ -82,5 +83,5 @@
 		synchronized (executables)  {
 			for (ExecTask task : executables) {
-				if (task.getJobId().compareTo(jobId) == 0 && task.getId().compareTo(taskId)==0) {
+				if (task.getJobId().compareTo(jobId) == 0 && task.getId().compareTo(taskId) == 0) {
 					return task;
 				}
Index: DCWoRMS/trunk/src/schedframe/scheduling/manager/resources/LocalResourceManager.java
===================================================================
--- DCWoRMS/trunk/src/schedframe/scheduling/manager/resources/LocalResourceManager.java	(revision 477)
+++ DCWoRMS/trunk/src/schedframe/scheduling/manager/resources/LocalResourceManager.java	(revision 490)
@@ -13,5 +13,4 @@
 import java.util.Properties;
 import java.util.Set;
-import java.util.Stack;
 
 import schedframe.exceptions.ResourceException;
@@ -175,15 +174,4 @@
 		return resourceUnit;
 	}
-	/*public List<AbstractResourceUnit> getAvailableResourceUnits(String resourceName) throws Exception {
-		ComputingResource resource = getResourceByName(resourceName);
-		List<AbstractResourceUnit> resourceUnits = new ArrayList<AbstractResourceUnit>();
-		while(resource != null){
-			for(List<AbstractResourceUnit> resUnits: resource.getResourceCharacteristic().getResourceUnits().values())
-				resUnits.addAll(resourceUnits);
-			resource = resource.getParent();
-		}
-		
-		return resourceUnits;
-	}*/
 
 	public List<? extends ComputingResource> filterResources(Properties properties) {
@@ -242,5 +230,5 @@
 				computingResources = (List<ComputingResource>) getResourcesOfType(StandardResourceType.Core);
 			} catch (ResourceException e) {
-				throw new RuntimeException("GSSIM internal error");
+				throw new RuntimeException("DCWorms internal error");
 			}
 			PEUnit peUnit = new ProcessingElements(computingResources);
@@ -253,5 +241,5 @@
 				computingResources = (List<ComputingResource>) getResourcesOfType(StandardResourceType.Processor);
 			} catch (ResourceException e) {
-				throw new RuntimeException("GSSIM internal error");
+				throw new RuntimeException("DCWorms internal error");
 			}
 			PEUnit peUnit = new ProcessingElements(computingResources);
@@ -318,20 +306,4 @@
 			return false;
 		}
-		/*ResourceUnit peUnit = resources.get(StandardResourceUnitName.PE);
-
-		if (peUnit != null) {
-			if (peUnit instanceof ProcessingElements) {
-				ProcessingElements choosenProcessors = (ProcessingElements) peUnit;
-
-				for (int i = 0; i < choosenProcessors.size(); i++) {
-					choosenProcessors.get(i).setStatus(ResourceStatus.BUSY);
-				}
-			}
-		}*/
-
-		/*Memory m = (Memory) resources.get(StandardResourceUnitName.MEMORY);
-		if (m != null) {
-			m.getProvisioner().setState(ResourceUnitState.BUSY);
-		}*/
 		
 		for(ResourceUnitName resUnitName: resources.keySet()){
@@ -345,19 +317,4 @@
 	public void freeResources(Map<ResourceUnitName, ResourceUnit> resources) {
 		
-		/*ResourceUnit peUnit = resources.get(StandardResourceUnitName.PE);
-		
-		if (peUnit instanceof ProcessingElements) {
-			ProcessingElements processingElements = (ProcessingElements) peUnit;
-
-			for (int i = 0; i < processingElements.size(); i++) {
-				processingElements.get(i).setStatus(ResourceStatus.FREE);
-			}
-		}*/
-
-		/*Memory m = (Memory) resources.get(StandardResourceUnitName.MEMORY);
-		if (m != null) {
-			m.getProvisioner().setState(ResourceUnitState.FREE);
-		}*/
-		
 		for(ResourceUnitName resUnitName: resources.keySet()){
 			ResourceUnit resUnit = resources.get(resUnitName);
@@ -366,4 +323,3 @@
 	}
 
-
 }
Index: DCWoRMS/trunk/src/schedframe/scheduling/queue/TaskQueue.java
===================================================================
--- DCWoRMS/trunk/src/schedframe/scheduling/queue/TaskQueue.java	(revision 481)
+++ DCWoRMS/trunk/src/schedframe/scheduling/queue/TaskQueue.java	(revision 490)
@@ -2,7 +2,8 @@
 
 import gridsim.gssim.DCWormsTags;
-import gssim.schedframe.scheduling.queues.AbstractStatsSupportingQueue;
 
 import org.joda.time.DateTime;
+
+import dcworms.schedframe.scheduling.queues.AbstractStatsSupportingQueue;
 
 import schedframe.scheduling.tasks.TaskInterface;
Index: DCWoRMS/trunk/src/schedframe/scheduling/tasks/Task.java
===================================================================
--- DCWoRMS/trunk/src/schedframe/scheduling/tasks/Task.java	(revision 481)
+++ DCWoRMS/trunk/src/schedframe/scheduling/tasks/Task.java	(revision 490)
@@ -78,5 +78,4 @@
 		this.brokerSubmitTime = null;
 		this.duration = null;
-	//	this.gridletID_ = (getJobId() + "_" + getId()).hashCode();
 		prepareTopology();
 	}
@@ -89,5 +88,4 @@
 		this.brokerSubmitTime = null;
 		this.duration = null;
-	//	this.gridletID_ = (getJobId() + getId()).hashCode();
 		prepareTopology();
 	}
Index: DCWoRMS/trunk/src/schedframe/scheduling/tasks/Job.java
===================================================================
--- DCWoRMS/trunk/src/schedframe/scheduling/tasks/Job.java	(revision 481)
+++ DCWoRMS/trunk/src/schedframe/scheduling/tasks/Job.java	(revision 490)
@@ -203,6 +203,6 @@
 		
 		List<Task> readyTasks = new ArrayList<Task>();
-
 		int size = tasks.size();
+		
 		for(int i = 0; i < size; i++){
 			int parCnt;
@@ -215,12 +215,9 @@
 			} catch(Exception e){
 				parCnt = 0;
-				//e.printStackTrace();
-			}
-			if(parCnt == 0)
-			{
+			}
+			if(parCnt == 0) {
 				readyTasks.add(task);
 			}
-			else
-			{
+			else {
 				for(int j = 0; j < parCnt; j++){
 					ParentType par = task.getDescription().getWorkflow().getParent(j);
Index: DCWoRMS/trunk/src/schedframe/scheduling/plugin/SchedulingPlugin.java
===================================================================
--- DCWoRMS/trunk/src/schedframe/scheduling/plugin/SchedulingPlugin.java	(revision 481)
+++ DCWoRMS/trunk/src/schedframe/scheduling/plugin/SchedulingPlugin.java	(revision 490)
@@ -3,4 +3,5 @@
 import schedframe.Plugin;
 import schedframe.events.scheduling.SchedulingEvent;
+import schedframe.scheduling.TaskList;
 import schedframe.scheduling.TaskListImpl;
 import schedframe.scheduling.manager.resources.ResourceManager;
@@ -12,5 +13,5 @@
 public interface SchedulingPlugin extends Plugin{
 
-	public int placeTasksInQueues(TaskListImpl newTasks,
+	public int placeTasksInQueues(TaskList newTasks,
 			TaskQueueList queues, 
 			ResourceManager resourceManager, ModuleList modules);
Index: DCWoRMS/trunk/src/schedframe/scheduling/plugin/estimation/ExecutionTimeEstimationPlugin.java
===================================================================
--- DCWoRMS/trunk/src/schedframe/scheduling/plugin/estimation/ExecutionTimeEstimationPlugin.java	(revision 477)
+++ DCWoRMS/trunk/src/schedframe/scheduling/plugin/estimation/ExecutionTimeEstimationPlugin.java	(revision 490)
@@ -1,7 +1,8 @@
 package schedframe.scheduling.plugin.estimation;
 
-import gssim.schedframe.scheduling.ExecTask;
 
 import java.util.Map;
+
+import dcworms.schedframe.scheduling.ExecTask;
 
 import schedframe.Plugin;
Index: DCWoRMS/trunk/src/schedframe/scheduling/policy/global/GlobalManagementSystem.java
===================================================================
--- DCWoRMS/trunk/src/schedframe/scheduling/policy/global/GlobalManagementSystem.java	(revision 481)
+++ DCWoRMS/trunk/src/schedframe/scheduling/policy/global/GlobalManagementSystem.java	(revision 490)
@@ -11,10 +11,12 @@
 import org.qcg.broker.schemas.schedulingplan.types.AllocationStatus;
 
+import dcworms.schedframe.scheduling.ExecTask;
+import dcworms.schedframe.scheduling.Executable;
+
 import qcg.shared.constants.BrokerConstants;
-import schedframe.events.scheduling.SchedulingEvent;
 import schedframe.events.scheduling.TaskArrivedEvent;
 import schedframe.events.scheduling.TimerEvent;
+import schedframe.scheduling.TaskListImpl;
 import schedframe.scheduling.WorkloadUnitHandler;
-import schedframe.scheduling.TaskListImpl;
 import schedframe.scheduling.plan.AllocationInterface;
 import schedframe.scheduling.plan.ScheduledTaskInterface;
@@ -35,6 +37,4 @@
 import gridsim.IO_data;
 import gridsim.gssim.DCWormsTags;
-import gssim.schedframe.scheduling.ExecTask;
-import gssim.schedframe.scheduling.Executable;
 
 public class GlobalManagementSystem extends AbstractManagementSystem {
@@ -80,17 +80,4 @@
 		
 		registerWorkloadUnit(wu);
-		/*Job job = (Job) wu;
-		jobRegistry.addJob(job);
-
-		if (log.isInfoEnabled())
-			log.info("Received job " + job.getId() + " at " + new DateTime(DateTimeUtilsExt.currentTimeMillis()));
-
-		List<JobInterface<?>> jobsList = new ArrayList<JobInterface<?>>();
-		jobsList.add(job);
-		WorkloadUnitList readyWorkloadUnits = new WorkloadUnitList();
-		readyWorkloadUnits.addAll(jobRegistry.getReadyTasks(jobsList));
-		schedulingPlugin.placeJobsInQueues(readyWorkloadUnits, queues, getResourceManager(), moduleList);
-
-		schedule(new TaskArrivedEvent());*/
 
 	}
@@ -104,5 +91,5 @@
 	
 
-	protected void scheduleAvaialbleTasks(Job job){
+	protected void schedule(JobInterface<?> job){
 		List<JobInterface<?>> jobsList = new ArrayList<JobInterface<?>>();
 		jobsList.add(job);
@@ -111,15 +98,10 @@
 		
 		schedulingPlugin.placeTasksInQueues(readyTasks, queues, getResourceManager(), moduleList);
-		schedule(new TaskArrivedEvent());
-	}
-	
-	protected void schedule(SchedulingEvent schedulingEvent) {
-
 		SchedulingPlanInterface<?> decision = schedulingPlugin.schedule(
-				schedulingEvent, queues, getJobRegistry(),  getResourceManager(), moduleList);
+				new TaskArrivedEvent(), queues, getJobRegistry(),  getResourceManager(), moduleList);
 		if (decision != null)
 			executeSchedulingPlan(decision);
 	}
-	
+
 	public void notifyReturnedWorkloadUnit(WorkloadUnit wu) {
 		Executable exec = (Executable) wu;
@@ -133,11 +115,10 @@
 		try {
 			Job job = jobRegistry.getJob(exec.getJobId());
-			/*Task task = job.getTask(exec.getTaskId());
+			Task task = job.getTask(exec.getTaskId());
 			if(exec.getProcessesId() == null){
 				try {
 					task.setStatus(exec.getStatus());
 				} catch (Exception e) {
-					// TODO Auto-generated catch block
-					e.printStackTrace();
+
 				}
 			} else {
@@ -150,5 +131,5 @@
 					}
 				}
-			}*/
+			}
 			
 			if(job.isFinished()){
@@ -156,12 +137,5 @@
 			}
 			else {
-				scheduleAvaialbleTasks(job);
-				/*List<JobInterface<?>> jobs = new ArrayList<JobInterface<?>>();
-				jobs.add(jobRegistry.getJobInfo(job.getId()));
-				WorkloadUnitList readyWorkloadUnits = new WorkloadUnitList();
-				readyWorkloadUnits.addAll(jobRegistry.getReadyTasks(jobs));
-				schedulingPlugin.placeJobsInQueues(readyWorkloadUnits, queues,
-						getResourceManager(), moduleList);
-				schedule(new TaskArrivedEvent());*/
+				schedule(job);
 			}
 			
@@ -269,6 +243,6 @@
 		IO_data data = new IO_data(task, 0, resID);
 		scheduler.send(scheduler.getOutputPort(), GridSimTags.SCHEDULE_NOW, GridSimTags.GRIDLET_SUBMIT, data);	
-		
-		//scheduler.send(providerName, GridSimTags.SCHEDULE_NOW, GridSimTags.GRIDLET_SUBMIT, job);			
+		//scheduler.send(providerName, GridSimTags.SCHEDULE_NOW, GridSimTags.GRIDLET_SUBMIT, job);	
+		
 		if(log.isDebugEnabled())
 			log.debug("Submitted job " + task.getId() + " to " + providerName);
@@ -278,11 +252,10 @@
 	class GlobalWorkloadUnitHandler implements  WorkloadUnitHandler{
 
-		public void handleJob(Job job){
-
+		public void handleJob(JobInterface<?> job){
 			if (log.isInfoEnabled())
 				log.info("Received job " + job.getId() + " at " + new DateTime(DateTimeUtilsExt.currentTimeMillis()));
 
 			jobRegistry.addJob(job);
-			scheduleAvaialbleTasks(job);
+			schedule(job);
 		}
 		
@@ -294,5 +267,4 @@
 			throw new RuntimeException("Not implemented since it isn't expected that tasks are send directly to the global scheduler.");
 		}
-
 	}
 
Index: DCWoRMS/trunk/src/schedframe/scheduling/policy/AbstractManagementSystem.java
===================================================================
--- DCWoRMS/trunk/src/schedframe/scheduling/policy/AbstractManagementSystem.java	(revision 481)
+++ DCWoRMS/trunk/src/schedframe/scheduling/policy/AbstractManagementSystem.java	(revision 490)
@@ -7,4 +7,8 @@
 import org.apache.commons.logging.LogFactory;
 import org.joda.time.DateTimeUtilsExt;
+
+import dcworms.schedframe.scheduling.ExecTask;
+import dcworms.schedframe.scheduling.Executable;
+import dcworms.schedframe.scheduling.queues.AbstractStatsSupportingQueue;
 
 import schedframe.PluginConfiguration;
@@ -34,7 +38,4 @@
 import gridsim.IO_data;
 import gridsim.gssim.DCWormsTags;
-import gssim.schedframe.scheduling.ExecTask;
-import gssim.schedframe.scheduling.Executable;
-import gssim.schedframe.scheduling.queues.AbstractStatsSupportingQueue;
 
 public abstract class AbstractManagementSystem {
@@ -144,5 +145,4 @@
 			return;
 		}
-		//Executable exec = (Executable) wu;
 		removeFromQueue(task);
 		scheduler.send(providerName, GridSimTags.SCHEDULE_NOW, GridSimTags.GRIDLET_SUBMIT, task);	
@@ -199,8 +199,8 @@
 	}
 	
-	protected boolean removeFromQueue(WorkloadUnit wu) {
+	protected boolean removeFromQueue(TaskInterface<?> task) {
 		for(TaskQueue queue : queues){
-			if(queue.contains(wu)){
-				queue.remove(wu);
+			if(queue.contains(task)){
+				queue.remove(task);
 				return true;
 			}
Index: DCWoRMS/trunk/src/schedframe/scheduling/policy/local/LocalManagementSystem.java
===================================================================
--- DCWoRMS/trunk/src/schedframe/scheduling/policy/local/LocalManagementSystem.java	(revision 481)
+++ DCWoRMS/trunk/src/schedframe/scheduling/policy/local/LocalManagementSystem.java	(revision 490)
@@ -1,4 +1,6 @@
 package schedframe.scheduling.policy.local;
 
+import dcworms.schedframe.scheduling.ExecTask;
+import dcworms.schedframe.scheduling.Executable;
 import eduni.simjava.Sim_event;
 import eduni.simjava.Sim_system;
@@ -7,6 +9,4 @@
 import gridsim.gssim.DCWormsTags;
 import gridsim.gssim.filter.ExecTaskFilter;
-import gssim.schedframe.scheduling.ExecTask;
-import gssim.schedframe.scheduling.Executable;
 
 import java.util.ArrayList;
@@ -41,6 +41,7 @@
 import schedframe.scheduling.ResourceHistoryItem;
 import schedframe.scheduling.Scheduler;
+import schedframe.scheduling.TaskList;
 import schedframe.scheduling.TaskListImpl;
-import schedframe.scheduling.UsedResourceList;
+import schedframe.scheduling.UsedResourcesList;
 import schedframe.scheduling.WorkloadUnitHandler;
 import schedframe.scheduling.manager.resources.LocalResourceManager;
@@ -78,6 +79,4 @@
 
 		super(providerId, entityName, execTimeEstimationPlugin, queues);
-
-		//schedulingPlugin = (LocalSchedulingPlugin) InstanceFactory.createInstance(schedulingPluginClassName, LocalSchedulingPlugin.class);
 		
 		if (schedPlugin == null) {
@@ -85,13 +84,11 @@
 		}
 		this.schedulingPlugin =  schedPlugin;
-		accTotalLoad = new Accumulator();
-		moduleList = new ModuleListImpl(1);
-
+		this.moduleList = new ModuleListImpl(1);
+		
+		this.accTotalLoad = new Accumulator();
 	}
 
 	public void init(Scheduler sched, ManagedResources managedResources) {
 		super.init(sched, managedResources);
-		//scheduler = sched;
-		//resourceManager = ResourceManagerFactory.createResourceManager(scheduler);
 		double load = 0;
 		accTotalLoad.add(load);
@@ -115,14 +112,13 @@
 			}
 			sendTimerEvent();
-
 			break;
 
 		case DCWormsTags.TASK_READY_FOR_EXECUTION:
 			
-			ExecTask data = (ExecTask) ev.get_data();
-			try {
-				data.setStatus(DCWormsTags.READY);
+			ExecTask execTask = (ExecTask) ev.get_data();
+			try {
+				execTask.setStatus(DCWormsTags.READY);
 				if (pluginSupportsEvent(tag)) {
-					SchedulingEvent event = new StartTaskExecutionEvent(data.getJobId(), data.getId());
+					SchedulingEvent event = new StartTaskExecutionEvent(execTask.getJobId(), execTask.getId());
 					SchedulingPlanInterface<?> decision =  schedulingPlugin.schedule(event,
 							queues,  getJobRegistry(), getResourceManager(), moduleList);
@@ -136,48 +132,36 @@
 		case DCWormsTags.TASK_EXECUTION_FINISHED:
 			obj = ev.get_data();
-			ExecTask exec = (ExecTask) obj;
-			if (exec.getStatus() == DCWormsTags.INEXEC) {
-				finalizeExecutable(exec);
-
-				sendFinishedWorkloadUnit(exec);
-				//task.setGridletStatus(Gridlet.SUCCESS);
-				//task.finalizeGridlet();
-				log.debug(exec.getJobId() + "_" + exec.getId() + " finished execution on " + new DateTime());
+			execTask = (ExecTask) obj;
+			if (execTask.getStatus() == DCWormsTags.INEXEC) {
+				
+				finalizeExecutable(execTask);
+				sendFinishedWorkloadUnit(execTask);
+				log.debug(execTask.getJobId() + "_" + execTask.getId() + " finished execution on " + new DateTime());
 				log.info(DCWormsConstants.USAGE_MEASURE_NAME + ": " + calculateTotalLoad(jobRegistry.getRunningTasks().size()));
-				/*UsedResourceList<ResourceHistoryItem> lastUsedList = task.getUsedResources();
-				Map<ResourceUnitName, AbstractResourceUnit> lastUsed = lastUsedList.getLast()
-						.getResourceUnits();
-				getAllocationManager().freeResources(lastUsed);
-				ProcessingElements pes = (ProcessingElements) lastUsed.get(StandardResourceUnitName.PROCESSINGELEMENTS);
-				for (ComputingResource resource : pes) {
-					resource.handleEvent(new EnergyEvent(EnergyEventType.TASK_FINISHED, task));
+				if (pluginSupportsEvent(tag)) {
+					SchedulingEvent event = new TaskFinishedEvent(execTask.getJobId(), execTask.getId());
+					SchedulingPlanInterface<?> decision = schedulingPlugin.schedule(event,
+							queues, getJobRegistry(), getResourceManager(), moduleList);
+					executeSchedulingPlan(decision);
 				}
-				SubTaskFilter filter = new SubTaskFilter(task.getGridletID(), GssimTags.TASK_REQUESTED_TIME_EXPIRED);
-				scheduler.sim_cancel(filter, null);
-				super.sendFinishJob((Executable) task.getGridlet());*/
-			}
+			}
+
+			Job job = jobRegistry.getJob(execTask.getJobId());
+			if(!job.isFinished()){
+				getWorkloadUnitHandler().handleJob(job);
+			}
+			break;
+			
+		case DCWormsTags.TASK_REQUESTED_TIME_EXPIRED:
+			obj = ev.get_data();
+			execTask = (Executable) obj;
 			if (pluginSupportsEvent(tag)) {
-				SchedulingEvent event = new TaskFinishedEvent(exec.getJobId(), exec.getId());
+				SchedulingEvent event = new TaskRequestedTimeExpiredEvent(execTask.getJobId(), execTask.getId());
 				SchedulingPlanInterface<?> decision = schedulingPlugin.schedule(event,
 						queues, getJobRegistry(), getResourceManager(), moduleList);
 				executeSchedulingPlan(decision);
 			}
-			Job job = jobRegistry.getJob(exec.getJobId());
-			if(!job.isFinished()){
-				getWorkloadUnitHandler().handleJob(job);
-			}
-
 			break;
-		case DCWormsTags.TASK_REQUESTED_TIME_EXPIRED:
-			obj = ev.get_data();
-			exec = (Executable) obj;
-			if (pluginSupportsEvent(tag)) {
-				SchedulingEvent event = new TaskRequestedTimeExpiredEvent(exec.getJobId(), exec.getId());
-				SchedulingPlanInterface<?> decision = schedulingPlugin.schedule(event,
-						queues, getJobRegistry(), getResourceManager(), moduleList);
-				executeSchedulingPlan(decision);
-			}
-
-			break;
+			
 		case DCWormsTags.UPDATE:
 			updateProcessingTimes(ev);
@@ -185,5 +169,4 @@
 		}
 	}
-	
 
 	public void notifyReturnedWorkloadUnit(WorkloadUnit wu) {
@@ -223,5 +206,5 @@
 				} else {
 					ExecTask exec = (ExecTask) task;
-					executeTask(exec, chooseResourcesForExecution(allocation.getProviderName(), (ExecTask)task));
+					executeTask(exec, chooseResourcesForExecution(allocation.getProviderName(), exec));
 				}
 			}
@@ -237,5 +220,5 @@
 			return;
 		removeFromQueue(task);
-		//double completionPercentage = (submittedTask.getLength() - submittedTask.getRemainingGridletLength())/submittedTask.getLength();
+
 		SchedulingEvent event = new SchedulingEvent(SchedulingEventType.START_TASK_EXECUTION);
 		int time = Double.valueOf(
@@ -251,7 +234,11 @@
 		ResourceHistoryItem resHistItem = new ResourceHistoryItem(choosenResources, currentTime);
 		exec.addUsedResources(resHistItem);
-
-		scheduler.sendInternal(time, DCWormsTags.TASK_EXECUTION_FINISHED,
-				exec);
+		try {
+			exec.setStatus(DCWormsTags.INEXEC);
+		} catch (Exception e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		scheduler.sendInternal(time, DCWormsTags.TASK_EXECUTION_FINISHED, exec);
 
 		try {
@@ -262,18 +249,15 @@
 			scheduler.sendInternal(t, DCWormsTags.TASK_REQUESTED_TIME_EXPIRED, exec);
 		}
-		
-		try {
-			exec.setStatus(DCWormsTags.INEXEC);
-		} catch (Exception e1) {
-			// TODO Auto-generated catch block
-			e1.printStackTrace();
-		}
+
 		log.info(DCWormsConstants.USAGE_MEASURE_NAME + ": " + calculateTotalLoad(jobRegistry.getRunningTasks().size()));
 		
 		PEUnit peUnit = (PEUnit)choosenResources.get(StandardResourceUnitName.PE);
-		if(peUnit instanceof ProcessingElements){
+		
+		notifyComputingResources(peUnit, EnergyEventType.TASK_STARTED, exec);
+		
+		/*if(peUnit instanceof ProcessingElements){
 			ProcessingElements pes = (ProcessingElements) peUnit;
 			for (ComputingResource resource : pes) {
-				resource.handleEvent(new EnergyEvent(EnergyEventType.TASK_FINISHED, exec));
+				resource.handleEvent(new EnergyEvent(EnergyEventType.TASK_STARTED, exec));
 			}
 		} else {
@@ -282,12 +266,9 @@
 				resource = ResourceController.getComputingResourceByName(peUnit.getResourceId());
 			} catch (ResourceException e) {
-				
-			}
-			resource.handleEvent(new EnergyEvent(EnergyEventType.TASK_FINISHED, exec));
-		}
-		/*ProcessingElements pes = (ProcessingElements) choosenResources.get(StandardResourceUnitName.PE);
-		for (ComputingResource resource : pes) {
-			resource.handleEvent(new EnergyEvent(EnergyEventType.TASK_STARTED, submittedTask));
-		}*/
+				return;
+			}
+			resource.handleEvent(new EnergyEvent(EnergyEventType.TASK_STARTED, exec));
+		}
+*/
 
 		/*for(ExecTaskInterface etask : jobRegistry.getRunningTasks()){
@@ -301,46 +282,15 @@
 		
 		Executable exec = (Executable)execTask;
-		try {
-			exec.setStatus(DCWormsTags.SUCCESS);
-		} catch (Exception e1) {
-			// TODO Auto-generated catch block
-			e1.printStackTrace();
-		}
 		exec.finalizeExecutable();
-		UsedResourceList<ResourceHistoryItem> lastUsedList = exec.getUsedResources();
-		Map<ResourceUnitName, ResourceUnit> lastUsed = lastUsedList.getLast()
-				.getResourceUnits();
-		getAllocationManager().freeResources(lastUsed);
-		
-		PEUnit peUnit = (PEUnit)lastUsed.get(StandardResourceUnitName.PE);
-		if(peUnit instanceof ProcessingElements){
-			ProcessingElements pes = (ProcessingElements) peUnit;
-			for (ComputingResource resource : pes) {
-				resource.handleEvent(new EnergyEvent(EnergyEventType.TASK_FINISHED, exec));
-			}
-		} else {
-			ComputingResource resource = null;
-			try {
-				resource = ResourceController.getComputingResourceByName(peUnit.getResourceId());
-			} catch (ResourceException e) {
-				
-			}
-			resource.handleEvent(new EnergyEvent(EnergyEventType.TASK_FINISHED, exec));
-		}
-		/*ProcessingElements pes = (ProcessingElements) lastUsed.get(StandardResourceUnitName.PE);
-		for (ComputingResource resource : pes) {
-			resource.handleEvent(new EnergyEvent(EnergyEventType.TASK_FINISHED, subTask));
-		}*/
+		
 		ExecTaskFilter filter = new ExecTaskFilter(exec.getUniqueId(), DCWormsTags.TASK_REQUESTED_TIME_EXPIRED);
 		scheduler.sim_cancel(filter, null);
 		
-
+		Task task;
 		Job job = jobRegistry.getJob(exec.getJobId());
-
-		Task task = null;
 		try {
 			task = job.getTask(exec.getTaskId());
 		} catch (NoSuchFieldException e) {
-			e.printStackTrace();
+			return;
 		}
 		if(exec.getProcessesId() == null){
@@ -360,4 +310,27 @@
 			}
 		}
+		
+		UsedResourcesList lastUsedList = exec.getUsedResources();
+		Map<ResourceUnitName, ResourceUnit> lastUsed = lastUsedList.getLast()
+				.getResourceUnits();
+		getAllocationManager().freeResources(lastUsed);
+		
+		PEUnit peUnit = (PEUnit)lastUsed.get(StandardResourceUnitName.PE);
+		notifyComputingResources(peUnit, EnergyEventType.TASK_FINISHED, exec);
+		/*if(peUnit instanceof ProcessingElements){
+			ProcessingElements pes = (ProcessingElements) peUnit;
+			for (ComputingResource resource : pes) {
+				resource.handleEvent(new EnergyEvent(EnergyEventType.TASK_FINISHED, exec));
+			}
+		} else {
+			ComputingResource resource = null;
+			try {
+				resource = ResourceController.getComputingResourceByName(peUnit.getResourceId());
+			} catch (ResourceException e) {
+				return;
+			}
+			resource.handleEvent(new EnergyEvent(EnergyEventType.TASK_FINISHED, exec));
+		}*/
+
 		//sendFinishedWorkloadUnit(executable);
 	}
@@ -374,14 +347,31 @@
 			ExecTask task = iter.next();
 			Executable exec = (Executable)task;
-			UsedResourceList<ResourceHistoryItem> usedResourcesList = exec.getUsedResources();
-			ResourceUnit unit = usedResourcesList.getLast().getResourceUnits()
+			UsedResourcesList usedResourcesList = exec.getUsedResources();
+			PEUnit peUnit = (PEUnit)usedResourcesList.getLast().getResourceUnits()
 					.get(StandardResourceUnitName.PE);
 
-			double load = getMIShare(timeSpan, (PEUnit) unit);
+			double load = getMIShare(timeSpan, peUnit);
 			exec.setCompletionPercentage(100 * timeSpan/exec.getEstimatedDuration());
 			addTotalLoad(load);
 		}
 	}
-
+	private void notifyComputingResources(PEUnit peUnit, EnergyEventType eventType, Object obj){
+
+		if(peUnit instanceof ProcessingElements){
+			ProcessingElements pes = (ProcessingElements) peUnit;
+			for (ComputingResource resource : pes) {
+				resource.handleEvent(new EnergyEvent(eventType, obj));
+			}
+		} else {
+			ComputingResource resource = null;
+			try {
+				resource = ResourceController.getComputingResourceByName(peUnit.getResourceId());
+			} catch (ResourceException e) {
+				return;
+			}
+			resource.handleEvent(new EnergyEvent(eventType, obj));
+		}
+	}
+	
 	private double getMIShare(double timeSpan, PEUnit pes) {
 		double localLoad;
@@ -402,6 +392,6 @@
 	protected void updateProcessingTimes(Sim_event ev) {
 		updateProcessingProgress();
-		for (ExecTask task : jobRegistry.getRunningTasks()) {
-			Executable exec = (Executable)task;
+		for (ExecTask execTask : jobRegistry.getRunningTasks()) {
+			Executable exec = (Executable)execTask;
 			List<String> visitedResource = exec.getVisitedResources();
 			String originResource = ev.get_data().toString();
@@ -411,11 +401,7 @@
 			
 			Map<ResourceUnitName, ResourceUnit> choosenResources = exec.getUsedResources().getLast().getResourceUnits();
-			//double completionPercentage = (task.getLength() - subTask.getRemainingGridletLength())/task.getLength();
 			double time = execTimeEstimationPlugin.execTimeEstimation(new SchedulingEvent(SchedulingEventType.RESOURCE_STATE_CHANGED), 
-					task, choosenResources, exec.getCompletionPercentage());
-
-			/*if(!subTask.getVisitedResources().contains(ev.get_data().toString())) {
-				continue;
-			}*/
+					execTask, choosenResources, exec.getCompletionPercentage());
+
 			//check if the new estimated end time is equal to the previous one; if yes the continue without update
 			if( DoubleMath.subtract((exec.getExecStartTime() + exec.getEstimatedDuration()), (new DateTime().getMillis()/1000 + time)) == 0.0){
@@ -424,6 +410,5 @@
 			ExecTaskFilter filter = new ExecTaskFilter(exec.getUniqueId(), DCWormsTags.TASK_EXECUTION_FINISHED);
 			scheduler.sim_cancel(filter, null);
-			scheduler.sendInternal(time, DCWormsTags.TASK_EXECUTION_FINISHED, task);
-
+			scheduler.sendInternal(time, DCWormsTags.TASK_EXECUTION_FINISHED, execTask);
 		}
 	}	
@@ -443,5 +428,4 @@
 				numberOfPE = numberOfPE + resUnit.getAmount();
 			}
-			//numberOfPE = getResourceManager().getPE().size();
 		} catch (Exception e) {
 			numberOfPE = 1;
@@ -464,4 +448,5 @@
 			ExecTask task) {
 
+		Map<ResourceUnitName, ResourceUnit> map = new HashMap<ResourceUnitName, ResourceUnit>();
 		ResourceManager resourceManager = this.resourceManager;
 		if(resourceName != null){
@@ -472,9 +457,6 @@
 				return null;
 			}
-
 			resourceManager = new LocalResourceManager(resource);
 		}
-		Map<ResourceUnitName, ResourceUnit> map = new HashMap<ResourceUnitName, ResourceUnit>();
-
 
 		int cpuRequest;
@@ -485,5 +467,4 @@
 		}
 
-		//PEUnit processingUnits = null;
 		if (cpuRequest != 0) {
 			
@@ -494,6 +475,6 @@
 				return null;
 			}
+			
 			List<ResourceUnit> choosenPEUnits = new ArrayList<ResourceUnit>();
-
 			for (int i = 0; i < availableUnits.size() && cpuRequest > 0; i++) {
 				PEUnit peUnit = (PEUnit) availableUnits .get(i);
@@ -508,5 +489,4 @@
 				return null;
 			}
-
 			map.put(StandardResourceUnitName.PE, choosenPEUnits.get(0));
 		}
@@ -529,5 +509,5 @@
 	class LocalWorkloadUnitHandler implements WorkloadUnitHandler{
 		
-		public void handleJob(Job job){
+		public void handleJob(JobInterface<?> job){
 
 			if (log.isInfoEnabled())
@@ -536,17 +516,17 @@
 			List<JobInterface<?>> jobsList = new ArrayList<JobInterface<?>>();
 			jobsList.add(job);
-			TaskListImpl readyTasks = new TaskListImpl();
+			TaskListImpl availableTasks = new TaskListImpl();
 			for(Task task: jobRegistry.getAvailableTasks(jobsList)){
 				task.setStatus((int)BrokerConstants.TASK_STATUS_QUEUED);
-				readyTasks.add(task);
-			}
-
-			for(WorkloadUnit e:readyTasks){	
-				registerWorkloadUnit(e);
-			}
-		}
-		
-		public void handleTask(TaskInterface<?> ti){
-			Task task = (Task)ti;
+				availableTasks.add(task);
+			}
+
+			for(TaskInterface<?> task: availableTasks){	
+				registerWorkloadUnit(task);
+			}
+		}
+		
+		public void handleTask(TaskInterface<?> t){
+			Task task = (Task)t;
 			List<AbstractProcesses> processes = task.getProcesses();
 
@@ -564,22 +544,19 @@
 		
 		public void handleExecutable(ExecTask task){
+			
 			Executable exec = (Executable) task;
-
-			// int cost =
-			// this.resourceManager.getResourceCharacteristic().getResUnits() !=
-			// null ?
-			// this.resourceManager.getResourceCharacteristic().getResUnits().get(ResourceParameterName.COST).getAmount()
-			// : 1;
-
-			exec.visitResource(scheduler.get_name());
+			jobRegistry.addExecTask(exec);
+			
+			exec.trackResource(scheduler.get_name());
 			Scheduler parentScheduler = scheduler.getParent();
-			while (parentScheduler != null && !exec.getVisitedResources().contains(parentScheduler.get_name())) {
-				exec.visitResource(parentScheduler.get_name());
+			List<String> visitedResource = exec.getVisitedResources();
+			String [] visitedResourcesArray = visitedResource.toArray(new String[visitedResource.size()]);
+			while (parentScheduler != null && !ArrayUtils.contains(visitedResourcesArray, parentScheduler.get_name())) {
+				exec.trackResource(parentScheduler.get_name());
 				parentScheduler = parentScheduler.getParent();
 			}
-			
 			exec.setSchedulerName(scheduler.get_id());
-			jobRegistry.addExecTask(exec);
-			TaskListImpl newTasks = new TaskListImpl();
+			
+			TaskList newTasks = new TaskListImpl();
 			newTasks.add(exec);
 		
Index: DCWoRMS/trunk/src/schedframe/scheduling/WorkloadUnitHandler.java
===================================================================
--- DCWoRMS/trunk/src/schedframe/scheduling/WorkloadUnitHandler.java	(revision 481)
+++ DCWoRMS/trunk/src/schedframe/scheduling/WorkloadUnitHandler.java	(revision 490)
@@ -1,12 +1,11 @@
 package schedframe.scheduling;
 
-import schedframe.scheduling.tasks.Job;
+import dcworms.schedframe.scheduling.ExecTask;
+import schedframe.scheduling.tasks.JobInterface;
+import schedframe.scheduling.tasks.TaskInterface;
 
-import schedframe.scheduling.tasks.TaskInterface;
-import gssim.schedframe.scheduling.ExecTask;
-
-public 	interface WorkloadUnitHandler{
+public interface WorkloadUnitHandler{
 	
-	public void handleJob(Job job);
+	public void handleJob(JobInterface<?> job);
 	
 	public void handleTask(TaskInterface<?> task);
Index: DCWoRMS/trunk/src/schedframe/scheduling/UsedResourceList.java
===================================================================
--- DCWoRMS/trunk/src/schedframe/scheduling/UsedResourceList.java	(revision 477)
+++ 	(revision )
@@ -1,12 +1,0 @@
-package schedframe.scheduling;
-
-import java.util.LinkedList;
-
-public class UsedResourceList<E> extends LinkedList<E>{
-
-	/**
-	 * 
-	 */
-	private static final long serialVersionUID = 1L;
-	
-}
