diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/hyracks/bootstrap/NCApplicationEntryPoint.java b/asterix-app/src/main/java/edu/uci/ics/asterix/hyracks/bootstrap/NCApplicationEntryPoint.java
index 4e5fde1..8d38b56 100644
--- a/asterix-app/src/main/java/edu/uci/ics/asterix/hyracks/bootstrap/NCApplicationEntryPoint.java
+++ b/asterix-app/src/main/java/edu/uci/ics/asterix/hyracks/bootstrap/NCApplicationEntryPoint.java
@@ -18,132 +18,152 @@
 import edu.uci.ics.hyracks.api.application.INCApplicationEntryPoint;
 
 public class NCApplicationEntryPoint implements INCApplicationEntryPoint {
-    private static final Logger LOGGER = Logger.getLogger(NCApplicationEntryPoint.class.getName());
+	private static final Logger LOGGER = Logger
+			.getLogger(NCApplicationEntryPoint.class.getName());
 
-    private INCApplicationContext ncApplicationContext = null;
-    private AsterixAppRuntimeContext runtimeContext;
-    private String nodeId;
-    private boolean isMetadataNode = false;
-    private boolean stopInitiated = false;
-    private SystemState systemState = SystemState.NEW_UNIVERSE;
+	private INCApplicationContext ncApplicationContext = null;
+	private AsterixAppRuntimeContext runtimeContext;
+	private String nodeId;
+	private boolean isMetadataNode = false;
+	private boolean stopInitiated = false;
+	private SystemState systemState = SystemState.NEW_UNIVERSE;
 
-    @Override
-    public void start(INCApplicationContext ncAppCtx, String[] args) throws Exception {
-        ncApplicationContext = ncAppCtx;
-        nodeId = ncApplicationContext.getNodeId();
-        if (LOGGER.isLoggable(Level.INFO)) {
-            LOGGER.info("Starting Asterix node controller: " + nodeId);
-        }
+	@Override
+	public void start(INCApplicationContext ncAppCtx, String[] args)
+			throws Exception {
+		ncApplicationContext = ncAppCtx;
+		nodeId = ncApplicationContext.getNodeId();
+		if (LOGGER.isLoggable(Level.INFO)) {
+			LOGGER.info("Starting Asterix node controller: " + nodeId);
+		}
 
-        runtimeContext = new AsterixAppRuntimeContext(ncApplicationContext);
-        runtimeContext.initialize();
-        ncApplicationContext.setApplicationObject(runtimeContext);
-        JVMShutdownHook sHook = new JVMShutdownHook(this);
-        Runtime.getRuntime().addShutdownHook(sHook);
+		runtimeContext = new AsterixAppRuntimeContext(ncApplicationContext);
+		runtimeContext.initialize();
+		ncApplicationContext.setApplicationObject(runtimeContext);
+		JVMShutdownHook sHook = new JVMShutdownHook(this);
+		Runtime.getRuntime().addShutdownHook(sHook);
 
-        //#. recover if the system is corrupted by checking system state.
-        IRecoveryManager recoveryMgr = runtimeContext.getTransactionSubsystem().getRecoveryManager();
-        systemState = recoveryMgr.getSystemState();
-        if (systemState != SystemState.NEW_UNIVERSE) {
-            PersistentLocalResourceRepository localResourceRepository = (PersistentLocalResourceRepository) runtimeContext
-                    .getLocalResourceRepository();
-            localResourceRepository.initialize(nodeId, null, false, runtimeContext.getResourceIdFactory());
-        }
-        if (systemState == SystemState.CORRUPTED) {
-            recoveryMgr.startRecovery(true);
-        } else if (systemState == SystemState.NEW_UNIVERSE) {
-            recoveryMgr.checkpoint(true);
-        }
-    }
+		// #. recover if the system is corrupted by checking system state.
+		IRecoveryManager recoveryMgr = runtimeContext.getTransactionSubsystem()
+				.getRecoveryManager();
+		systemState = recoveryMgr.getSystemState();
+		if (systemState != SystemState.NEW_UNIVERSE) {
+			PersistentLocalResourceRepository localResourceRepository = (PersistentLocalResourceRepository) runtimeContext
+					.getLocalResourceRepository();
+			localResourceRepository.initialize(nodeId, null, false,
+					runtimeContext.getResourceIdFactory());
+		}
+		if (systemState == SystemState.CORRUPTED) {
+			recoveryMgr.startRecovery(true);
+		} else if (systemState == SystemState.NEW_UNIVERSE) {
+			recoveryMgr.checkpoint(true);
+		}
+	}
 
-    @Override
-    public void stop() throws Exception {
-        if (!stopInitiated) {
-            stopInitiated = true;
-            if (LOGGER.isLoggable(Level.INFO)) {
-                LOGGER.info("Stopping Asterix node controller: " + nodeId);
-            }
+	@Override
+	public void stop() throws Exception {
+		if (!stopInitiated) {
+			stopInitiated = true;
+			if (LOGGER.isLoggable(Level.INFO)) {
+				LOGGER.info("Stopping Asterix node controller: " + nodeId);
+			}
 
-            IRecoveryManager recoveryMgr = runtimeContext.getTransactionSubsystem().getRecoveryManager();
-            recoveryMgr.checkpoint(true);
+			IRecoveryManager recoveryMgr = runtimeContext
+					.getTransactionSubsystem().getRecoveryManager();
+			recoveryMgr.checkpoint(true);
 
-            if (isMetadataNode) {
-                MetadataBootstrap.stopUniverse();
-            }
-            runtimeContext.deinitialize();
-        } else {
-            if (LOGGER.isLoggable(Level.INFO)) {
-                LOGGER.info("Duplicate attempt to stop ignored: " + nodeId);
-            }
-        }
-    }
+			if (isMetadataNode) {
+				MetadataBootstrap.stopUniverse();
+			}
+			runtimeContext.deinitialize();
+		} else {
+			if (LOGGER.isLoggable(Level.INFO)) {
+				LOGGER.info("Duplicate attempt to stop ignored: " + nodeId);
+			}
+		}
+	}
 
-    @Override
-    public void notifyStartupComplete() throws Exception {
-        IAsterixStateProxy proxy = (IAsterixStateProxy) ncApplicationContext.getDistributedState();
+	@Override
+	public void notifyStartupComplete() throws Exception {
+		IAsterixStateProxy proxy = (IAsterixStateProxy) ncApplicationContext
+				.getDistributedState();
 
-        if (systemState == SystemState.NEW_UNIVERSE) {
-            PersistentLocalResourceRepository localResourceRepository = (PersistentLocalResourceRepository) runtimeContext
-                    .getLocalResourceRepository();
-            localResourceRepository.initialize(nodeId, proxy.getAsterixProperties().getStores().get(nodeId)[0], true,
-                    null);
-        }
+		if (systemState == SystemState.NEW_UNIVERSE) {
+			PersistentLocalResourceRepository localResourceRepository = (PersistentLocalResourceRepository) runtimeContext
+					.getLocalResourceRepository();
+			System.out.println("nodeid" + nodeId);
+			System.out.println("proxy" + proxy);
+			System.out.println("stores"
+					+ proxy.getAsterixProperties().getStores());
+			System.out.println("store"
+					+ proxy.getAsterixProperties().getStores().get(nodeId)[0]);
 
-        isMetadataNode = nodeId.equals(proxy.getAsterixProperties().getMetadataNodeName());
-        if (isMetadataNode) {
-            registerRemoteMetadataNode(proxy);
+			localResourceRepository.initialize(nodeId, proxy
+					.getAsterixProperties().getStores().get(nodeId)[0], true,
+					null);
+		}
 
-            if (LOGGER.isLoggable(Level.INFO)) {
-                LOGGER.info("Bootstrapping metadata");
-            }
-            MetadataManager.INSTANCE = new MetadataManager(proxy);
-            MetadataManager.INSTANCE.init();
-            MetadataBootstrap.startUniverse(proxy.getAsterixProperties(), ncApplicationContext,
-                    systemState == SystemState.NEW_UNIVERSE);
-            MetadataBootstrap.startDDLRecovery();
-        }
+		isMetadataNode = nodeId.equals(proxy.getAsterixProperties()
+				.getMetadataNodeName());
+		if (isMetadataNode) {
+			registerRemoteMetadataNode(proxy);
 
-        IRecoveryManager recoveryMgr = runtimeContext.getTransactionSubsystem().getRecoveryManager();
-        recoveryMgr.checkpoint(true);
+			if (LOGGER.isLoggable(Level.INFO)) {
+				LOGGER.info("Bootstrapping metadata");
+			}
+			MetadataManager.INSTANCE = new MetadataManager(proxy);
+			MetadataManager.INSTANCE.init();
+			MetadataBootstrap.startUniverse(proxy.getAsterixProperties(),
+					ncApplicationContext,
+					systemState == SystemState.NEW_UNIVERSE);
+			MetadataBootstrap.startDDLRecovery();
+		}
 
-        //TODO
-        //reclaim storage for orphaned index artifacts in NCs.
-    }
+		IRecoveryManager recoveryMgr = runtimeContext.getTransactionSubsystem()
+				.getRecoveryManager();
+		recoveryMgr.checkpoint(true);
 
-    public void registerRemoteMetadataNode(IAsterixStateProxy proxy) throws RemoteException {
-        IMetadataNode stub = null;
-        MetadataNode.INSTANCE.initialize(runtimeContext);
-        stub = (IMetadataNode) UnicastRemoteObject.exportObject(MetadataNode.INSTANCE, 0);
-        proxy.setMetadataNode(stub);
+		// TODO
+		// reclaim storage for orphaned index artifacts in NCs.
+	}
 
-        if (LOGGER.isLoggable(Level.INFO)) {
-            LOGGER.info("Metadata node bound");
-        }
-    }
+	public void registerRemoteMetadataNode(IAsterixStateProxy proxy)
+			throws RemoteException {
+		IMetadataNode stub = null;
+		MetadataNode.INSTANCE.initialize(runtimeContext);
+		stub = (IMetadataNode) UnicastRemoteObject.exportObject(
+				MetadataNode.INSTANCE, 0);
+		proxy.setMetadataNode(stub);
 
-    /**
-     * Shutdown hook that invokes {@link NCApplicationEntryPoint#stop() stop} method.
-     */
-    private static class JVMShutdownHook extends Thread {
+		if (LOGGER.isLoggable(Level.INFO)) {
+			LOGGER.info("Metadata node bound");
+		}
+	}
 
-        private final NCApplicationEntryPoint ncAppEntryPoint;
+	/**
+	 * Shutdown hook that invokes {@link NCApplicationEntryPoint#stop() stop}
+	 * method.
+	 */
+	private static class JVMShutdownHook extends Thread {
 
-        public JVMShutdownHook(NCApplicationEntryPoint ncAppEntryPoint) {
-            this.ncAppEntryPoint = ncAppEntryPoint;
-        }
+		private final NCApplicationEntryPoint ncAppEntryPoint;
 
-        public void run() {
-            if (LOGGER.isLoggable(Level.INFO)) {
-                LOGGER.info("Shutdown hook in progress");
-            }
-            try {
-                ncAppEntryPoint.stop();
-            } catch (Exception e) {
-                if (LOGGER.isLoggable(Level.WARNING)) {
-                    LOGGER.warning("Exception in executing shutdown hook" + e);
-                }
-            }
-        }
-    }
+		public JVMShutdownHook(NCApplicationEntryPoint ncAppEntryPoint) {
+			this.ncAppEntryPoint = ncAppEntryPoint;
+		}
+
+		public void run() {
+			if (LOGGER.isLoggable(Level.INFO)) {
+				LOGGER.info("Shutdown hook in progress");
+			}
+			try {
+				ncAppEntryPoint.stop();
+			} catch (Exception e) {
+				if (LOGGER.isLoggable(Level.WARNING)) {
+					LOGGER.warning("Exception in executing shutdown hook" + e);
+				}
+			}
+		}
+	}
 
 }
\ No newline at end of file
diff --git a/asterix-events/src/main/java/edu/uci/ics/asterix/event/driver/EventDriver.java b/asterix-events/src/main/java/edu/uci/ics/asterix/event/driver/EventDriver.java
index d3c338d..66c0102 100644
--- a/asterix-events/src/main/java/edu/uci/ics/asterix/event/driver/EventDriver.java
+++ b/asterix-events/src/main/java/edu/uci/ics/asterix/event/driver/EventDriver.java
@@ -41,7 +41,7 @@
 public class EventDriver {
 
     public static final String CLIENT_NODE_ID = "client_node";
-    public static final Node CLIENT_NODE = new Node(CLIENT_NODE_ID, "127.0.0.1", null, null, null, null, null);
+    public static final Node CLIENT_NODE = new Node(CLIENT_NODE_ID, "127.0.0.1", null, null, null, null, null, null);
 
     private static String eventsDir;
     private static Events events;
@@ -141,9 +141,9 @@
         args.add(scriptDirSuffix);
         Node clientNode = new Node();
         clientNode.setId("client");
-        clientNode.setIp("127.0.0.1");
+        clientNode.setClusterIp("127.0.0.1");
         for (Node node : cluster.getNode()) {
-            args.add(node.getIp());
+            args.add(node.getClusterIp());
         }
         EventUtil.executeLocalScript(clientNode, eventsDir + "/" + "events" + "/" + "prepare.sh", args);
     }
@@ -153,11 +153,10 @@
         args.add(scriptDirSuffix);
         Node clientNode = new Node();
         clientNode.setId("client");
-        clientNode.setIp("127.0.0.1");
+        clientNode.setClusterIp("127.0.0.1");
         for (Node node : cluster.getNode()) {
-            args.add(node.getIp());
+            args.add(node.getClusterIp());
         }
         EventUtil.executeLocalScript(clientNode, eventsDir + "/" + "events" + "/" + "cleanup.sh", args);
     }
-
 }
diff --git a/asterix-events/src/main/java/edu/uci/ics/asterix/event/management/EventExecutor.java b/asterix-events/src/main/java/edu/uci/ics/asterix/event/management/EventExecutor.java
index 0157f65..6d89c88 100644
--- a/asterix-events/src/main/java/edu/uci/ics/asterix/event/management/EventExecutor.java
+++ b/asterix-events/src/main/java/edu/uci/ics/asterix/event/management/EventExecutor.java
@@ -18,6 +18,7 @@
 import java.io.File;
 import java.io.IOException;
 import java.io.StringWriter;
+import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -44,21 +45,28 @@
         List<String> pargs = new ArrayList<String>();
         pargs.add("/bin/bash");
         pargs.add(client.getEventsDir() + File.separator + "scripts" + File.separator + EXECUTE_SCRIPT);
-        StringBuffer envBuffer = new StringBuffer(IP_LOCATION + "=" + node.getIp() + " ");
+        StringBuffer envBuffer = new StringBuffer(IP_LOCATION + "=" + node.getClusterIp() + " ");
         if (!node.getId().equals(EventDriver.CLIENT_NODE_ID) && cluster.getEnv() != null) {
             for (Property p : cluster.getEnv().getProperty()) {
                 if (p.getKey().equals("JAVA_HOME")) {
                     String val = node.getJavaHome() == null ? p.getValue() : node.getJavaHome();
                     envBuffer.append(p.getKey() + "=" + val + " ");
                 } else if (p.getKey().equals("JAVA_OPTS")) {
-                    String val = "\"" + "-Xmx"
-                            + (node.getJavaHeap() == null ? cluster.getJavaHeap() : node.getJavaHeap());
-                    if (node.getDebug() != null) {
-                        val = val + " " + "-Xdebug -Xrunjdwp:transport=dt_socket,address=" + node.getDebug().intValue()
-                                + "," + "server=y,suspend=n";
+                    StringBuilder builder = new StringBuilder();
+                    builder.append("\"");
+                    String javaOpts = (node.getJavaOpts() == null ? cluster.getJavaOpts() : node.getJavaOpts());
+                    if (javaOpts != null) {
+                        builder.append(javaOpts);
                     }
-                    val = val + "\"";
-                    envBuffer.append(p.getKey() + "=" + val + " ");
+                    if (cluster.isDebugEnabled() != null && cluster.isDebugEnabled().booleanValue()) {
+                        BigInteger debugPort = node.getDebug() == null ? cluster.getDebug() : node.getDebug();
+                        if (debugPort != null) {
+                            builder.append("-Xdebug -Xrunjdwp:transport=dt_socket,address=" + debugPort.intValue()
+                                    + "," + "server=y,suspend=n");
+                        }
+                    }
+                    builder.append("\"");
+                    envBuffer.append(p.getKey() + "=" + builder + " ");
                 } else {
                     envBuffer.append(p.getKey() + "=" + p.getValue() + " ");
                 }
@@ -66,6 +74,7 @@
             }
             pargs.add(cluster.getUsername() == null ? System.getProperty("user.name") : cluster.getUsername());
         }
+
         StringBuffer argBuffer = new StringBuffer();
         if (args != null && args.size() > 0) {
             for (String arg : args) {
@@ -74,7 +83,7 @@
         }
 
         ProcessBuilder pb = new ProcessBuilder(pargs);
-        pb.environment().put(IP_LOCATION, node.getIp());
+        pb.environment().put(IP_LOCATION, node.getClusterIp());
         pb.environment().put(CLUSTER_ENV, envBuffer.toString());
         pb.environment().put(SCRIPT, script);
         pb.environment().put(ARGS, argBuffer.toString());
diff --git a/asterix-events/src/main/java/edu/uci/ics/asterix/event/management/EventUtil.java b/asterix-events/src/main/java/edu/uci/ics/asterix/event/management/EventUtil.java
index bf31e9f..d484947 100644
--- a/asterix-events/src/main/java/edu/uci/ics/asterix/event/management/EventUtil.java
+++ b/asterix-events/src/main/java/edu/uci/ics/asterix/event/management/EventUtil.java
@@ -31,232 +31,215 @@
 
 public class EventUtil {
 
-	public static final String EVENTS_DIR = "events";
-	public static final String CLUSTER_CONF = "config/cluster.xml";
-	public static final String PATTERN_CONF = "config/pattern.xml";
-	public static final DateFormat dateFormat = new SimpleDateFormat(
-			"yyyy/MM/dd HH:mm:ss");
+    public static final String EVENTS_DIR = "events";
+    public static final String CLUSTER_CONF = "config/cluster.xml";
+    public static final String PATTERN_CONF = "config/pattern.xml";
+    public static final DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
 
-	private static final String IP_LOCATION = "IP_LOCATION";
-	private static final String CLUSTER_ENV = "ENV";
-	private static final String SCRIPT = "SCRIPT";
-	private static final String ARGS = "ARGS";
-	private static final String EXECUTE_SCRIPT = "events/execute.sh";
+    private static final String IP_LOCATION = "IP_LOCATION";
+    private static final String CLUSTER_ENV = "ENV";
+    private static final String SCRIPT = "SCRIPT";
+    private static final String ARGS = "ARGS";
+    private static final String EXECUTE_SCRIPT = "events/execute.sh";
 
-	public static long parseTimeInterval(ValueType v, String unit)
-			throws IllegalArgumentException {
-		int val = 0;
-		switch (v.getType()) {
-		case ABS:
-			val = Integer.parseInt(v.getAbsoluteValue());
-			break;
-		case RANDOM_MIN_MAX:
-			val = Randomizer.getInstance().getRandomInt(v.getMin(), v.getMax());
-			break;
-		case RANDOM_RANGE:
-			String[] values = v.getRangeSet();
-			val = Integer.parseInt(values[Randomizer.getInstance()
-					.getRandomInt(0, values.length - 1)]);
-			break;
-		}
-		return computeInterval(val, unit);
-	}
+    public static long parseTimeInterval(ValueType v, String unit) throws IllegalArgumentException {
+        int val = 0;
+        switch (v.getType()) {
+            case ABS:
+                val = Integer.parseInt(v.getAbsoluteValue());
+                break;
+            case RANDOM_MIN_MAX:
+                val = Randomizer.getInstance().getRandomInt(v.getMin(), v.getMax());
+                break;
+            case RANDOM_RANGE:
+                String[] values = v.getRangeSet();
+                val = Integer.parseInt(values[Randomizer.getInstance().getRandomInt(0, values.length - 1)]);
+                break;
+        }
+        return computeInterval(val, unit);
+    }
 
-	public static long parseTimeInterval(String v, String unit)
-			throws IllegalArgumentException {
-		int value = Integer.parseInt(v);
-		return computeInterval(value, unit);
-	}
+    public static long parseTimeInterval(String v, String unit) throws IllegalArgumentException {
+        int value = Integer.parseInt(v);
+        return computeInterval(value, unit);
+    }
 
-	private static long computeInterval(int val, String unit) {
-		int vmult = 1;
-		if ("hr".equalsIgnoreCase(unit)) {
-			vmult = 3600 * 1000;
-		} else if ("min".equalsIgnoreCase(unit)) {
-			vmult = 60 * 1000;
-		} else if ("sec".equalsIgnoreCase(unit)) {
-			vmult = 1000;
-		} else
-			throw new IllegalArgumentException(
-					" invalid unit value specified for frequency (hr,min,sec)");
-		return val * vmult;
+    private static long computeInterval(int val, String unit) {
+        int vmult = 1;
+        if ("hr".equalsIgnoreCase(unit)) {
+            vmult = 3600 * 1000;
+        } else if ("min".equalsIgnoreCase(unit)) {
+            vmult = 60 * 1000;
+        } else if ("sec".equalsIgnoreCase(unit)) {
+            vmult = 1000;
+        } else
+            throw new IllegalArgumentException(" invalid unit value specified for frequency (hr,min,sec)");
+        return val * vmult;
 
-	}
+    }
 
-	public static Event getEvent(Pattern pattern, Events events) {
-		for (Event event : events.getEvent()) {
-			if (event.getType().equals(pattern.getEvent().getType())) {
-				return event;
-			}
-		}
-		throw new IllegalArgumentException(" Unknown event type"
-				+ pattern.getEvent().getType());
-	}
+    public static Event getEvent(Pattern pattern, Events events) {
+        for (Event event : events.getEvent()) {
+            if (event.getType().equals(pattern.getEvent().getType())) {
+                return event;
+            }
+        }
+        throw new IllegalArgumentException(" Unknown event type" + pattern.getEvent().getType());
+    }
 
-	public static Node getEventLocation(Pattern pattern,
-			List<Node> candidateLocations, Cluster cluster) {
-		ValueType value = new ValueType(pattern.getEvent().getNodeid()
-				.getValue());
-		Node location = null;
-		Type vtype = value.getType();
+    public static Node getEventLocation(Pattern pattern, List<Node> candidateLocations, Cluster cluster) {
+        ValueType value = new ValueType(pattern.getEvent().getNodeid().getValue());
+        Node location = null;
+        Type vtype = value.getType();
 
-		switch (vtype) {
-		case ABS:
-			location = getNodeFromId(value.getAbsoluteValue(), cluster);
-			break;
-		case RANDOM_RANGE:
-			int nodeIndex = Randomizer.getInstance().getRandomInt(0,
-					candidateLocations.size() - 1);
-			location = candidateLocations.get(nodeIndex);
-			break;
-		case RANDOM_MIN_MAX:
-			throw new IllegalStateException(
-					" Canont configure a min max value range for location");
-		}
-		return location;
+        switch (vtype) {
+            case ABS:
+                location = getNodeFromId(value.getAbsoluteValue(), cluster);
+                break;
+            case RANDOM_RANGE:
+                int nodeIndex = Randomizer.getInstance().getRandomInt(0, candidateLocations.size() - 1);
+                location = candidateLocations.get(nodeIndex);
+                break;
+            case RANDOM_MIN_MAX:
+                throw new IllegalStateException(" Canont configure a min max value range for location");
+        }
+        return location;
 
-	}
+    }
 
-	public static List<Node> getCandidateLocations(Pattern pattern,
-			Cluster cluster) {
-		ValueType value = new ValueType(pattern.getEvent().getNodeid()
-				.getValue());
-		List<Node> candidateList = new ArrayList<Node>();
-		switch (value.getType()) {
-		case ABS:
-			candidateList.add(getNodeFromId(value.getAbsoluteValue(), cluster));
-			break;
-		case RANDOM_RANGE:
-			boolean anyOption = false;
-			String[] values = value.getRangeSet();
-			for (String v : values) {
-				if (v.equalsIgnoreCase("ANY")) {
-					anyOption = true;
-				}
-			}
-			if (anyOption) {
-				for (Node node : cluster.getNode()) {
-					candidateList.add(node);
-				}
-			} else {
-				boolean found = false;
-				for (String v : values) {
-					for (Node node : cluster.getNode()) {
-						if (node.getId().equals(v)) {
-							candidateList.add(node);
-							found = true;
-							break;
-						}
-					}
-					if (!found) {
-						throw new IllegalStateException("Unknonw nodeId : " + v);
-					}
-					found = false;
-				}
+    public static List<Node> getCandidateLocations(Pattern pattern, Cluster cluster) {
+        ValueType value = new ValueType(pattern.getEvent().getNodeid().getValue());
+        List<Node> candidateList = new ArrayList<Node>();
+        switch (value.getType()) {
+            case ABS:
+                candidateList.add(getNodeFromId(value.getAbsoluteValue(), cluster));
+                break;
+            case RANDOM_RANGE:
+                boolean anyOption = false;
+                String[] values = value.getRangeSet();
+                for (String v : values) {
+                    if (v.equalsIgnoreCase("ANY")) {
+                        anyOption = true;
+                    }
+                }
+                if (anyOption) {
+                    for (Node node : cluster.getNode()) {
+                        candidateList.add(node);
+                    }
+                } else {
+                    boolean found = false;
+                    for (String v : values) {
+                        for (Node node : cluster.getNode()) {
+                            if (node.getId().equals(v)) {
+                                candidateList.add(node);
+                                found = true;
+                                break;
+                            }
+                        }
+                        if (!found) {
+                            throw new IllegalStateException("Unknonw nodeId : " + v);
+                        }
+                        found = false;
+                    }
 
-			}
-			String[] excluded = value.getRangeExcluded();
-			if (excluded != null && excluded.length > 0) {
-				List<Node> markedForRemoval = new ArrayList<Node>();
-				for (String exclusion : excluded) {
-					for (Node node : candidateList) {
-						if (node.getId().equals(exclusion)) {
-							markedForRemoval.add(node);
-						}
-					}
-				}
-				candidateList.removeAll(markedForRemoval);
-			}
-			break;
-		case RANDOM_MIN_MAX:
-			throw new IllegalStateException(
-					" Invalid value configured for location");
-		}
-		return candidateList;
-	}
+                }
+                String[] excluded = value.getRangeExcluded();
+                if (excluded != null && excluded.length > 0) {
+                    List<Node> markedForRemoval = new ArrayList<Node>();
+                    for (String exclusion : excluded) {
+                        for (Node node : candidateList) {
+                            if (node.getId().equals(exclusion)) {
+                                markedForRemoval.add(node);
+                            }
+                        }
+                    }
+                    candidateList.removeAll(markedForRemoval);
+                }
+                break;
+            case RANDOM_MIN_MAX:
+                throw new IllegalStateException(" Invalid value configured for location");
+        }
+        return candidateList;
+    }
 
-	private static Node getNodeFromId(String nodeid, Cluster cluster) {
-		if (nodeid.equals(EventDriver.CLIENT_NODE.getId())) {
-			return EventDriver.CLIENT_NODE;
-		}
+    private static Node getNodeFromId(String nodeid, Cluster cluster) {
+        if (nodeid.equals(EventDriver.CLIENT_NODE.getId())) {
+            return EventDriver.CLIENT_NODE;
+        }
 
-		if (nodeid.equals(cluster.getMasterNode().getId())) {
-			String ram = cluster.getMasterNode().getJavaHeap() == null ? cluster
-					.getJavaHeap() : cluster.getMasterNode().getJavaHeap();
-			String logDir = cluster.getMasterNode().getLogdir() == null ? cluster
-					.getLogdir() : cluster.getMasterNode().getLogdir();
-			String javaHome = cluster.getMasterNode().getJavaHome() == null ? cluster
-					.getJavaHome() : cluster.getMasterNode().getJavaHome();
-			BigInteger debug = cluster.getMasterNode().getDebug();
-			return new Node(cluster.getMasterNode().getId(), cluster
-					.getMasterNode().getIp(), ram, javaHome, logDir, null,
-					debug);
-		}
+        if (nodeid.equals(cluster.getMasterNode().getId())) {
+            String javaOpts = cluster.getMasterNode().getJavaOpts() == null ? cluster.getJavaOpts() : cluster
+                    .getMasterNode().getJavaOpts();
+            String logDir = cluster.getMasterNode().getLogdir() == null ? cluster.getLogdir() : cluster.getMasterNode()
+                    .getLogdir();
+            String javaHome = cluster.getMasterNode().getJavaHome() == null ? cluster.getJavaHome() : cluster
+                    .getMasterNode().getJavaHome();
+            BigInteger debug = cluster.getMasterNode().getDebug();
+            return new Node(cluster.getMasterNode().getId(), cluster.getMasterNode().getClusterIp(), javaHome,
+                    javaOpts, logDir, null, null, debug);
+        }
 
-		List<Node> nodeList = cluster.getNode();
-		for (Node node : nodeList) {
-			if (node.getId().equals(nodeid)) {
-				return node;
-			}
-		}
-		StringBuffer buffer = new StringBuffer();
-		buffer.append(EventDriver.CLIENT_NODE.getId() + ",");
-		buffer.append(cluster.getMasterNode().getId() + ",");
-		for (Node v : cluster.getNode()) {
-			buffer.append(v.getId() + ",");
-		}
-		buffer.deleteCharAt(buffer.length() - 1);
-		throw new IllegalArgumentException("Unknown node id :" + nodeid
-				+ " valid ids:" + buffer);
-	}
+        List<Node> nodeList = cluster.getNode();
+        for (Node node : nodeList) {
+            if (node.getId().equals(nodeid)) {
+                return node;
+            }
+        }
+        StringBuffer buffer = new StringBuffer();
+        buffer.append(EventDriver.CLIENT_NODE.getId() + ",");
+        buffer.append(cluster.getMasterNode().getId() + ",");
+        for (Node v : cluster.getNode()) {
+            buffer.append(v.getId() + ",");
+        }
+        buffer.deleteCharAt(buffer.length() - 1);
+        throw new IllegalArgumentException("Unknown node id :" + nodeid + " valid ids:" + buffer);
+    }
 
-	public static void executeEventScript(Node node, String script,
-			List<String> args, Cluster cluster) throws IOException,
-			InterruptedException {
-		List<String> pargs = new ArrayList<String>();
-		pargs.add("/bin/bash");
-		pargs.add(EventDriver.getEventsDir() + "/" + EXECUTE_SCRIPT);
-		StringBuffer argBuffer = new StringBuffer();
-		String env = EventDriver.getStringifiedEnv(cluster) + " " + IP_LOCATION
-				+ "=" + node.getIp();
-		if (args != null) {
-			for (String arg : args) {
-				argBuffer.append(arg + " ");
-			}
-		}
-		ProcessBuilder pb = new ProcessBuilder(pargs);
-		pb.environment().putAll(EventDriver.getEnvironment());
-		pb.environment().put(IP_LOCATION, node.getIp());
-		pb.environment().put(CLUSTER_ENV, env);
-		pb.environment().put(SCRIPT, script);
-		pb.environment().put(ARGS, argBuffer.toString());
-		pb.start();
-	}
+    public static void executeEventScript(Node node, String script, List<String> args, Cluster cluster)
+            throws IOException, InterruptedException {
+        List<String> pargs = new ArrayList<String>();
+        pargs.add("/bin/bash");
+        pargs.add(EventDriver.getEventsDir() + "/" + EXECUTE_SCRIPT);
+        StringBuffer argBuffer = new StringBuffer();
+        String env = EventDriver.getStringifiedEnv(cluster) + " " + IP_LOCATION + "=" + node.getClusterIp();
+        if (args != null) {
+            for (String arg : args) {
+                argBuffer.append(arg + " ");
+            }
+        }
+        ProcessBuilder pb = new ProcessBuilder(pargs);
+        pb.environment().putAll(EventDriver.getEnvironment());
+        pb.environment().put(IP_LOCATION, node.getClusterIp());
+        pb.environment().put(CLUSTER_ENV, env);
+        pb.environment().put(SCRIPT, script);
+        pb.environment().put(ARGS, argBuffer.toString());
+        pb.start();
+    }
 
-	public static void executeLocalScript(Node node, String script,
-			List<String> args) throws IOException, InterruptedException {
-		List<String> pargs = new ArrayList<String>();
-		pargs.add("/bin/bash");
-		pargs.add(script);
-		if (args != null) {
-			pargs.addAll(args);
-		}
-		ProcessBuilder pb = new ProcessBuilder(pargs);
-		pb.environment().putAll(EventDriver.getEnvironment());
-		pb.environment().put(IP_LOCATION, node.getIp());
-		pb.start();
-	}
+    public static void executeLocalScript(Node node, String script, List<String> args) throws IOException,
+            InterruptedException {
+        List<String> pargs = new ArrayList<String>();
+        pargs.add("/bin/bash");
+        pargs.add(script);
+        if (args != null) {
+            pargs.addAll(args);
+        }
+        ProcessBuilder pb = new ProcessBuilder(pargs);
+        pb.environment().putAll(EventDriver.getEnvironment());
+        pb.environment().put(IP_LOCATION, node.getClusterIp());
+        pb.start();
+    }
 
-	public static List<String> getEventArgs(Pattern pattern) {
-		List<String> pargs = new ArrayList<String>();
-		if (pattern.getEvent().getPargs() == null) {
-			return pargs;
-		}
-		String[] args = pattern.getEvent().getPargs().split(" ");
-		for (String arg : args) {
-			pargs.add(arg.trim());
-		}
-		return pargs;
-	}
+    public static List<String> getEventArgs(Pattern pattern) {
+        List<String> pargs = new ArrayList<String>();
+        if (pattern.getEvent().getPargs() == null) {
+            return pargs;
+        }
+        String[] args = pattern.getEvent().getPargs().split(" ");
+        for (String arg : args) {
+            pargs.add(arg.trim());
+        }
+        return pargs;
+    }
 
 }
diff --git a/asterix-events/src/main/java/edu/uci/ics/asterix/event/management/EventrixClient.java b/asterix-events/src/main/java/edu/uci/ics/asterix/event/management/EventrixClient.java
index 4cd4b82..52d46c8 100644
--- a/asterix-events/src/main/java/edu/uci/ics/asterix/event/management/EventrixClient.java
+++ b/asterix-events/src/main/java/edu/uci/ics/asterix/event/management/EventrixClient.java
@@ -38,166 +38,159 @@
 
 public class EventrixClient {
 
-	private static final Logger LOGGER = Logger.getLogger(EventrixClient.class
-			.getName());
+    private static final Logger LOGGER = Logger.getLogger(EventrixClient.class.getName());
 
-	private EventTask[] tasks;
-	private boolean dryRun = false;
-	private LinkedBlockingQueue<EventTaskReport> msgInbox = new LinkedBlockingQueue<EventTaskReport>();
-	private AtomicInteger pendingTasks = new AtomicInteger(0);
-	private final Cluster cluster;
-	private IPatternListener listener;
-	private IOutputHandler outputHandler;
-	private Events events;
-	private String eventsDir;
+    private EventTask[] tasks;
+    private boolean dryRun = false;
+    private LinkedBlockingQueue<EventTaskReport> msgInbox = new LinkedBlockingQueue<EventTaskReport>();
+    private AtomicInteger pendingTasks = new AtomicInteger(0);
+    private final Cluster cluster;
+    private IPatternListener listener;
+    private IOutputHandler outputHandler;
+    private Events events;
+    private String eventsDir;
 
-	public EventrixClient(String eventsDir, Cluster cluster, boolean dryRun,
-			IOutputHandler outputHandler) throws Exception {
-		this.eventsDir = eventsDir;
-		this.events = initializeEvents();
-		this.cluster = cluster;
-		this.dryRun = dryRun;
-		this.outputHandler = outputHandler;
-		if (!dryRun) {
-			initializeCluster(eventsDir);
-		}
-	}
+    public EventrixClient(String eventsDir, Cluster cluster, boolean dryRun, IOutputHandler outputHandler)
+            throws Exception {
+        this.eventsDir = eventsDir;
+        this.events = initializeEvents();
+        this.cluster = cluster;
+        this.dryRun = dryRun;
+        this.outputHandler = outputHandler;
+        if (!dryRun) {
+            initializeCluster(eventsDir);
+        }
+    }
 
-	public void submit(Patterns patterns) throws Exception {
-		initTasks(patterns);
-		try {
-			waitForCompletion();
-		} catch (InterruptedException ie) {
-			LOGGER.info("Interrupted exception :" + ie);
-		} catch (Exception e) {
-			throw e;
-		}
+    public void submit(Patterns patterns) throws Exception {
+        initTasks(patterns);
+        try {
+            waitForCompletion();
+        } catch (InterruptedException ie) {
+            LOGGER.info("Interrupted exception :" + ie);
+        } catch (Exception e) {
+            throw e;
+        }
 
-	}
+    }
 
-	public void submit(Patterns patterns, IPatternListener listener)
-			throws Exception {
-		this.listener = listener;
-		initTasks(patterns);
-	}
+    public void submit(Patterns patterns, IPatternListener listener) throws Exception {
+        this.listener = listener;
+        initTasks(patterns);
+    }
 
-	private void initTasks(Patterns patterns) {
-		tasks = new EventTask[patterns.getPattern().size()];
-		pendingTasks.set(tasks.length);
-		int index = 0;
-		for (Pattern pattern : patterns.getPattern()) {
-			tasks[index] = new EventTask(pattern, this);
-			tasks[index].start();
-			index++;
-		}
-	}
+    private void initTasks(Patterns patterns) {
+        tasks = new EventTask[patterns.getPattern().size()];
+        pendingTasks.set(tasks.length);
+        int index = 0;
+        for (Pattern pattern : patterns.getPattern()) {
+            tasks[index] = new EventTask(pattern, this);
+            tasks[index].start();
+            index++;
+        }
+    }
 
-	public Cluster getCluster() {
-		return cluster;
-	}
+    public Cluster getCluster() {
+        return cluster;
+    }
 
-	public boolean isDryRun() {
-		return dryRun;
-	}
+    public boolean isDryRun() {
+        return dryRun;
+    }
 
-	public Events getEvents() {
-		return events;
-	}
+    public Events getEvents() {
+        return events;
+    }
 
-	public String getEventsDir() {
-		return eventsDir;
-	}
+    public String getEventsDir() {
+        return eventsDir;
+    }
 
-	public synchronized void notifyCompletion(EventTaskReport report) {
+    public synchronized void notifyCompletion(EventTaskReport report) {
 
-		if (report.isSuccess()) {
-			if (listener != null) {
-				pendingTasks.decrementAndGet();
-				listener.eventCompleted(report);
-				if (pendingTasks.get() == 0) {
-					listener.jobCompleted();
-				}
-			} else {
-				try {
-					msgInbox.put(report);
-				} catch (InterruptedException e) {
-				}
-			}
-		} else {
-			for (EventTask t : tasks) {
-				if (t.getState() == EventTask.State.INITIALIZED
-						|| t.getState() == EventTask.State.IN_PROGRESS) {
-					t.cancel();
-				}
-			}
-			if (listener != null) {
-				listener.jobFailed(report);
-			} else {
-				try {
-					msgInbox.put(report);
-				} catch (InterruptedException e) {
-				}
-			}
-		}
-	}
+        if (report.isSuccess()) {
+            if (listener != null) {
+                pendingTasks.decrementAndGet();
+                listener.eventCompleted(report);
+                if (pendingTasks.get() == 0) {
+                    listener.jobCompleted();
+                }
+            } else {
+                try {
+                    msgInbox.put(report);
+                } catch (InterruptedException e) {
+                }
+            }
+        } else {
+            for (EventTask t : tasks) {
+                if (t.getState() == EventTask.State.INITIALIZED || t.getState() == EventTask.State.IN_PROGRESS) {
+                    t.cancel();
+                }
+            }
+            if (listener != null) {
+                listener.jobFailed(report);
+            } else {
+                try {
+                    msgInbox.put(report);
+                } catch (InterruptedException e) {
+                }
+            }
+        }
+    }
 
-	private void waitForCompletion() throws Exception {
-		while (true) {
-			EventTaskReport report = msgInbox.take();
-			if (report.isSuccess()) {
-				if (pendingTasks.decrementAndGet() == 0) {
-					break;
-				}
-			} else {
-				throw new RuntimeException(report.getException().getMessage());
-			}
-		}
-	}
+    private void waitForCompletion() throws Exception {
+        while (true) {
+            EventTaskReport report = msgInbox.take();
+            if (report.isSuccess()) {
+                if (pendingTasks.decrementAndGet() == 0) {
+                    break;
+                }
+            } else {
+                throw new RuntimeException(report.getException().getMessage());
+            }
+        }
+    }
 
-	private void initializeCluster(String eventsDir) throws Exception {
-		Patterns patterns = initPattern(eventsDir);
-		submit(patterns);
-	}
+    private void initializeCluster(String eventsDir) throws Exception {
+        Patterns patterns = initPattern(eventsDir);
+        submit(patterns);
+    }
 
-	private Patterns initPattern(String eventsDir) {
-		Nodeid nodeid = new Nodeid(new Value(null,
-				EventDriver.CLIENT_NODE.getId()));
-		List<Pattern> patternList = new ArrayList<Pattern>();
-		String workingDir = cluster.getWorkingDir().getDir();
-		String username = cluster.getUsername() == null ? System
-				.getProperty("user.name") : cluster.getUsername();
-		patternList.add(getDirectoryTransferPattern(username, eventsDir,
-				nodeid, cluster.getMasterNode().getIp(), workingDir));
+    private Patterns initPattern(String eventsDir) {
+        Nodeid nodeid = new Nodeid(new Value(null, EventDriver.CLIENT_NODE.getId()));
+        List<Pattern> patternList = new ArrayList<Pattern>();
+        String workingDir = cluster.getWorkingDir().getDir();
+        String username = cluster.getUsername() == null ? System.getProperty("user.name") : cluster.getUsername();
+        patternList.add(getDirectoryTransferPattern(username, eventsDir, nodeid,
+                cluster.getMasterNode().getClusterIp(), workingDir));
 
-		if (!cluster.getWorkingDir().isNFS()) {
-			for (Node node : cluster.getNode()) {
-				patternList.add(getDirectoryTransferPattern(username,
-						eventsDir, nodeid, node.getIp(), workingDir));
-			}
-		}
-		Patterns patterns = new Patterns(patternList);
-		return patterns;
-	}
+        if (!cluster.getWorkingDir().isNFS()) {
+            for (Node node : cluster.getNode()) {
+                patternList.add(getDirectoryTransferPattern(username, eventsDir, nodeid, node.getClusterIp(),
+                        workingDir));
+            }
+        }
+        Patterns patterns = new Patterns(patternList);
+        return patterns;
+    }
 
-	private Pattern getDirectoryTransferPattern(String username, String src,
-			Nodeid srcNode, String destNodeIp, String destDir) {
-		String pargs = username + " " + src + " " + destNodeIp + " " + destDir;
-		Event event = new Event("directory_transfer", srcNode, pargs);
-		return new Pattern(null, 1, null, event);
-	}
+    private Pattern getDirectoryTransferPattern(String username, String src, Nodeid srcNode, String destNodeIp,
+            String destDir) {
+        String pargs = username + " " + src + " " + destNodeIp + " " + destDir;
+        Event event = new Event("directory_transfer", srcNode, pargs);
+        return new Pattern(null, 1, null, event);
+    }
 
-	public IOutputHandler getErrorHandler() {
-		return outputHandler;
-	}
+    public IOutputHandler getErrorHandler() {
+        return outputHandler;
+    }
 
-	private Events initializeEvents() throws JAXBException,
-			FileNotFoundException {
-		File file = new File(eventsDir + File.separator + "events"
-				+ File.separator + "events.xml");
-		JAXBContext eventCtx = JAXBContext.newInstance(Events.class);
-		Unmarshaller unmarshaller = eventCtx.createUnmarshaller();
-		events = (Events) unmarshaller.unmarshal(file);
-		return events;
-	}
+    private Events initializeEvents() throws JAXBException, FileNotFoundException {
+        File file = new File(eventsDir + File.separator + "events" + File.separator + "events.xml");
+        JAXBContext eventCtx = JAXBContext.newInstance(Events.class);
+        Unmarshaller unmarshaller = eventCtx.createUnmarshaller();
+        events = (Events) unmarshaller.unmarshal(file);
+        return events;
+    }
 
 }
diff --git a/asterix-events/src/main/resources/events/node_join/nc_join.sh b/asterix-events/src/main/resources/events/node_join/nc_join.sh
index 5aa86db..6b5280b 100755
--- a/asterix-events/src/main/resources/events/node_join/nc_join.sh
+++ b/asterix-events/src/main/resources/events/node_join/nc_join.sh
@@ -1,7 +1,8 @@
 CC_HOST=$1
 NC_ID=$2
+IO_DEVICES=$3
 if [ ! -d $LOG_DIR ]; 
 then 
   mkdir -p $LOG_DIR
 fi
-$ASTERIX_HOME/bin/asterixnc -node-id $NC_ID -cc-host $CC_HOST -cc-port 1099 -cluster-net-ip-address $IP_LOCATION  -data-ip-address $IP_LOCATION -result-ip-address $IP_LOCATION &> $LOG_DIR/${NC_ID}.log
+$ASTERIX_HOME/bin/asterixnc -node-id $NC_ID -cc-host $CC_HOST -cc-port 1099 -cluster-net-ip-address $IP_LOCATION  -data-ip-address $IP_LOCATION -iodevices $IO_DEVICES -result-ip-address $IP_LOCATION &> $LOG_DIR/${NC_ID}.log
diff --git a/asterix-events/src/main/resources/schema/cluster.xsd b/asterix-events/src/main/resources/schema/cluster.xsd
index 38afda3..0e1adce 100644
--- a/asterix-events/src/main/resources/schema/cluster.xsd
+++ b/asterix-events/src/main/resources/schema/cluster.xsd
@@ -3,19 +3,21 @@
 
 <!-- definition of simple types --> 
 <xs:element name="name" type="xs:string"/>
-<xs:element name="java_heap" type="xs:string"/>
+<xs:element name="java_opts" type="xs:string"/>
 <xs:element name="logdir" type="xs:string"/>
 <xs:element name="id" type="xs:string"/>
-<xs:element name="ip" type="xs:string"/>
+<xs:element name="client-ip" type="xs:string"/>
 <xs:element name="cluster-ip" type="xs:string"/>
 <xs:element name="key" type="xs:string"/>
 <xs:element name="value" type="xs:string"/>
 <xs:element name="dir" type="xs:string"/>
 <xs:element name="NFS" type="xs:boolean"/>
 <xs:element name="store" type="xs:string"/>
+<xs:element name="iodevices" type="xs:string"/>
 <xs:element name="java_home" type="xs:string"/>
 <xs:element name="username" type="xs:string"/>
 <xs:element name="debug" type="xs:integer"/>
+<xs:element name="debugEnabled" type="xs:boolean"/>
 
 <!-- definition of complex elements -->
 <xs:element name="workingDir">
@@ -31,10 +33,10 @@
   <xs:complexType>
     <xs:sequence>
       <xs:element ref="cl:id"/>
-      <xs:element ref="cl:ip"/>
+      <xs:element ref="cl:client-ip"/>
       <xs:element ref="cl:cluster-ip"/>
       <xs:element ref="cl:java_home" minOccurs="0"/>
-      <xs:element ref="cl:java_heap" minOccurs="0"/>
+      <xs:element ref="cl:java_opts" minOccurs="0"/>
       <xs:element ref="cl:logdir" minOccurs="0"/>
       <xs:element ref="cl:debug" minOccurs="0"/>
     </xs:sequence>
@@ -62,11 +64,12 @@
   <xs:complexType>
     <xs:sequence>
       <xs:element ref="cl:id"/>
-      <xs:element ref="cl:ip"/>
-      <xs:element ref="cl:java_heap" minOccurs="0"/>
+      <xs:element ref="cl:cluster-ip"/>
       <xs:element ref="cl:java_home" minOccurs="0"/>
+      <xs:element ref="cl:java_opts" minOccurs="0"/>
       <xs:element ref="cl:logdir" minOccurs="0"/>
       <xs:element ref="cl:store" minOccurs="0"/>
+      <xs:element ref="cl:iodevices" minOccurs="0"/>
       <xs:element ref="cl:debug" minOccurs="0"/>
     </xs:sequence>
   </xs:complexType>
@@ -78,11 +81,14 @@
       <xs:element ref="cl:name"/>
       <xs:element ref="cl:username"/>
       <xs:element ref="cl:env" minOccurs="0"/>
-      <xs:element ref="cl:java_heap" minOccurs="0"/>
       <xs:element ref="cl:java_home" minOccurs="0"/>
+      <xs:element ref="cl:java_opts" minOccurs="0"/>
       <xs:element ref="cl:logdir" minOccurs="0"/>
       <xs:element ref="cl:store" minOccurs="0"/>
+      <xs:element ref="cl:iodevices" minOccurs="0"/>
       <xs:element ref="cl:workingDir"/>
+      <xs:element ref="cl:debugEnabled" minOccurs="0"/>
+      <xs:element ref="cl:debug" minOccurs="0"/>
       <xs:element ref="cl:master-node"/>
       <xs:element ref="cl:node" maxOccurs="unbounded"/>
     </xs:sequence>
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/AbstractCommand.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/AbstractCommand.java
index af7dbb7..66a0697 100644
--- a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/AbstractCommand.java
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/AbstractCommand.java
@@ -28,14 +28,10 @@
     public void execute(String[] args) throws Exception {
         String[] cmdArgs = new String[args.length - 1];
         System.arraycopy(args, 1, cmdArgs, 0, cmdArgs.length);
-        if (cmdArgs.length >= 1 && cmdArgs[0].equals("-help")) {
-            System.out.println(getUsageDescription());
-        } else {
-            config = getCommandConfig();
-            CmdLineParser parser = new CmdLineParser(config);
-            parser.parseArgument(cmdArgs);
-            execCommand();
-        }
+        config = getCommandConfig();
+        CmdLineParser parser = new CmdLineParser(config);
+        parser.parseArgument(cmdArgs);
+        execCommand();
     }
 
     abstract protected void execCommand() throws Exception;
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/AbstractCommandConfig.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/AbstractCommandConfig.java
deleted file mode 100644
index f28dfd9..0000000
--- a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/AbstractCommandConfig.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package edu.uci.ics.asterix.installer.command;
-
-import org.kohsuke.args4j.Option;
-
-public class AbstractCommandConfig implements CommandConfig {
-
-    @Option(name = "-help", required = false, usage = "Help")
-    public boolean help = false;
-
-    @Override
-    public boolean helpMode() {
-        return help;
-    }
-
-}
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/AlterCommand.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/AlterCommand.java
index e52308e..5ef7449 100644
--- a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/AlterCommand.java
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/AlterCommand.java
@@ -52,14 +52,13 @@
     protected String getUsageDescription() {
         return "\nAlter the instance's configuration settings."
                 + "\nPrior to running this command, the instance is required to be INACTIVE state."
-                + "\n\nAvailable arguments/options" 
-                + "\n-n name of the ASTERIX instance"
+                + "\n\nAvailable arguments/options" + "\n-n name of the ASTERIX instance"
                 + "\n-conf path to the ASTERIX configuration file.";
     }
 
 }
 
-class AlterConfig extends AbstractCommandConfig {
+class AlterConfig extends CommandConfig {
 
     @Option(name = "-n", required = true, usage = "Name of Asterix Instance")
     public String name;
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/BackupCommand.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/BackupCommand.java
index cd4cc5c..603862c 100644
--- a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/BackupCommand.java
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/BackupCommand.java
@@ -59,15 +59,14 @@
                 + "\nfailure or accidental execution of a DDL statement (drop dataverse/dataset),"
                 + "\nyou may need to recover the lost data. The backup command allows you to take a"
                 + "\nbackup of the data stored with an ASTERIX instance. "
-                + "\nThe backed up snapshot is stored in HDFS." 
-                + "\n\nAvailable arguments/options:"
+                + "\nThe backed up snapshot is stored in HDFS." + "\n\nAvailable arguments/options:"
                 + "\n-n name of the Asterix instance";
 
     }
 
 }
 
-class BackupConfig extends AbstractCommandConfig {
+class BackupConfig extends CommandConfig {
 
     @Option(name = "-n", required = true, usage = "Name of the Asterix instance")
     public String name;
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/CommandConfig.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/CommandConfig.java
index 94aa935..55b0c3b 100644
--- a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/CommandConfig.java
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/CommandConfig.java
@@ -1,20 +1,5 @@
-/*
- * Copyright 2009-2012 by The Regents of the University of California
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * you may obtain a copy of the License from
- * 
- *     http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
 package edu.uci.ics.asterix.installer.command;
 
-public interface CommandConfig {
+public abstract class CommandConfig {
 
-    public boolean helpMode();
 }
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/CommandHandler.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/CommandHandler.java
index 8a9347a..7fc3884 100644
--- a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/CommandHandler.java
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/CommandHandler.java
@@ -55,6 +55,9 @@
             case SHUTDOWN:
                 cmd = new ShutdownCommand();
                 break;
+            case HELP:
+                cmd = new HelpCommand();
+                break;
         }
         cmd.execute(args);
     }
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/ConfigureCommand.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/ConfigureCommand.java
index 6b0b53d..cad8632 100644
--- a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/ConfigureCommand.java
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/ConfigureCommand.java
@@ -26,9 +26,11 @@
         String workingDir = InstallerDriver.getManagixHome() + File.separator + "clusters" + File.separator + "local"
                 + File.separator + "working_dir";
         cluster.setWorkingDir(new WorkingDir(workingDir, true));
-        cluster.setStore(workingDir + File.separator + "storage");
+        cluster.setIodevices(workingDir);
+        cluster.setStore("storage");
         cluster.setLogdir(workingDir + File.separator + "logs");
         cluster.setJavaHome(System.getenv("JAVA_HOME"));
+        cluster.setJavaOpts("-Xmx1048m");
 
         Marshaller marshaller = ctx.createMarshaller();
         marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
@@ -50,7 +52,7 @@
     @Override
     protected String getUsageDescription() {
         return "\nAuto-generates the ASTERIX installer configruation settings and ASTERIX cluster "
-                + "\n configuration settings for a single node setup.";
+                + "\nconfiguration settings for a single node setup.";
     }
 
     @Override
@@ -60,6 +62,6 @@
 
 }
 
-class ConfigureConfig extends AbstractCommandConfig {
+class ConfigureConfig extends CommandConfig {
 
 }
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/CreateCommand.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/CreateCommand.java
index 5ddc9e9..af472da 100644
--- a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/CreateCommand.java
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/CreateCommand.java
@@ -38,97 +38,85 @@
 
 public class CreateCommand extends AbstractCommand {
 
-	private String asterixInstanceName;
-	private Cluster cluster;
+    private String asterixInstanceName;
+    private Cluster cluster;
 
-	@Override
-	protected void execCommand() throws Exception {
-		InstallerDriver.initConfig();
-		ValidateCommand validateCommand = new ValidateCommand();
-		boolean valid = validateCommand
-				.validateCluster(((CreateConfig) config).clusterPath);
-		if (!valid) {
-			throw new Exception("Cannot create an Asterix instance.");
-		}
-		asterixInstanceName = ((CreateConfig) config).name;
-		InstallerUtil.validateAsterixInstanceNotExists(asterixInstanceName);
-		CreateConfig createConfig = (CreateConfig) config;
-		JAXBContext ctx = JAXBContext.newInstance(Cluster.class);
-		Unmarshaller unmarshaller = ctx.createUnmarshaller();
-		cluster = (Cluster) unmarshaller.unmarshal(new File(
-				createConfig.clusterPath));
-		cluster.setWorkingDir(new WorkingDir(cluster.getWorkingDir().getDir()
-				+ File.separator + asterixInstanceName, cluster.getWorkingDir()
-				.isNFS()));
-		cluster.setLogdir(cluster.getLogdir() + File.separator
-				+ asterixInstanceName);
-		AsterixInstance asterixInstance = InstallerUtil.createAsterixInstance(
-				asterixInstanceName, cluster);
-		InstallerUtil.evaluateConflictWithOtherInstances(asterixInstance);
-		InstallerUtil.createAsterixZip(asterixInstance, true);
-		List<Property> clusterProperties = new ArrayList<Property>();
-		clusterProperties.add(new Property("ASTERIX_HOME", cluster
-				.getWorkingDir().getDir() + File.separator + "asterix"));
-		clusterProperties.add(new Property("JAVA_OPTS", "-Xmx"
-				+ cluster.getJavaHeap()));
-		clusterProperties.add(new Property("CLUSTER_NET_IP", cluster
-				.getMasterNode().getClusterIp()));
-		clusterProperties.add(new Property("CLIENT_NET_IP", cluster
-				.getMasterNode().getIp()));
-		clusterProperties.add(new Property("LOG_DIR", cluster.getLogdir()));
-		clusterProperties.add(new Property("JAVA_HOME", cluster.getJavaHome()));
-		clusterProperties.add(new Property("WORKING_DIR", cluster
-				.getWorkingDir().getDir()));
-		cluster.setEnv(new Env(clusterProperties));
+    @Override
+    protected void execCommand() throws Exception {
+        InstallerDriver.initConfig();
+        ValidateCommand validateCommand = new ValidateCommand();
+        boolean valid = validateCommand.validateCluster(((CreateConfig) config).clusterPath);
+        if (!valid) {
+            throw new Exception("Cannot create an Asterix instance.");
+        }
+        asterixInstanceName = ((CreateConfig) config).name;
+        InstallerUtil.validateAsterixInstanceNotExists(asterixInstanceName);
+        CreateConfig createConfig = (CreateConfig) config;
+        JAXBContext ctx = JAXBContext.newInstance(Cluster.class);
+        Unmarshaller unmarshaller = ctx.createUnmarshaller();
+        cluster = (Cluster) unmarshaller.unmarshal(new File(createConfig.clusterPath));
+        cluster.setWorkingDir(new WorkingDir(cluster.getWorkingDir().getDir() + File.separator + asterixInstanceName,
+                cluster.getWorkingDir().isNFS()));
+        cluster.setLogdir(cluster.getLogdir() + File.separator + asterixInstanceName);
+        AsterixInstance asterixInstance = InstallerUtil.createAsterixInstance(asterixInstanceName, cluster);
+        InstallerUtil.evaluateConflictWithOtherInstances(asterixInstance);
+        InstallerUtil.createAsterixZip(asterixInstance, true);
+        List<Property> clusterProperties = new ArrayList<Property>();
+        clusterProperties.add(new Property("ASTERIX_HOME", cluster.getWorkingDir().getDir() + File.separator
+                + "asterix"));
+        StringBuilder javaOpts = new StringBuilder();
+        if (cluster.getJavaOpts() != null) {
+            javaOpts.append(cluster.getJavaOpts());
+        }
+        clusterProperties.add(new Property("JAVA_OPTS", javaOpts.toString()));
+        clusterProperties.add(new Property("CLUSTER_NET_IP", cluster.getMasterNode().getClusterIp()));
+        clusterProperties.add(new Property("CLIENT_NET_IP", cluster.getMasterNode().getClusterIp()));
+        clusterProperties.add(new Property("LOG_DIR", cluster.getLogdir()));
+        clusterProperties.add(new Property("JAVA_HOME", cluster.getJavaHome()));
+        clusterProperties.add(new Property("WORKING_DIR", cluster.getWorkingDir().getDir()));
+        cluster.setEnv(new Env(clusterProperties));
 
-		PatternCreator pc = new PatternCreator();
-		Patterns patterns = pc.getStartAsterixPattern(asterixInstanceName,
-				cluster);
-		InstallerUtil.getEventrixClient(cluster).submit(patterns);
+        PatternCreator pc = new PatternCreator();
+        Patterns patterns = pc.getStartAsterixPattern(asterixInstanceName, cluster);
+        InstallerUtil.getEventrixClient(cluster).submit(patterns);
 
-		AsterixRuntimeState runtimeState = VerificationUtil
-				.getAsterixRuntimeState(asterixInstance);
-		VerificationUtil.updateInstanceWithRuntimeDescription(asterixInstance,
-				runtimeState, true);
-		ServiceProvider.INSTANCE.getLookupService().writeAsterixInstance(
-				asterixInstance);
-		InstallerUtil.deleteDirectory(InstallerDriver.getManagixHome()
-				+ File.separator + InstallerDriver.ASTERIX_DIR + File.separator
-				+ asterixInstanceName);
-		LOGGER.info(asterixInstance.getDescription(false));
-	}
+        AsterixRuntimeState runtimeState = VerificationUtil.getAsterixRuntimeState(asterixInstance);
+        VerificationUtil.updateInstanceWithRuntimeDescription(asterixInstance, runtimeState, true);
+        ServiceProvider.INSTANCE.getLookupService().writeAsterixInstance(asterixInstance);
+        InstallerUtil.deleteDirectory(InstallerDriver.getManagixHome() + File.separator + InstallerDriver.ASTERIX_DIR
+                + File.separator + asterixInstanceName);
+        LOGGER.info(asterixInstance.getDescription(false));
+    }
 
-	@Override
-	protected CommandConfig getCommandConfig() {
-		return new CreateConfig();
-	}
+    @Override
+    protected CommandConfig getCommandConfig() {
+        return new CreateConfig();
+    }
 
-	public Cluster getCluster() {
-		return cluster;
-	}
+    public Cluster getCluster() {
+        return cluster;
+    }
 
-	public String getAsterixInstanceName() {
-		return asterixInstanceName;
-	}
+    public String getAsterixInstanceName() {
+        return asterixInstanceName;
+    }
 
-	@Override
-	protected String getUsageDescription() {
-		return "\nCreates an ASTERIX instance with a specified name."
-				+ "\n\nPost creation, the instance is in ACTIVE state, indicating its "
-				+ "\navailability for executing statements/queries."
-				+ "\n\nUsage arguments/options:"
-				+ "\n-n Name of the ASTERIX instance."
-				+ "\n-c Path to the cluster configuration file";
-	}
+    @Override
+    protected String getUsageDescription() {
+        return "\nCreates an ASTERIX instance with a specified name."
+                + "\n\nPost creation, the instance is in ACTIVE state, indicating its "
+                + "\navailability for executing statements/queries." + "\n\nUsage arguments/options:"
+                + "\n-n Name of the ASTERIX instance." + "\n-c Path to the cluster configuration file";
+    }
 
 }
 
-class CreateConfig extends AbstractCommandConfig {
+class CreateConfig extends CommandConfig {
 
-	@Option(name = "-n", required = true, usage = "Name of Asterix Instance")
-	public String name;
+    @Option(name = "-n", required = true, usage = "Name of Asterix Instance")
+    public String name;
 
-	@Option(name = "-c", required = true, usage = "Path to cluster configuration")
-	public String clusterPath;
+    @Option(name = "-c", required = true, usage = "Path to cluster configuration")
+    public String clusterPath;
 
 }
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/DeleteCommand.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/DeleteCommand.java
index a2788b4..2279d8f 100644
--- a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/DeleteCommand.java
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/DeleteCommand.java
@@ -26,41 +26,37 @@
 
 public class DeleteCommand extends AbstractCommand {
 
-	@Override
-	protected void execCommand() throws Exception {
-		InstallerDriver.initConfig();
-		String asterixInstanceName = ((DeleteConfig) config).name;
-		AsterixInstance instance = InstallerUtil.validateAsterixInstanceExists(
-				asterixInstanceName, State.INACTIVE);
-		PatternCreator pc = new PatternCreator();
-		Patterns patterns = pc.createDeleteInstancePattern(instance);
-		InstallerUtil.getEventrixClient(instance.getCluster()).submit(patterns);
+    @Override
+    protected void execCommand() throws Exception {
+        InstallerDriver.initConfig();
+        String asterixInstanceName = ((DeleteConfig) config).name;
+        AsterixInstance instance = InstallerUtil.validateAsterixInstanceExists(asterixInstanceName, State.INACTIVE);
+        PatternCreator pc = new PatternCreator();
+        Patterns patterns = pc.createDeleteInstancePattern(instance);
+        InstallerUtil.getEventrixClient(instance.getCluster()).submit(patterns);
 
-		patterns = pc.createRemoveAsterixWorkingDirPattern(instance);
-		InstallerUtil.getEventrixClient(instance.getCluster()).submit(patterns);
-		ServiceProvider.INSTANCE.getLookupService().removeAsterixInstance(
-				asterixInstanceName);
-		LOGGER.info("Deleted Asterix instance: " + asterixInstanceName);
-	}
+        patterns = pc.createRemoveAsterixWorkingDirPattern(instance);
+        InstallerUtil.getEventrixClient(instance.getCluster()).submit(patterns);
+        ServiceProvider.INSTANCE.getLookupService().removeAsterixInstance(asterixInstanceName);
+        LOGGER.info("Deleted Asterix instance: " + asterixInstanceName);
+    }
 
-	@Override
-	protected CommandConfig getCommandConfig() {
-		return new DeleteConfig();
-	}
+    @Override
+    protected CommandConfig getCommandConfig() {
+        return new DeleteConfig();
+    }
 
-	@Override
-	protected String getUsageDescription() {
-		return "\nPermanently deletes an ASTERIX instance." + "\n"
-				+ "The instance must be in the INACTIVE state."
-				+ "\n\nAvailable arguments/options"
-				+ "\n-n name of the ASTERIX instance.";
-	}
+    @Override
+    protected String getUsageDescription() {
+        return "\nPermanently deletes an ASTERIX instance." + "\n" + "The instance must be in the INACTIVE state."
+                + "\n\nAvailable arguments/options" + "\n-n name of the ASTERIX instance.";
+    }
 
 }
 
-class DeleteConfig extends AbstractCommandConfig {
+class DeleteConfig extends CommandConfig {
 
-	@Option(name = "-n", required = true, usage = "Name of Asterix Instance")
-	public String name;
+    @Option(name = "-n", required = true, usage = "Name of Asterix Instance")
+    public String name;
 
 }
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/DescribeCommand.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/DescribeCommand.java
index bec82d5..9306a56 100644
--- a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/DescribeCommand.java
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/DescribeCommand.java
@@ -29,77 +29,63 @@
 
 public class DescribeCommand extends AbstractCommand {
 
-	@Override
-	protected void execCommand() throws Exception {
-		InstallerDriver.initConfig();
-		String asterixInstanceName = ((DescribeConfig) config).name;
-		boolean adminView = ((DescribeConfig) config).admin;
-		if (asterixInstanceName != null) {
-			InstallerUtil.validateAsterixInstanceExists(asterixInstanceName,
-					State.INACTIVE, State.ACTIVE, State.UNUSABLE);
-			AsterixInstance instance = ServiceProvider.INSTANCE
-					.getLookupService().getAsterixInstance(asterixInstanceName);
-			if (instance != null) {
-				AsterixRuntimeState state = VerificationUtil
-						.getAsterixRuntimeState(instance);
-				boolean expectedRunning = instance.getState().equals(
-						State.UNUSABLE) ? instance.getPreviousState().equals(
-						State.ACTIVE) : !instance.getState().equals(
-						State.INACTIVE);
-				VerificationUtil.updateInstanceWithRuntimeDescription(instance,
-						state, expectedRunning);
-				ServiceProvider.INSTANCE.getLookupService()
-						.updateAsterixInstance(instance);
-				LOGGER.info(instance.getDescription(adminView));
-			} else {
-				throw new InstallerException("Asterix instance by the name "
-						+ asterixInstanceName + " does not exist.");
-			}
-		} else {
-			List<AsterixInstance> asterixInstances = ServiceProvider.INSTANCE
-					.getLookupService().getAsterixInstances();
-			if (asterixInstances.size() > 0) {
-				for (AsterixInstance instance : asterixInstances) {
-					AsterixRuntimeState state = VerificationUtil
-							.getAsterixRuntimeState(instance);
-					boolean expectedRunning = instance.getState().equals(
-							State.UNUSABLE) ? instance.getPreviousState()
-							.equals(State.ACTIVE) : !instance.getState()
-							.equals(State.INACTIVE);
-					VerificationUtil.updateInstanceWithRuntimeDescription(
-							instance, state, expectedRunning);
-					ServiceProvider.INSTANCE.getLookupService()
-							.updateAsterixInstance(instance);
-					LOGGER.info(instance.getDescription(adminView));
-				}
-			} else {
-				LOGGER.info("No Asterix instances found!");
-			}
+    @Override
+    protected void execCommand() throws Exception {
+        InstallerDriver.initConfig();
+        String asterixInstanceName = ((DescribeConfig) config).name;
+        boolean adminView = ((DescribeConfig) config).admin;
+        if (asterixInstanceName != null) {
+            InstallerUtil.validateAsterixInstanceExists(asterixInstanceName, State.INACTIVE, State.ACTIVE,
+                    State.UNUSABLE);
+            AsterixInstance instance = ServiceProvider.INSTANCE.getLookupService().getAsterixInstance(
+                    asterixInstanceName);
+            if (instance != null) {
+                AsterixRuntimeState state = VerificationUtil.getAsterixRuntimeState(instance);
+                boolean expectedRunning = instance.getState().equals(State.UNUSABLE) ? instance.getPreviousState()
+                        .equals(State.ACTIVE) : !instance.getState().equals(State.INACTIVE);
+                VerificationUtil.updateInstanceWithRuntimeDescription(instance, state, expectedRunning);
+                ServiceProvider.INSTANCE.getLookupService().updateAsterixInstance(instance);
+                LOGGER.info(instance.getDescription(adminView));
+            } else {
+                throw new InstallerException("Asterix instance by the name " + asterixInstanceName + " does not exist.");
+            }
+        } else {
+            List<AsterixInstance> asterixInstances = ServiceProvider.INSTANCE.getLookupService().getAsterixInstances();
+            if (asterixInstances.size() > 0) {
+                for (AsterixInstance instance : asterixInstances) {
+                    AsterixRuntimeState state = VerificationUtil.getAsterixRuntimeState(instance);
+                    boolean expectedRunning = instance.getState().equals(State.UNUSABLE) ? instance.getPreviousState()
+                            .equals(State.ACTIVE) : !instance.getState().equals(State.INACTIVE);
+                    VerificationUtil.updateInstanceWithRuntimeDescription(instance, state, expectedRunning);
+                    ServiceProvider.INSTANCE.getLookupService().updateAsterixInstance(instance);
+                    LOGGER.info(instance.getDescription(adminView));
+                }
+            } else {
+                LOGGER.info("No Asterix instances found!");
+            }
 
-		}
-	}
+        }
+    }
 
-	@Override
-	protected CommandConfig getCommandConfig() {
-		return new DescribeConfig();
-	}
+    @Override
+    protected CommandConfig getCommandConfig() {
+        return new DescribeConfig();
+    }
 
-	@Override
-	protected String getUsageDescription() {
-		return "\nProvides information about an ASTERIX instance."
-				+ "\n\nUsage arguments/options:-"
-				+ "\n[-n]       Name of the ASTERIX instance."
-				+ "\n[-admin]   Provides a detailed description";
-	}
+    @Override
+    protected String getUsageDescription() {
+        return "\nProvides information about an ASTERIX instance." + "\n\nUsage arguments/options:-"
+                + "\n[-n]       Name of the ASTERIX instance." + "\n[-admin]   Provides a detailed description";
+    }
 
 }
 
-class DescribeConfig extends AbstractCommandConfig {
+class DescribeConfig extends CommandConfig {
 
-	@Option(name = "-n", required = false, usage = "Name of Asterix Instance")
-	public String name;
+    @Option(name = "-n", required = false, usage = "Name of Asterix Instance")
+    public String name;
 
-	@Option(name = "-admin", required = false, usage = "Detailed description")
-	public boolean admin;
+    @Option(name = "-admin", required = false, usage = "Detailed description")
+    public boolean admin;
 
 }
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/HelpCommand.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/HelpCommand.java
new file mode 100644
index 0000000..a9864a3
--- /dev/null
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/HelpCommand.java
@@ -0,0 +1,85 @@
+/*
+ * Copyright 2009-2012 by The Regents of the University of California
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * you may obtain a copy of the License from
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package edu.uci.ics.asterix.installer.command;
+
+import org.kohsuke.args4j.Option;
+
+public class HelpCommand extends AbstractCommand {
+
+    @Override
+    protected void execCommand() throws Exception {
+        HelpConfig helpConfig = (HelpConfig) config;
+        String command = helpConfig.command;
+        CommandType cmdType = CommandType.valueOf(command.toUpperCase());
+        String helpMessage = null;
+        switch (cmdType) {
+            case CREATE:
+                helpMessage = new CreateCommand().getUsageDescription();
+                break;
+            case CONFIGURE:
+                helpMessage = new ConfigureCommand().getUsageDescription();
+                break;
+            case DELETE:
+                helpMessage = new DeleteCommand().getUsageDescription();
+                break;
+            case DESCRIBE:
+                helpMessage = new DescribeCommand().getUsageDescription();
+                break;
+            case RESTORE:
+                helpMessage = new RestoreCommand().getUsageDescription();
+                break;
+            case START:
+                helpMessage = new StartCommand().getUsageDescription();
+                break;
+            case SHUTDOWN:
+                helpMessage = new ShutdownCommand().getUsageDescription();
+                break;
+            case BACKUP:
+                helpMessage = new BackupCommand().getUsageDescription();
+                break;
+            case STOP:
+                helpMessage = new StopCommand().getUsageDescription();
+                break;
+            case VALIDATE:
+                helpMessage = new ValidateCommand().getUsageDescription();
+                break;
+            default:
+                helpMessage = "Unknown command " + command;
+        }
+
+        System.out.println(helpMessage);
+    }
+
+    @Override
+    protected CommandConfig getCommandConfig() {
+        return new HelpConfig();
+    }
+
+    @Override
+    protected String getUsageDescription() {
+        return "\nAlter the instance's configuration settings."
+                + "\nPrior to running this command, the instance is required to be INACTIVE state."
+                + "\n\nAvailable arguments/options" + "\n-n name of the ASTERIX instance"
+                + "\n-conf path to the ASTERIX configuration file.";
+    }
+
+}
+
+class HelpConfig extends CommandConfig {
+
+    @Option(name = "-cmd", required = true, usage = "Name of Asterix Instance")
+    public String command;
+
+}
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/ICommand.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/ICommand.java
index d27fee9..979c414 100644
--- a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/ICommand.java
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/ICommand.java
@@ -27,7 +27,8 @@
         ALTER,
         VALIDATE,
         CONFIGURE,
-        SHUTDOWN
+        SHUTDOWN,
+        HELP
     }
 
     public void execute(String args[]) throws Exception;
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/RestoreCommand.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/RestoreCommand.java
index 49629a4..9ef925a 100644
--- a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/RestoreCommand.java
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/RestoreCommand.java
@@ -60,7 +60,7 @@
 
 }
 
-class RestoreConfig extends AbstractCommandConfig {
+class RestoreConfig extends CommandConfig {
 
     @Option(name = "-n", required = true, usage = "Name of the Asterix instance")
     public String name;
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/ShutdownCommand.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/ShutdownCommand.java
index cbfd5c5..b9dd23d 100644
--- a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/ShutdownCommand.java
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/ShutdownCommand.java
@@ -39,6 +39,6 @@
 
 }
 
-class ShutdownConfig extends AbstractCommandConfig {
+class ShutdownConfig extends CommandConfig {
 
 }
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/StartCommand.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/StartCommand.java
index 8004e9a..38bcf33 100644
--- a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/StartCommand.java
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/StartCommand.java
@@ -61,11 +61,9 @@
     }
 }
 
-class StartConfig extends AbstractCommandConfig {
+class StartConfig extends CommandConfig {
 
     @Option(name = "-n", required = true, usage = "Name of Asterix Instance")
     public String name;
 
-  
-
 }
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/StopCommand.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/StopCommand.java
index 85fcb68..0e10414 100644
--- a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/StopCommand.java
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/StopCommand.java
@@ -80,7 +80,7 @@
 
 }
 
-class StopConfig extends AbstractCommandConfig {
+class StopConfig extends CommandConfig {
 
     @Option(name = "-n", required = true, usage = "Name of Asterix Instance")
     public String name;
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/ValidateCommand.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/ValidateCommand.java
index 42c0d38..1abeb0e 100644
--- a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/ValidateCommand.java
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/command/ValidateCommand.java
@@ -38,230 +38,204 @@
 
 public class ValidateCommand extends AbstractCommand {
 
-	private static final String OK = " [" + "\u2713" + "]";
-	private static final String ERROR = " [" + "x" + "]";
-	private static final String WARNING = " [" + "!" + "]";
+    private static final String OK = " [" + "\u2713" + "]";
+    private static final String ERROR = " [" + "x" + "]";
+    private static final String WARNING = " [" + "!" + "]";
 
-	@Override
-	protected void execCommand() throws Exception {
-		ValidateConfig vConfig = (ValidateConfig) config;
-		logValidationResult("Environment", validateEnvironment());
-		if (((ValidateConfig) config).cluster != null) {
-			logValidationResult("Cluster configuration",
-					validateCluster(vConfig.cluster));
-		} else {
-			logValidationResult("Installer Configuration",
-					validateConfiguration());
-		}
-	}
+    @Override
+    protected void execCommand() throws Exception {
+        ValidateConfig vConfig = (ValidateConfig) config;
+        logValidationResult("Environment", validateEnvironment());
+        if (((ValidateConfig) config).cluster != null) {
+            logValidationResult("Cluster configuration", validateCluster(vConfig.cluster));
+        } else {
+            logValidationResult("Installer Configuration", validateConfiguration());
+        }
+    }
 
-	private void logValidationResult(String prefix, boolean isValid) {
-		if (!isValid) {
-			LOGGER.fatal(prefix + ERROR);
-		} else {
-			LOGGER.info(prefix + OK);
-		}
-	}
+    private void logValidationResult(String prefix, boolean isValid) {
+        if (!isValid) {
+            LOGGER.fatal(prefix + ERROR);
+        } else {
+            LOGGER.info(prefix + OK);
+        }
+    }
 
-	@Override
-	protected CommandConfig getCommandConfig() {
-		return new ValidateConfig();
-	}
+    @Override
+    protected CommandConfig getCommandConfig() {
+        return new ValidateConfig();
+    }
 
-	@Override
-	protected String getUsageDescription() {
-		return "\nValidate the installer's configuration or a cluster configuration"
-				+ "\nUsage"
-				+ "\nFor validating the installer configuration"
-				+ "\nuse managix validate"
-				+ "\n\nFor validating a cluster configuration"
-				+ "\nuse managix validate -c <path to the cluster configuration file>";
-	}
+    @Override
+    protected String getUsageDescription() {
+        return "\nValidate the installer's configuration or a cluster configuration" + "\nUsage"
+                + "\nFor validating the installer configuration" + "\nuse managix validate"
+                + "\n\nFor validating a cluster configuration"
+                + "\nuse managix validate -c <path to the cluster configuration file>";
+    }
 
-	public boolean validateEnvironment() throws Exception {
-		boolean valid = true;
-		String managixHome = System.getenv(InstallerDriver.ENV_MANAGIX_HOME);
-		if (managixHome == null) {
-			valid = false;
-			LOGGER.fatal(InstallerDriver.ENV_MANAGIX_HOME + " not set " + ERROR);
-		} else {
-			File home = new File(managixHome);
-			if (!home.exists()) {
-				valid = false;
-				LOGGER.fatal(InstallerDriver.ENV_MANAGIX_HOME + ": "
-						+ home.getAbsolutePath() + " does not exist!" + ERROR);
-			}
-		}
-		return valid;
+    public boolean validateEnvironment() throws Exception {
+        boolean valid = true;
+        String managixHome = System.getenv(InstallerDriver.ENV_MANAGIX_HOME);
+        if (managixHome == null) {
+            valid = false;
+            LOGGER.fatal(InstallerDriver.ENV_MANAGIX_HOME + " not set " + ERROR);
+        } else {
+            File home = new File(managixHome);
+            if (!home.exists()) {
+                valid = false;
+                LOGGER.fatal(InstallerDriver.ENV_MANAGIX_HOME + ": " + home.getAbsolutePath() + " does not exist!"
+                        + ERROR);
+            }
+        }
+        return valid;
 
-	}
+    }
 
-	public boolean validateCluster(String clusterPath) throws Exception {
-		boolean valid = true;
-		Cluster cluster = null;
-		File f = new File(clusterPath);
-		if (!f.exists() || !f.isFile()) {
-			LOGGER.error(" Invalid path " + f.getAbsolutePath() + ERROR);
-			valid = false;
-		} else {
-			JAXBContext ctx = JAXBContext.newInstance(Cluster.class);
-			Unmarshaller unmarshaller = ctx.createUnmarshaller();
-			cluster = (Cluster) unmarshaller.unmarshal(new File(clusterPath));
-			validateClusterProperties(cluster);
+    public boolean validateCluster(String clusterPath) throws Exception {
+        boolean valid = true;
+        Cluster cluster = null;
+        File f = new File(clusterPath);
+        if (!f.exists() || !f.isFile()) {
+            LOGGER.error(" Invalid path " + f.getAbsolutePath() + ERROR);
+            valid = false;
+        } else {
+            JAXBContext ctx = JAXBContext.newInstance(Cluster.class);
+            Unmarshaller unmarshaller = ctx.createUnmarshaller();
+            cluster = (Cluster) unmarshaller.unmarshal(new File(clusterPath));
+            validateClusterProperties(cluster);
 
-			Set<String> servers = new HashSet<String>();
-			Set<String> serverIds = new HashSet<String>();
-			servers.add(cluster.getMasterNode().getIp());
-			serverIds.add(cluster.getMasterNode().getId());
+            Set<String> servers = new HashSet<String>();
+            Set<String> serverIds = new HashSet<String>();
+            servers.add(cluster.getMasterNode().getClusterIp());
+            serverIds.add(cluster.getMasterNode().getId());
 
-			MasterNode masterNode = cluster.getMasterNode();
-			Node master = new Node(masterNode.getId(), masterNode.getIp(),
-					masterNode.getJavaHeap(), masterNode.getJavaHome(),
-					masterNode.getLogdir(), null, masterNode.getDebug());
+            MasterNode masterNode = cluster.getMasterNode();
+            Node master = new Node(masterNode.getId(), masterNode.getClusterIp(), masterNode.getJavaOpts(),
+                    masterNode.getJavaHome(), masterNode.getLogdir(), null, null, null);
 
-			valid = valid & validateNodeConfiguration(master, cluster);
+            valid = valid & validateNodeConfiguration(master, cluster);
 
-			for (Node node : cluster.getNode()) {
-				servers.add(node.getIp());
-				if (serverIds.contains(node.getId())) {
-					valid = false;
-					LOGGER.error("Duplicate node id :" + node.getId() + ERROR);
-				} else {
-					valid = valid & validateNodeConfiguration(node, cluster);
-				}
-			}
-		}
+            for (Node node : cluster.getNode()) {
+                servers.add(node.getClusterIp());
+                if (serverIds.contains(node.getId())) {
+                    valid = false;
+                    LOGGER.error("Duplicate node id :" + node.getId() + ERROR);
+                } else {
+                    valid = valid & validateNodeConfiguration(node, cluster);
+                }
+            }
+        }
 
-		return valid;
-	}
+        return valid;
+    }
 
-	private void validateClusterProperties(Cluster cluster) {
-		List<String> tempDirs = new ArrayList<String>();
-		if (cluster.getLogdir() != null
-				&& checkTemporaryPath(cluster.getLogdir())) {
-			tempDirs.add("Log directory: " + cluster.getLogdir());
-		}
-		if (cluster.getStore() != null
-				&& checkTemporaryPath(cluster.getStore())) {
-			tempDirs.add("Store directory: " + cluster.getStore());
-		}
+    private void validateClusterProperties(Cluster cluster) {
+        List<String> tempDirs = new ArrayList<String>();
+        if (cluster.getLogdir() != null && checkTemporaryPath(cluster.getLogdir())) {
+            tempDirs.add("Log directory: " + cluster.getLogdir());
+        }
+        if (cluster.getStore() != null && checkTemporaryPath(cluster.getStore())) {
+            tempDirs.add("Store directory: " + cluster.getStore());
+        }
 
-		if (tempDirs.size() > 0) {
-			StringBuffer msg = new StringBuffer();
-			msg.append("The following paths are subject to be cleaned up by OS");
-			for (String tempDir : tempDirs) {
-				msg.append("\n" + tempDir + WARNING);
-			}
-			LOGGER.warn(msg);
-		}
+        if (tempDirs.size() > 0) {
+            StringBuffer msg = new StringBuffer();
+            msg.append("The following paths are subject to be cleaned up by OS");
+            for (String tempDir : tempDirs) {
+                msg.append("\n" + tempDir + WARNING);
+            }
+            LOGGER.warn(msg);
+        }
 
-	}
+    }
 
-	private boolean validateNodeConfiguration(Node node, Cluster cluster) {
-		boolean valid = true;
-		valid = checkNodeReachability(node.getIp());
-		if (node.getJavaHome() == null || node.getJavaHome().length() == 0) {
-			if (cluster.getJavaHome() == null
-					|| cluster.getJavaHome().length() == 0) {
-				valid = false;
-				LOGGER.fatal("java_home not defined at cluster/node level for node: "
-						+ node.getId() + ERROR);
-			}
-		}
+    private boolean validateNodeConfiguration(Node node, Cluster cluster) {
+        boolean valid = true;
+        valid = checkNodeReachability(node.getClusterIp());
+        if (node.getJavaHome() == null || node.getJavaHome().length() == 0) {
+            if (cluster.getJavaHome() == null || cluster.getJavaHome().length() == 0) {
+                valid = false;
+                LOGGER.fatal("java_home not defined at cluster/node level for node: " + node.getId() + ERROR);
+            }
+        }
 
-		if (node.getLogdir() == null || node.getLogdir().length() == 0) {
-			if (cluster.getLogdir() == null
-					|| cluster.getLogdir().length() == 0) {
-				valid = false;
-				LOGGER.fatal("log_dir not defined at cluster/node level for node: "
-						+ node.getId() + ERROR);
-			}
-		}
+        if (node.getLogdir() == null || node.getLogdir().length() == 0) {
+            if (cluster.getLogdir() == null || cluster.getLogdir().length() == 0) {
+                valid = false;
+                LOGGER.fatal("log_dir not defined at cluster/node level for node: " + node.getId() + ERROR);
+            }
+        }
 
-		if (node.getStore() == null || cluster.getStore().length() == 0) {
-			if (cluster.getMasterNode().getId().equals(node.getId())
-					&& (cluster.getStore() == null || cluster.getStore()
-							.length() == 0)) {
-				valid = false;
-				LOGGER.fatal("store not defined at cluster/node level for node: "
-						+ node.getId() + ERROR);
-			}
-		}
+        if (node.getStore() == null || cluster.getStore().length() == 0) {
+            if (cluster.getMasterNode().getId().equals(node.getId())
+                    && (cluster.getStore() == null || cluster.getStore().length() == 0)) {
+                valid = false;
+                LOGGER.fatal("store not defined at cluster/node level for node: " + node.getId() + ERROR);
+            }
+        }
 
-		if (node.getJavaHeap() == null || node.getJavaHeap().length() == 0) {
-			if (cluster.getJavaHeap() == null
-					|| cluster.getJavaHeap().length() == 0) {
-				valid = false;
-				LOGGER.fatal("java heap size not defined at cluster/node level for node: "
-						+ node.getId() + ERROR);
-			}
-		}
-		return valid;
-	}
+        return valid;
+    }
 
-	private boolean checkTemporaryPath(String logdir) {
-		return logdir.startsWith("/tmp/");
+    private boolean checkTemporaryPath(String logdir) {
+        return logdir.startsWith("/tmp/");
 
-	}
+    }
 
-	public boolean validateConfiguration() throws Exception {
-		String managixHome = System.getenv(InstallerDriver.ENV_MANAGIX_HOME);
-		File configFile = new File(managixHome + File.separator
-				+ InstallerDriver.MANAGIX_CONF_XML);
-		JAXBContext configCtx = JAXBContext.newInstance(Configuration.class);
-		Unmarshaller unmarshaller = configCtx.createUnmarshaller();
-		Configuration conf = (Configuration) unmarshaller.unmarshal(configFile);
-		return validateZookeeperConfiguration(conf);
-	}
+    public boolean validateConfiguration() throws Exception {
+        String managixHome = System.getenv(InstallerDriver.ENV_MANAGIX_HOME);
+        File configFile = new File(managixHome + File.separator + InstallerDriver.MANAGIX_CONF_XML);
+        JAXBContext configCtx = JAXBContext.newInstance(Configuration.class);
+        Unmarshaller unmarshaller = configCtx.createUnmarshaller();
+        Configuration conf = (Configuration) unmarshaller.unmarshal(configFile);
+        return validateZookeeperConfiguration(conf);
+    }
 
-	private boolean validateZookeeperConfiguration(Configuration conf)
-			throws Exception {
-		boolean valid = true;
-		Zookeeper zk = conf.getZookeeper();
+    private boolean validateZookeeperConfiguration(Configuration conf) throws Exception {
+        boolean valid = true;
+        Zookeeper zk = conf.getZookeeper();
 
-		if (zk.getHomeDir() == null || zk.getHomeDir().length() == 0) {
-			valid = false;
-			LOGGER.fatal("Zookeeper home dir not configured" + ERROR);
-		} else if (checkTemporaryPath(zk.getHomeDir())) {
-			LOGGER.warn("Zookeeper home dir is subject to be cleaned up by OS"
-					+ WARNING);
-		}
+        if (zk.getHomeDir() == null || zk.getHomeDir().length() == 0) {
+            valid = false;
+            LOGGER.fatal("Zookeeper home dir not configured" + ERROR);
+        } else if (checkTemporaryPath(zk.getHomeDir())) {
+            LOGGER.warn("Zookeeper home dir is subject to be cleaned up by OS" + WARNING);
+        }
 
-		if (zk.getServers().getServer().isEmpty()) {
-			valid = false;
-			LOGGER.fatal("Zookeeper servers not configured" + ERROR);
-		}
+        if (zk.getServers().getServer().isEmpty()) {
+            valid = false;
+            LOGGER.fatal("Zookeeper servers not configured" + ERROR);
+        }
 
-		boolean validEnsemble = true;
-		for (String server : zk.getServers().getServer()) {
-			validEnsemble = validEnsemble && checkNodeReachability(server);
-		}
+        boolean validEnsemble = true;
+        for (String server : zk.getServers().getServer()) {
+            validEnsemble = validEnsemble && checkNodeReachability(server);
+        }
 
-		return valid;
-	}
+        return valid;
+    }
 
-	private boolean checkNodeReachability(String server) {
-		boolean reachable = true;
-		try {
-			InetAddress address = InetAddress.getByName(server);
-			if (!address.isReachable(1000)) {
-				LOGGER.fatal("\n" + "Server: " + server + " unreachable"
-						+ ERROR);
-				reachable = false;
-			}
-		} catch (Exception e) {
-			reachable = false;
-			LOGGER.fatal("\n" + "Server: " + server + " Invalid address"
-					+ ERROR);
-		}
-		return reachable;
-	}
+    private boolean checkNodeReachability(String server) {
+        boolean reachable = true;
+        try {
+            InetAddress address = InetAddress.getByName(server);
+            if (!address.isReachable(1000)) {
+                LOGGER.fatal("\n" + "Server: " + server + " unreachable" + ERROR);
+                reachable = false;
+            }
+        } catch (Exception e) {
+            reachable = false;
+            LOGGER.fatal("\n" + "Server: " + server + " Invalid address" + ERROR);
+        }
+        return reachable;
+    }
 
 }
 
-class ValidateConfig extends AbstractCommandConfig {
+class ValidateConfig extends CommandConfig {
 
-	@Option(name = "-c", required = false, usage = "Path to the cluster configuration xml")
-	public String cluster;
+    @Option(name = "-c", required = false, usage = "Path to the cluster configuration xml")
+    public String cluster;
 
 }
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/driver/InstallerUtil.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/driver/InstallerUtil.java
index 24b531a..a688abf 100644
--- a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/driver/InstallerUtil.java
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/driver/InstallerUtil.java
@@ -25,9 +25,12 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.StringWriter;
+import java.net.URL;
+import java.net.URLClassLoader;
 import java.util.ArrayList;
 import java.util.Enumeration;
 import java.util.List;
+import java.util.Map;
 import java.util.Properties;
 import java.util.Random;
 import java.util.jar.JarEntry;
@@ -71,10 +74,27 @@
         unzip(InstallerDriver.getAsterixZip(), asterixInstanceDir);
         File sourceJar = new File(asterixInstanceDir + File.separator + "lib" + File.separator + "asterix-app-"
                 + asterixInstance.getAsterixVersion() + ".jar");
-        String origFile = "test.properties";
+
+        String txnLogPropertyFile = "log.properties";
+        Properties txnLogProperties = new Properties();
+        URLClassLoader urlClassLoader = new URLClassLoader(new URL[] { sourceJar.toURI().toURL() });
+        InputStream in = urlClassLoader.getResourceAsStream(txnLogPropertyFile);
+        if (in != null) {
+            txnLogProperties.load(in);
+        }
+
+        writeAsterixLogConfigurationFile(asterixInstance.getName(), asterixInstance.getCluster(), txnLogProperties);
+
+        String asterixPropertyFile = "test.properties";
         File replacementFile = new File(asterixInstanceDir + File.separator + "test.properties");
-        replaceInJar(sourceJar, origFile, replacementFile);
+        replaceInJar(sourceJar, asterixPropertyFile, replacementFile);
+
+        replacementFile = new File(asterixInstanceDir + File.separator + "log.properties");
+        replaceInJar(sourceJar, txnLogPropertyFile, replacementFile);
+
         new File(asterixInstanceDir + File.separator + "test.properties").delete();
+        new File(asterixInstanceDir + File.separator + "log.properties").delete();
+
         String asterixZipName = InstallerDriver.getAsterixZip().substring(
                 InstallerDriver.getAsterixZip().lastIndexOf(File.separator) + 1);
         zipDir(new File(asterixInstanceDir), new File(asterixInstanceDir + File.separator + asterixZipName));
@@ -111,7 +131,6 @@
 
     public static String getNodeDirectories(String asterixInstanceName, Node node, Cluster cluster) {
         String storeDataSubDir = asterixInstanceName + File.separator + "data" + File.separator;
-        String storeLibrarySubDir = asterixInstanceName + File.separator + "library" + File.separator;
         String[] storeDirs = null;
         StringBuffer nodeDataStore = new StringBuffer();
         String storeDirValue = node.getStore();
@@ -121,7 +140,6 @@
                 throw new IllegalStateException(" Store not defined for node " + node.getId());
             }
             storeDataSubDir = node.getId() + File.separator + storeDataSubDir;
-            storeLibrarySubDir = node.getId() + File.separator + storeLibrarySubDir;
         }
 
         storeDirs = storeDirValue.split(",");
@@ -143,19 +161,40 @@
         conf.append("MetadataNode=" + asterixInstanceName + "_" + metadataNodeId + "\n");
         conf.append("NewUniverse=" + newData + "\n");
 
+        String storeDir = null;
         for (Node node : cluster.getNode()) {
-            String nodeDir = getNodeDirectories(asterixInstance.getName(), node, cluster);
-            conf.append(asterixInstanceName + "_" + node.getId() + ".stores" + "=" + nodeDir + "\n");
+            storeDir = node.getStore() == null ? cluster.getStore() : node.getStore();
+            conf.append(asterixInstanceName + "_" + node.getId() + ".stores" + "=" + storeDir + "\n");
         }
+
         Properties asterixConfProp = asterixInstance.getConfiguration();
         String outputDir = asterixConfProp.getProperty("output_dir");
         conf.append("OutputDir=" + outputDir);
+
         File asterixConfDir = new File(InstallerDriver.getAsterixDir() + File.separator + asterixInstanceName);
         asterixConfDir.mkdirs();
         dumpToFile(InstallerDriver.getAsterixDir() + File.separator + asterixInstanceName + File.separator
                 + "test.properties", conf.toString());
     }
 
+    private static void writeAsterixLogConfigurationFile(String asterixInstanceName, Cluster cluster,
+            Properties logProperties) throws IOException {
+        StringBuffer conf = new StringBuffer();
+        for (Map.Entry<Object, Object> p : logProperties.entrySet()) {
+            conf.append(p.getKey() + "=" + p.getValue() + "\n");
+        }
+
+        for (Node node : cluster.getNode()) {
+            String iodevices = node.getIodevices() == null ? cluster.getIodevices() : node.getIodevices();
+            String store = node.getStore() == null ? cluster.getStore() : node.getStore();
+            String txnLogDir = iodevices.split(",")[0].trim() + File.separator + store;
+            conf.append(asterixInstanceName + "_" + node.getId() + "." + "txnLogDir=" + txnLogDir + "\n");
+        }
+        dumpToFile(InstallerDriver.getAsterixDir() + File.separator + asterixInstanceName + File.separator
+                + "log.properties", conf.toString());
+
+    }
+
     public static Properties getAsterixConfiguration(String asterixConf) throws FileNotFoundException, IOException {
         Properties prop = new Properties();
         prop.load(new FileInputStream(asterixConf));
@@ -301,21 +340,21 @@
     public static void evaluateConflictWithOtherInstances(AsterixInstance instance) throws Exception {
         List<AsterixInstance> existingInstances = ServiceProvider.INSTANCE.getLookupService().getAsterixInstances();
         List<String> usedIps = new ArrayList<String>();
-        String masterIp = instance.getCluster().getMasterNode().getIp();
+        String masterIp = instance.getCluster().getMasterNode().getClusterIp();
         for (Node node : instance.getCluster().getNode()) {
-            usedIps.add(node.getIp());
+            usedIps.add(node.getClusterIp());
         }
-        usedIps.add(instance.getCluster().getMasterNode().getIp());
+        usedIps.add(instance.getCluster().getMasterNode().getClusterIp());
         boolean conflictFound = false;
         AsterixInstance conflictingInstance = null;
         for (AsterixInstance existing : existingInstances) {
-            conflictFound = existing.getCluster().getMasterNode().getIp().equals(masterIp);
+            conflictFound = existing.getCluster().getMasterNode().getClusterIp().equals(masterIp);
             if (conflictFound) {
                 conflictingInstance = existing;
                 break;
             }
             for (Node n : existing.getCluster().getNode()) {
-                if (usedIps.contains(n.getIp())) {
+                if (usedIps.contains(n.getClusterIp())) {
                     conflictFound = true;
                     conflictingInstance = existing;
                     break;
@@ -341,7 +380,7 @@
         }
         ProcessBuilder pb = new ProcessBuilder(pargs);
         pb.environment().putAll(EventDriver.getEnvironment());
-        pb.environment().put("IP_LOCATION", EventDriver.CLIENT_NODE.getIp());
+        pb.environment().put("IP_LOCATION", EventDriver.CLIENT_NODE.getClusterIp());
         Process p = pb.start();
         BufferedInputStream bis = new BufferedInputStream(p.getInputStream());
         StringWriter writer = new StringWriter();
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/error/VerificationUtil.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/error/VerificationUtil.java
index 7c7a792..612c2e4 100644
--- a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/error/VerificationUtil.java
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/error/VerificationUtil.java
@@ -37,9 +37,9 @@
         Cluster cluster = instance.getCluster();
         List<String> args = new ArrayList<String>();
         args.add(instance.getName());
-        args.add(instance.getCluster().getMasterNode().getIp());
+        args.add(instance.getCluster().getMasterNode().getClusterIp());
         for (Node node : cluster.getNode()) {
-            args.add(node.getIp());
+            args.add(node.getClusterIp());
             args.add(instance.getName() + "_" + node.getId());
         }
 
@@ -51,10 +51,16 @@
         List<ProcessInfo> processes = new ArrayList<ProcessInfo>();
 
         for (String line : output.split("\n")) {
+            String nodeid = null;
             infoFields = line.split(":");
             try {
                 int pid = Integer.parseInt(infoFields[3]);
-                pInfo = new ProcessInfo(infoFields[0], infoFields[1], pid);
+                if (infoFields[0].equals("NC")) {
+                    nodeid = infoFields[2].split("_")[1];
+                } else {
+                    nodeid = instance.getCluster().getMasterNode().getId();
+                }
+                pInfo = new ProcessInfo(infoFields[0], infoFields[1], nodeid, pid);
                 processes.add(pInfo);
             } catch (Exception e) {
                 if (infoFields[0].equalsIgnoreCase("CC")) {
@@ -72,8 +78,8 @@
         StringBuffer summary = new StringBuffer();
         if (expectedRunning) {
             if (!state.isCcRunning()) {
-                summary.append("Cluster Controller not running at " + instance.getCluster().getMasterNode().getIp()
-                        + "\n");
+                summary.append("Cluster Controller not running at "
+                        + instance.getCluster().getMasterNode().getClusterIp() + "\n");
                 instance.setState(State.UNUSABLE);
             }
             if (state.getFailedNCs() != null && !state.getFailedNCs().isEmpty()) {
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/events/PatternCreator.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/events/PatternCreator.java
index fc53304..887ebda 100644
--- a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/events/PatternCreator.java
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/events/PatternCreator.java
@@ -41,449 +41,385 @@
 
 public class PatternCreator {
 
-	private ILookupService lookupService = ServiceProvider.INSTANCE
-			.getLookupService();
+    private ILookupService lookupService = ServiceProvider.INSTANCE.getLookupService();
 
-	private void addInitialDelay(Pattern p, int delay, String unit) {
-		Delay d = new Delay(new Value(null, "" + delay), unit);
-		p.setDelay(d);
-	}
+    private void addInitialDelay(Pattern p, int delay, String unit) {
+        Delay d = new Delay(new Value(null, "" + delay), unit);
+        p.setDelay(d);
+    }
 
-	public Patterns getStartAsterixPattern(String asterixInstanceName,
-			Cluster cluster) throws Exception {
-		String ccLocationId = cluster.getMasterNode().getId();
-		String ccLocationIp = cluster.getMasterNode().getIp();
+    public Patterns getStartAsterixPattern(String asterixInstanceName, Cluster cluster) throws Exception {
+        String ccLocationId = cluster.getMasterNode().getId();
+        String ccLocationIp = cluster.getMasterNode().getClusterIp();
 
-		String destDir = cluster.getWorkingDir().getDir() + File.separator
-				+ "asterix";
-		List<Pattern> ps = new ArrayList<Pattern>();
+        String destDir = cluster.getWorkingDir().getDir() + File.separator + "asterix";
+        List<Pattern> ps = new ArrayList<Pattern>();
 
-		Pattern copyHyracks = createCopyHyracksPattern(asterixInstanceName,
-				cluster, ccLocationIp, destDir);
-		ps.add(copyHyracks);
+        Pattern copyHyracks = createCopyHyracksPattern(asterixInstanceName, cluster, ccLocationIp, destDir);
+        ps.add(copyHyracks);
 
-		Pattern createCC = createCCStartPattern(ccLocationId);
-		addInitialDelay(createCC, 2, "sec");
-		ps.add(createCC);
+        Pattern createCC = createCCStartPattern(ccLocationId);
+        addInitialDelay(createCC, 2, "sec");
+        ps.add(createCC);
 
-		boolean copyHyracksToNC = !cluster.getWorkingDir().isNFS();
-		for (Node node : cluster.getNode()) {
-			if (copyHyracksToNC) {
-				Pattern copyHyracksForNC = createCopyHyracksPattern(
-						asterixInstanceName, cluster, node.getIp(), destDir);
-				ps.add(copyHyracksForNC);
-			}
-			Pattern createNC = createNCStartPattern(cluster.getMasterNode()
-					.getIp(), node.getId(),
-					asterixInstanceName + "_" + node.getId());
-			addInitialDelay(createNC, 4, "sec");
-			ps.add(createNC);
-		}
+        boolean copyHyracksToNC = !cluster.getWorkingDir().isNFS();
+        for (Node node : cluster.getNode()) {
+            if (copyHyracksToNC) {
+                Pattern copyHyracksForNC = createCopyHyracksPattern(asterixInstanceName, cluster, node.getClusterIp(),
+                        destDir);
+                ps.add(copyHyracksForNC);
+            }
+            String iodevices = node.getIodevices() == null ? cluster.getIodevices() : node.getIodevices();
+            Pattern createNC = createNCStartPattern(cluster.getMasterNode().getClusterIp(), node.getId(),
+                    asterixInstanceName + "_" + node.getId(), iodevices);
+            addInitialDelay(createNC, 4, "sec");
+            ps.add(createNC);
+        }
 
-		Patterns patterns = new Patterns(ps);
-		patterns.getPattern().addAll(
-				createHadoopLibraryTransferPattern(cluster).getPattern());
-		return patterns;
-	}
+        Patterns patterns = new Patterns(ps);
+        patterns.getPattern().addAll(createHadoopLibraryTransferPattern(cluster).getPattern());
+        return patterns;
+    }
 
-	public Patterns getStopCommandPattern(StopCommand stopCommand)
-			throws Exception {
-		List<Pattern> ps = new ArrayList<Pattern>();
-		AsterixInstance asterixInstance = lookupService
-				.getAsterixInstance(stopCommand.getAsterixInstanceName());
-		Cluster cluster = asterixInstance.getCluster();
+    public Patterns getStopCommandPattern(StopCommand stopCommand) throws Exception {
+        List<Pattern> ps = new ArrayList<Pattern>();
+        AsterixInstance asterixInstance = lookupService.getAsterixInstance(stopCommand.getAsterixInstanceName());
+        Cluster cluster = asterixInstance.getCluster();
 
-		String ccLocation = cluster.getMasterNode().getId();
-		Pattern createCC = createCCStopPattern(ccLocation);
-		addInitialDelay(createCC, 5, "sec");
-		ps.add(createCC);
+        String ccLocation = cluster.getMasterNode().getId();
+        Pattern createCC = createCCStopPattern(ccLocation);
+        addInitialDelay(createCC, 5, "sec");
+        ps.add(createCC);
 
-		String asterixInstanceName = stopCommand.getAsterixInstanceName();
-		int nodeControllerIndex = 1;
-		for (Node node : cluster.getNode()) {
-			Pattern createNC = createNCStopPattern(node.getId(),
-					asterixInstanceName + "_" + nodeControllerIndex);
-			ps.add(createNC);
-			nodeControllerIndex++;
-		}
+        String asterixInstanceName = stopCommand.getAsterixInstanceName();
+        int nodeControllerIndex = 1;
+        for (Node node : cluster.getNode()) {
+            Pattern createNC = createNCStopPattern(node.getId(), asterixInstanceName + "_" + nodeControllerIndex);
+            ps.add(createNC);
+            nodeControllerIndex++;
+        }
 
-		Patterns patterns = new Patterns(ps);
-		return patterns;
-	}
+        Patterns patterns = new Patterns(ps);
+        return patterns;
+    }
 
-	public Patterns getBackUpAsterixPattern(AsterixInstance instance,
-			Backup backupConf) throws Exception {
-		BackupType backupType = BackupInfo.getBackupType(backupConf);
-		Patterns patterns = null;
-		switch (backupType) {
-		case HDFS:
-			patterns = getHDFSBackUpAsterixPattern(instance, backupConf);
-			break;
-		case LOCAL:
-			patterns = getLocalBackUpAsterixPattern(instance, backupConf);
-			break;
-		}
-		return patterns;
-	}
+    public Patterns getBackUpAsterixPattern(AsterixInstance instance, Backup backupConf) throws Exception {
+        BackupType backupType = BackupInfo.getBackupType(backupConf);
+        Patterns patterns = null;
+        switch (backupType) {
+            case HDFS:
+                patterns = getHDFSBackUpAsterixPattern(instance, backupConf);
+                break;
+            case LOCAL:
+                patterns = getLocalBackUpAsterixPattern(instance, backupConf);
+                break;
+        }
+        return patterns;
+    }
 
-	public Patterns getRestoreAsterixPattern(AsterixInstance instance,
-			BackupInfo backupInfo) throws Exception {
-		BackupType backupType = backupInfo.getBackupType();
-		Patterns patterns = null;
-		switch (backupType) {
-		case HDFS:
-			patterns = getHDFSRestoreAsterixPattern(instance, backupInfo);
-			break;
-		case LOCAL:
-			patterns = getLocalRestoreAsterixPattern(instance, backupInfo);
-			break;
-		}
-		return patterns;
-	}
+    public Patterns getRestoreAsterixPattern(AsterixInstance instance, BackupInfo backupInfo) throws Exception {
+        BackupType backupType = backupInfo.getBackupType();
+        Patterns patterns = null;
+        switch (backupType) {
+            case HDFS:
+                patterns = getHDFSRestoreAsterixPattern(instance, backupInfo);
+                break;
+            case LOCAL:
+                patterns = getLocalRestoreAsterixPattern(instance, backupInfo);
+                break;
+        }
+        return patterns;
+    }
 
-	private Patterns getHDFSBackUpAsterixPattern(AsterixInstance instance,
-			Backup backupConf) throws Exception {
-		Cluster cluster = instance.getCluster();
-		String clusterStore = instance.getCluster().getStore();
-		String hdfsUrl = backupConf.getHdfs().getUrl();
-		String hadoopVersion = backupConf.getHdfs().getVersion();
-		String hdfsBackupDir = backupConf.getBackupDir();
-		VerificationUtil.verifyBackupRestoreConfiguration(hdfsUrl,
-				hadoopVersion, hdfsBackupDir);
-		String workingDir = cluster.getWorkingDir().getDir();
-		String backupId = "" + instance.getBackupInfo().size();
-		String nodeStore;
-		String pargs;
-		List<Pattern> patternList = new ArrayList<Pattern>();
-		for (Node node : cluster.getNode()) {
-			Nodeid nodeid = new Nodeid(new Value(null, node.getId()));
-			nodeStore = node.getStore() == null ? clusterStore : node
-					.getStore();
-			pargs = workingDir + " " + instance.getName() + " " + nodeStore
-					+ " " + backupId + " " + hdfsBackupDir + " " + "hdfs" + " "
-					+ node.getId() + " " + hdfsUrl + " " + hadoopVersion;
-			Event event = new Event("backup", nodeid, pargs);
-			patternList.add(new Pattern(null, 1, null, event));
-		}
-		return new Patterns(patternList);
-	}
+    private Patterns getHDFSBackUpAsterixPattern(AsterixInstance instance, Backup backupConf) throws Exception {
+        Cluster cluster = instance.getCluster();
+        String clusterStore = instance.getCluster().getStore();
+        String hdfsUrl = backupConf.getHdfs().getUrl();
+        String hadoopVersion = backupConf.getHdfs().getVersion();
+        String hdfsBackupDir = backupConf.getBackupDir();
+        VerificationUtil.verifyBackupRestoreConfiguration(hdfsUrl, hadoopVersion, hdfsBackupDir);
+        String workingDir = cluster.getWorkingDir().getDir();
+        String backupId = "" + instance.getBackupInfo().size();
+        String nodeStore;
+        String pargs;
+        List<Pattern> patternList = new ArrayList<Pattern>();
+        for (Node node : cluster.getNode()) {
+            Nodeid nodeid = new Nodeid(new Value(null, node.getId()));
+            nodeStore = node.getStore() == null ? clusterStore : node.getStore();
+            pargs = workingDir + " " + instance.getName() + " " + nodeStore + " " + backupId + " " + hdfsBackupDir
+                    + " " + "hdfs" + " " + node.getId() + " " + hdfsUrl + " " + hadoopVersion;
+            Event event = new Event("backup", nodeid, pargs);
+            patternList.add(new Pattern(null, 1, null, event));
+        }
+        return new Patterns(patternList);
+    }
 
-	private Patterns getLocalBackUpAsterixPattern(AsterixInstance instance,
-			Backup backupConf) throws Exception {
-		Cluster cluster = instance.getCluster();
-		String clusterStore = instance.getCluster().getStore();
-		String backupDir = backupConf.getBackupDir();
-		String workingDir = cluster.getWorkingDir().getDir();
-		String backupId = "" + instance.getBackupInfo().size();
-		String nodeStore;
-		String pargs;
-		List<Pattern> patternList = new ArrayList<Pattern>();
-		for (Node node : cluster.getNode()) {
-			Nodeid nodeid = new Nodeid(new Value(null, node.getId()));
-			nodeStore = node.getStore() == null ? clusterStore : node
-					.getStore();
-			pargs = workingDir + " " + instance.getName() + " " + nodeStore
-					+ " " + backupId + " " + backupDir + " " + "local" + " "
-					+ node.getId();
-			Event event = new Event("backup", nodeid, pargs);
-			patternList.add(new Pattern(null, 1, null, event));
-		}
-		return new Patterns(patternList);
-	}
+    private Patterns getLocalBackUpAsterixPattern(AsterixInstance instance, Backup backupConf) throws Exception {
+        Cluster cluster = instance.getCluster();
+        String clusterStore = instance.getCluster().getStore();
+        String backupDir = backupConf.getBackupDir();
+        String workingDir = cluster.getWorkingDir().getDir();
+        String backupId = "" + instance.getBackupInfo().size();
+        String nodeStore;
+        String pargs;
+        List<Pattern> patternList = new ArrayList<Pattern>();
+        for (Node node : cluster.getNode()) {
+            Nodeid nodeid = new Nodeid(new Value(null, node.getId()));
+            nodeStore = node.getStore() == null ? clusterStore : node.getStore();
+            pargs = workingDir + " " + instance.getName() + " " + nodeStore + " " + backupId + " " + backupDir + " "
+                    + "local" + " " + node.getId();
+            Event event = new Event("backup", nodeid, pargs);
+            patternList.add(new Pattern(null, 1, null, event));
+        }
+        return new Patterns(patternList);
+    }
 
-	public Patterns getHDFSRestoreAsterixPattern(AsterixInstance instance,
-			BackupInfo backupInfo) throws Exception {
-		Cluster cluster = instance.getCluster();
-		String clusterStore = instance.getCluster().getStore();
-		String hdfsUrl = backupInfo.getBackupConf().getHdfs().getUrl();
-		String hadoopVersion = backupInfo.getBackupConf().getHdfs()
-				.getVersion();
-		String hdfsBackupDir = backupInfo.getBackupConf().getBackupDir();
-		VerificationUtil.verifyBackupRestoreConfiguration(hdfsUrl,
-				hadoopVersion, hdfsBackupDir);
-		String workingDir = cluster.getWorkingDir().getDir();
-		int backupId = backupInfo.getId();
-		String nodeStore;
-		String pargs;
-		List<Pattern> patternList = new ArrayList<Pattern>();
-		for (Node node : cluster.getNode()) {
-			Nodeid nodeid = new Nodeid(new Value(null, node.getId()));
-			nodeStore = node.getStore() == null ? clusterStore : node
-					.getStore();
-			pargs = workingDir + " " + instance.getName() + " " + nodeStore
-					+ " " + backupId + " " + hdfsBackupDir + " " + "hdfs" + " "
-					+ node.getId() + " " + hdfsUrl + " " + hadoopVersion;
-			Event event = new Event("restore", nodeid, pargs);
-			patternList.add(new Pattern(null, 1, null, event));
-		}
-		return new Patterns(patternList);
-	}
+    public Patterns getHDFSRestoreAsterixPattern(AsterixInstance instance, BackupInfo backupInfo) throws Exception {
+        Cluster cluster = instance.getCluster();
+        String clusterStore = instance.getCluster().getStore();
+        String hdfsUrl = backupInfo.getBackupConf().getHdfs().getUrl();
+        String hadoopVersion = backupInfo.getBackupConf().getHdfs().getVersion();
+        String hdfsBackupDir = backupInfo.getBackupConf().getBackupDir();
+        VerificationUtil.verifyBackupRestoreConfiguration(hdfsUrl, hadoopVersion, hdfsBackupDir);
+        String workingDir = cluster.getWorkingDir().getDir();
+        int backupId = backupInfo.getId();
+        String nodeStore;
+        String pargs;
+        List<Pattern> patternList = new ArrayList<Pattern>();
+        for (Node node : cluster.getNode()) {
+            Nodeid nodeid = new Nodeid(new Value(null, node.getId()));
+            nodeStore = node.getStore() == null ? clusterStore : node.getStore();
+            pargs = workingDir + " " + instance.getName() + " " + nodeStore + " " + backupId + " " + hdfsBackupDir
+                    + " " + "hdfs" + " " + node.getId() + " " + hdfsUrl + " " + hadoopVersion;
+            Event event = new Event("restore", nodeid, pargs);
+            patternList.add(new Pattern(null, 1, null, event));
+        }
+        return new Patterns(patternList);
+    }
 
-	public Patterns getLocalRestoreAsterixPattern(AsterixInstance instance,
-			BackupInfo backupInfo) throws Exception {
-		Cluster cluster = instance.getCluster();
-		String clusterStore = instance.getCluster().getStore();
-		String backupDir = backupInfo.getBackupConf().getBackupDir();
-		String workingDir = cluster.getWorkingDir().getDir();
-		int backupId = backupInfo.getId();
-		String nodeStore;
-		String pargs;
-		List<Pattern> patternList = new ArrayList<Pattern>();
-		for (Node node : cluster.getNode()) {
-			Nodeid nodeid = new Nodeid(new Value(null, node.getId()));
-			nodeStore = node.getStore() == null ? clusterStore : node
-					.getStore();
-			pargs = workingDir + " " + instance.getName() + " " + nodeStore
-					+ " " + backupId + " " + backupDir + " " + "local" + " "
-					+ node.getId();
-			Event event = new Event("restore", nodeid, pargs);
-			patternList.add(new Pattern(null, 1, null, event));
-		}
-		return new Patterns(patternList);
-	}
+    public Patterns getLocalRestoreAsterixPattern(AsterixInstance instance, BackupInfo backupInfo) throws Exception {
+        Cluster cluster = instance.getCluster();
+        String clusterStore = instance.getCluster().getStore();
+        String backupDir = backupInfo.getBackupConf().getBackupDir();
+        String workingDir = cluster.getWorkingDir().getDir();
+        int backupId = backupInfo.getId();
+        String nodeStore;
+        String pargs;
+        List<Pattern> patternList = new ArrayList<Pattern>();
+        for (Node node : cluster.getNode()) {
+            Nodeid nodeid = new Nodeid(new Value(null, node.getId()));
+            nodeStore = node.getStore() == null ? clusterStore : node.getStore();
+            pargs = workingDir + " " + instance.getName() + " " + nodeStore + " " + backupId + " " + backupDir + " "
+                    + "local" + " " + node.getId();
+            Event event = new Event("restore", nodeid, pargs);
+            patternList.add(new Pattern(null, 1, null, event));
+        }
+        return new Patterns(patternList);
+    }
 
-	public Patterns createHadoopLibraryTransferPattern(Cluster cluster)
-			throws Exception {
-		List<Pattern> patternList = new ArrayList<Pattern>();
-		String workingDir = cluster.getWorkingDir().getDir();
-		String hadoopVersion = InstallerDriver.getConfiguration().getBackup()
-				.getHdfs().getVersion();
-		File hadoopDir = new File(InstallerDriver.getManagixHome()
-				+ File.separator + InstallerDriver.MANAGIX_INTERNAL_DIR
-				+ File.separator + "hadoop-" + hadoopVersion);
-		if (!hadoopDir.exists()) {
-			throw new IllegalStateException("Hadoop version :" + hadoopVersion
-					+ " not supported");
-		}
+    public Patterns createHadoopLibraryTransferPattern(Cluster cluster) throws Exception {
+        List<Pattern> patternList = new ArrayList<Pattern>();
+        String workingDir = cluster.getWorkingDir().getDir();
+        String hadoopVersion = InstallerDriver.getConfiguration().getBackup().getHdfs().getVersion();
+        File hadoopDir = new File(InstallerDriver.getManagixHome() + File.separator
+                + InstallerDriver.MANAGIX_INTERNAL_DIR + File.separator + "hadoop-" + hadoopVersion);
+        if (!hadoopDir.exists()) {
+            throw new IllegalStateException("Hadoop version :" + hadoopVersion + " not supported");
+        }
 
-		Nodeid nodeid = new Nodeid(new Value(null,
-				EventDriver.CLIENT_NODE.getId()));
-		String username = cluster.getUsername() != null ? cluster.getUsername()
-				: System.getProperty("user.name");
-		String pargs = username + " " + hadoopDir.getAbsolutePath() + " "
-				+ cluster.getMasterNode().getIp() + " " + workingDir;
-		Event event = new Event("directory_transfer", nodeid, pargs);
-		Pattern p = new Pattern(null, 1, null, event);
-		addInitialDelay(p, 2, "sec");
-		patternList.add(p);
+        Nodeid nodeid = new Nodeid(new Value(null, EventDriver.CLIENT_NODE.getId()));
+        String username = cluster.getUsername() != null ? cluster.getUsername() : System.getProperty("user.name");
+        String pargs = username + " " + hadoopDir.getAbsolutePath() + " " + cluster.getMasterNode().getClusterIp()
+                + " " + workingDir;
+        Event event = new Event("directory_transfer", nodeid, pargs);
+        Pattern p = new Pattern(null, 1, null, event);
+        addInitialDelay(p, 2, "sec");
+        patternList.add(p);
 
-		boolean copyToNC = !cluster.getWorkingDir().isNFS();
-		if (copyToNC) {
-			for (Node node : cluster.getNode()) {
-				nodeid = new Nodeid(new Value(null, node.getId()));
-				pargs = cluster.getUsername() + " "
-						+ hadoopDir.getAbsolutePath() + " " + node.getIp()
-						+ " " + workingDir;
-				event = new Event("directory_transfer", nodeid, pargs);
-				p = new Pattern(null, 1, null, event);
-				addInitialDelay(p, 2, "sec");
-				patternList.add(p);
-			}
-		}
-		Patterns patterns = new Patterns(patternList);
-		return patterns;
-	}
+        boolean copyToNC = !cluster.getWorkingDir().isNFS();
+        if (copyToNC) {
+            for (Node node : cluster.getNode()) {
+                nodeid = new Nodeid(new Value(null, node.getId()));
+                pargs = cluster.getUsername() + " " + hadoopDir.getAbsolutePath() + " " + node.getClusterIp() + " "
+                        + workingDir;
+                event = new Event("directory_transfer", nodeid, pargs);
+                p = new Pattern(null, 1, null, event);
+                addInitialDelay(p, 2, "sec");
+                patternList.add(p);
+            }
+        }
+        Patterns patterns = new Patterns(patternList);
+        return patterns;
+    }
 
-	public Patterns createDeleteInstancePattern(AsterixInstance instance)
-			throws Exception {
-		List<Pattern> patternList = new ArrayList<Pattern>();
-		patternList.addAll(createRemoveAsterixStoragePattern(instance)
-				.getPattern());
-		if (instance.getBackupInfo() != null
-				&& instance.getBackupInfo().size() > 0) {
-			List<BackupInfo> backups = instance.getBackupInfo();
-			Set<String> removedBackupDirsHDFS = new HashSet<String>();
-			Set<String> removedBackupDirsLocal = new HashSet<String>();
+    public Patterns createDeleteInstancePattern(AsterixInstance instance) throws Exception {
+        List<Pattern> patternList = new ArrayList<Pattern>();
+        patternList.addAll(createRemoveAsterixStoragePattern(instance).getPattern());
+        if (instance.getBackupInfo() != null && instance.getBackupInfo().size() > 0) {
+            List<BackupInfo> backups = instance.getBackupInfo();
+            Set<String> removedBackupDirsHDFS = new HashSet<String>();
+            Set<String> removedBackupDirsLocal = new HashSet<String>();
 
-			String backupDir;
-			for (BackupInfo binfo : backups) {
-				backupDir = binfo.getBackupConf().getBackupDir();
-				switch (binfo.getBackupType()) {
-				case HDFS:
-					if (removedBackupDirsHDFS.contains(backups)) {
-						continue;
-					}
-					patternList.addAll(createRemoveHDFSBackupPattern(instance,
-							backupDir).getPattern());
-					removedBackupDirsHDFS.add(backupDir);
-					break;
+            String backupDir;
+            for (BackupInfo binfo : backups) {
+                backupDir = binfo.getBackupConf().getBackupDir();
+                switch (binfo.getBackupType()) {
+                    case HDFS:
+                        if (removedBackupDirsHDFS.contains(backups)) {
+                            continue;
+                        }
+                        patternList.addAll(createRemoveHDFSBackupPattern(instance, backupDir).getPattern());
+                        removedBackupDirsHDFS.add(backupDir);
+                        break;
 
-				case LOCAL:
-					if (removedBackupDirsLocal.contains(backups)) {
-						continue;
-					}
-					patternList.addAll(createRemoveLocalBackupPattern(instance,
-							backupDir).getPattern());
-					removedBackupDirsLocal.add(backupDir);
-					break;
-				}
+                    case LOCAL:
+                        if (removedBackupDirsLocal.contains(backups)) {
+                            continue;
+                        }
+                        patternList.addAll(createRemoveLocalBackupPattern(instance, backupDir).getPattern());
+                        removedBackupDirsLocal.add(backupDir);
+                        break;
+                }
 
-			}
-		}
-		patternList.addAll(createRemoveAsterixLogDirPattern(instance)
-				.getPattern());
-		Patterns patterns = new Patterns(patternList);
-		return patterns;
-	}
+            }
+        }
+        patternList.addAll(createRemoveAsterixLogDirPattern(instance).getPattern());
+        Patterns patterns = new Patterns(patternList);
+        return patterns;
+    }
 
-	private Patterns createRemoveHDFSBackupPattern(AsterixInstance instance,
-			String hdfsBackupDir) throws Exception {
-		List<Pattern> patternList = new ArrayList<Pattern>();
-		Cluster cluster = instance.getCluster();
-		String hdfsUrl = InstallerDriver.getConfiguration().getBackup()
-				.getHdfs().getUrl();
-		String hadoopVersion = InstallerDriver.getConfiguration().getBackup()
-				.getHdfs().getVersion();
-		String workingDir = cluster.getWorkingDir().getDir();
-		Node launchingNode = cluster.getNode().get(0);
-		Nodeid nodeid = new Nodeid(new Value(null, launchingNode.getId()));
-		String pathToDelete = hdfsBackupDir + File.separator
-				+ instance.getName();
-		String pargs = workingDir + " " + hadoopVersion + " " + hdfsUrl + " "
-				+ pathToDelete;
-		Event event = new Event("hdfs_delete", nodeid, pargs);
-		patternList.add(new Pattern(null, 1, null, event));
-		Patterns patterns = new Patterns(patternList);
-		return patterns;
-	}
+    private Patterns createRemoveHDFSBackupPattern(AsterixInstance instance, String hdfsBackupDir) throws Exception {
+        List<Pattern> patternList = new ArrayList<Pattern>();
+        Cluster cluster = instance.getCluster();
+        String hdfsUrl = InstallerDriver.getConfiguration().getBackup().getHdfs().getUrl();
+        String hadoopVersion = InstallerDriver.getConfiguration().getBackup().getHdfs().getVersion();
+        String workingDir = cluster.getWorkingDir().getDir();
+        Node launchingNode = cluster.getNode().get(0);
+        Nodeid nodeid = new Nodeid(new Value(null, launchingNode.getId()));
+        String pathToDelete = hdfsBackupDir + File.separator + instance.getName();
+        String pargs = workingDir + " " + hadoopVersion + " " + hdfsUrl + " " + pathToDelete;
+        Event event = new Event("hdfs_delete", nodeid, pargs);
+        patternList.add(new Pattern(null, 1, null, event));
+        Patterns patterns = new Patterns(patternList);
+        return patterns;
+    }
 
-	private Patterns createRemoveLocalBackupPattern(AsterixInstance instance,
-			String localBackupDir) throws Exception {
-		List<Pattern> patternList = new ArrayList<Pattern>();
-		Cluster cluster = instance.getCluster();
+    private Patterns createRemoveLocalBackupPattern(AsterixInstance instance, String localBackupDir) throws Exception {
+        List<Pattern> patternList = new ArrayList<Pattern>();
+        Cluster cluster = instance.getCluster();
 
-		String pathToDelete = localBackupDir + File.separator
-				+ instance.getName();
-		String pargs = pathToDelete;
-		List<String> removedBackupDirs = new ArrayList<String>();
-		for (Node node : cluster.getNode()) {
-			if (removedBackupDirs.contains(node.getIp())) {
-				continue;
-			}
-			Nodeid nodeid = new Nodeid(new Value(null, node.getId()));
-			Event event = new Event("file_delete", nodeid, pargs);
-			patternList.add(new Pattern(null, 1, null, event));
-			removedBackupDirs.add(node.getIp());
-		}
+        String pathToDelete = localBackupDir + File.separator + instance.getName();
+        String pargs = pathToDelete;
+        List<String> removedBackupDirs = new ArrayList<String>();
+        for (Node node : cluster.getNode()) {
+            if (removedBackupDirs.contains(node.getClusterIp())) {
+                continue;
+            }
+            Nodeid nodeid = new Nodeid(new Value(null, node.getId()));
+            Event event = new Event("file_delete", nodeid, pargs);
+            patternList.add(new Pattern(null, 1, null, event));
+            removedBackupDirs.add(node.getClusterIp());
+        }
 
-		Patterns patterns = new Patterns(patternList);
-		return patterns;
-	}
+        Patterns patterns = new Patterns(patternList);
+        return patterns;
+    }
 
-	public Patterns createRemoveAsterixWorkingDirPattern(
-			AsterixInstance instance) throws Exception {
-		List<Pattern> patternList = new ArrayList<Pattern>();
-		Cluster cluster = instance.getCluster();
-		String workingDir = cluster.getWorkingDir().getDir();
-		String pargs = workingDir;
-		Nodeid nodeid = new Nodeid(new Value(null, cluster.getMasterNode()
-				.getId()));
-		Event event = new Event("file_delete", nodeid, pargs);
-		patternList.add(new Pattern(null, 1, null, event));
+    public Patterns createRemoveAsterixWorkingDirPattern(AsterixInstance instance) throws Exception {
+        List<Pattern> patternList = new ArrayList<Pattern>();
+        Cluster cluster = instance.getCluster();
+        String workingDir = cluster.getWorkingDir().getDir();
+        String pargs = workingDir;
+        Nodeid nodeid = new Nodeid(new Value(null, cluster.getMasterNode().getId()));
+        Event event = new Event("file_delete", nodeid, pargs);
+        patternList.add(new Pattern(null, 1, null, event));
 
-		if (!cluster.getWorkingDir().isNFS()) {
-			for (Node node : cluster.getNode()) {
-				nodeid = new Nodeid(new Value(null, node.getId()));
-				event = new Event("file_delete", nodeid, pargs);
-				patternList.add(new Pattern(null, 1, null, event));
-			}
-		}
-		Patterns patterns = new Patterns(patternList);
-		return patterns;
-	}
+        if (!cluster.getWorkingDir().isNFS()) {
+            for (Node node : cluster.getNode()) {
+                nodeid = new Nodeid(new Value(null, node.getId()));
+                event = new Event("file_delete", nodeid, pargs);
+                patternList.add(new Pattern(null, 1, null, event));
+            }
+        }
+        Patterns patterns = new Patterns(patternList);
+        return patterns;
+    }
 
-	private Patterns createRemoveAsterixLogDirPattern(AsterixInstance instance)
-			throws Exception {
-		List<Pattern> patternList = new ArrayList<Pattern>();
-		Cluster cluster = instance.getCluster();
-		String pargs = instance.getCluster().getLogdir();
-		Nodeid nodeid = new Nodeid(new Value(null, cluster.getMasterNode()
-				.getId()));
-		Event event = new Event("file_delete", nodeid, pargs);
-		patternList.add(new Pattern(null, 1, null, event));
+    private Patterns createRemoveAsterixLogDirPattern(AsterixInstance instance) throws Exception {
+        List<Pattern> patternList = new ArrayList<Pattern>();
+        Cluster cluster = instance.getCluster();
+        String pargs = instance.getCluster().getLogdir();
+        Nodeid nodeid = new Nodeid(new Value(null, cluster.getMasterNode().getId()));
+        Event event = new Event("file_delete", nodeid, pargs);
+        patternList.add(new Pattern(null, 1, null, event));
 
-		if (!cluster.getWorkingDir().isNFS()) {
-			for (Node node : cluster.getNode()) {
-				nodeid = new Nodeid(new Value(null, node.getId()));
-				event = new Event("file_delete", nodeid, pargs);
-				patternList.add(new Pattern(null, 1, null, event));
-			}
-		}
-		Patterns patterns = new Patterns(patternList);
-		return patterns;
-	}
+        if (!cluster.getWorkingDir().isNFS()) {
+            for (Node node : cluster.getNode()) {
+                nodeid = new Nodeid(new Value(null, node.getId()));
+                event = new Event("file_delete", nodeid, pargs);
+                patternList.add(new Pattern(null, 1, null, event));
+            }
+        }
+        Patterns patterns = new Patterns(patternList);
+        return patterns;
+    }
 
-	private Patterns createRemoveAsterixStoragePattern(AsterixInstance instance)
-			throws Exception {
-		List<Pattern> patternList = new ArrayList<Pattern>();
-		Cluster cluster = instance.getCluster();
-		String pargs = null;
+    private Patterns createRemoveAsterixStoragePattern(AsterixInstance instance) throws Exception {
+        List<Pattern> patternList = new ArrayList<Pattern>();
+        Cluster cluster = instance.getCluster();
+        String pargs = null;
 
-		for (Node node : cluster.getNode()) {
-			Nodeid nodeid = new Nodeid(new Value(null, node.getId()));
-			String[] nodeStores;
-			if (node.getStore() != null) {
-				nodeStores = node.getStore().trim().split(",");
-				for (String ns : nodeStores) {
-					pargs = ns + File.separator + instance.getName();
-				}
-			} else {
-				nodeStores = cluster.getStore().trim().split(",");
-				for (String ns : nodeStores) {
-					pargs = ns + File.separator + node.getId() + File.separator
-							+ instance.getName();
-				}
-			}
-			Event event = new Event("file_delete", nodeid, pargs);
-			patternList.add(new Pattern(null, 1, null, event));
-		}
-		Patterns patterns = new Patterns(patternList);
-		return patterns;
-	}
+        for (Node node : cluster.getNode()) {
+            Nodeid nodeid = new Nodeid(new Value(null, node.getId()));
+            String[] nodeIODevices;
+            String iodevices = node.getIodevices() == null ? cluster.getIodevices() : node.getIodevices();
+            nodeIODevices = iodevices.trim().split(",");
+            for (String nodeIODevice : nodeIODevices) {
+                String nodeStore = node.getStore() == null ? cluster.getStore() : node.getStore();
+                pargs = nodeIODevice.trim() + File.separator + nodeStore;
+                Event event = new Event("file_delete", nodeid, pargs);
+                patternList.add(new Pattern(null, 1, null, event));
+            }
+        }
+        Patterns patterns = new Patterns(patternList);
+        return patterns;
+    }
 
-	private Pattern createCopyHyracksPattern(String instanceName,
-			Cluster cluster, String destinationIp, String destDir) {
-		Nodeid nodeid = new Nodeid(new Value(null,
-				EventDriver.CLIENT_NODE.getId()));
-		String username = cluster.getUsername() != null ? cluster.getUsername()
-				: System.getProperty("user.name");
-		String asterixZipName = InstallerDriver.getAsterixZip()
-				.substring(
-						InstallerDriver.getAsterixZip().lastIndexOf(
-								File.separator) + 1);
-		String fileToTransfer = new File(InstallerDriver.getAsterixDir()
-				+ File.separator + instanceName + File.separator
-				+ asterixZipName).getAbsolutePath();
-		String pargs = username + " " + fileToTransfer + " " + destinationIp
-				+ " " + destDir + " " + "unpack";
-		Event event = new Event("file_transfer", nodeid, pargs);
-		return new Pattern(null, 1, null, event);
-	}
+    private Pattern createCopyHyracksPattern(String instanceName, Cluster cluster, String destinationIp, String destDir) {
+        Nodeid nodeid = new Nodeid(new Value(null, EventDriver.CLIENT_NODE.getId()));
+        String username = cluster.getUsername() != null ? cluster.getUsername() : System.getProperty("user.name");
+        String asterixZipName = InstallerDriver.getAsterixZip().substring(
+                InstallerDriver.getAsterixZip().lastIndexOf(File.separator) + 1);
+        String fileToTransfer = new File(InstallerDriver.getAsterixDir() + File.separator + instanceName
+                + File.separator + asterixZipName).getAbsolutePath();
+        String pargs = username + " " + fileToTransfer + " " + destinationIp + " " + destDir + " " + "unpack";
+        Event event = new Event("file_transfer", nodeid, pargs);
+        return new Pattern(null, 1, null, event);
+    }
 
-	private Pattern createCCStartPattern(String hostId) {
-		Nodeid nodeid = new Nodeid(new Value(null, hostId));
-		Event event = new Event("cc_start", nodeid, "");
-		return new Pattern(null, 1, null, event);
-	}
+    private Pattern createCCStartPattern(String hostId) {
+        Nodeid nodeid = new Nodeid(new Value(null, hostId));
+        Event event = new Event("cc_start", nodeid, "");
+        return new Pattern(null, 1, null, event);
+    }
 
-	public Pattern createCCStopPattern(String hostId) {
-		Nodeid nodeid = new Nodeid(new Value(null, hostId));
-		Event event = new Event("cc_failure", nodeid, null);
-		return new Pattern(null, 1, null, event);
-	}
+    public Pattern createCCStopPattern(String hostId) {
+        Nodeid nodeid = new Nodeid(new Value(null, hostId));
+        Event event = new Event("cc_failure", nodeid, null);
+        return new Pattern(null, 1, null, event);
+    }
 
-	public Pattern createNCStartPattern(String ccHost, String hostId,
-			String nodeControllerId) {
-		Nodeid nodeid = new Nodeid(new Value(null, hostId));
-		Event event = new Event("node_join", nodeid, ccHost + " "
-				+ nodeControllerId);
-		return new Pattern(null, 1, null, event);
-	}
+    public Pattern createNCStartPattern(String ccHost, String hostId, String nodeControllerId, String iodevices) {
+        Nodeid nodeid = new Nodeid(new Value(null, hostId));
+        String pargs = ccHost + " " + nodeControllerId + " " + iodevices;
+        Event event = new Event("node_join", nodeid, pargs);
+        return new Pattern(null, 1, null, event);
+    }
 
-	public Pattern createNCStopPattern(String hostId, String nodeControllerId) {
-		Nodeid nodeid = new Nodeid(new Value(null, hostId));
-		Event event = new Event("node_failure", nodeid, nodeControllerId);
-		return new Pattern(null, 1, null, event);
-	}
+    public Pattern createNCStopPattern(String hostId, String nodeControllerId) {
+        Nodeid nodeid = new Nodeid(new Value(null, hostId));
+        Event event = new Event("node_failure", nodeid, nodeControllerId);
+        return new Pattern(null, 1, null, event);
+    }
 
 }
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/model/AsterixInstance.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/model/AsterixInstance.java
index d3ba758..de1dcb3 100644
--- a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/model/AsterixInstance.java
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/model/AsterixInstance.java
@@ -58,7 +58,7 @@
         this.asterixVersion = asterixVersion;
         this.createdTimestamp = new Date();
         this.backupInfo = new ArrayList<BackupInfo>();
-        this.webInterfaceUrl = "http://" + cluster.getMasterNode().getIp() + ":" + 19001;
+        this.webInterfaceUrl = "http://" + cluster.getMasterNode().getClusterIp() + ":" + 19001;
     }
 
     public Date getModifiedTimestamp() {
@@ -155,9 +155,10 @@
     }
 
     private void addDetailedInformation(StringBuffer buffer) {
-        buffer.append("Master node:" + cluster.getMasterNode().getId() + ":" + cluster.getMasterNode().getIp() + "\n");
+        buffer.append("Master node:" + cluster.getMasterNode().getId() + ":" + cluster.getMasterNode().getClusterIp()
+                + "\n");
         for (Node node : cluster.getNode()) {
-            buffer.append(node.getId() + ":" + node.getIp() + "\n");
+            buffer.append(node.getId() + ":" + node.getClusterIp() + "\n");
         }
 
         if (backupInfo != null && backupInfo.size() > 0) {
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/model/ProcessInfo.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/model/ProcessInfo.java
index 2880671..42ee112 100644
--- a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/model/ProcessInfo.java
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/model/ProcessInfo.java
@@ -21,11 +21,13 @@
     private static final long serialVersionUID = 304186774065853730L;
     private final String processName;
     private final String host;
+    private final String nodeId;
     private final int processId;
 
-    public ProcessInfo(String processName, String host, int processId) {
+    public ProcessInfo(String processName, String host, String nodeId, int processId) {
         this.processName = processName;
         this.host = host;
+        this.nodeId = nodeId;
         this.processId = processId;
     }
 
@@ -41,8 +43,12 @@
         return processId;
     }
 
+    public String getNodeId() {
+        return nodeId;
+    }
+
     public String toString() {
-        return processName + " at " + host + " [ " + processId + " ] ";
+        return processName + " at " + nodeId + " [ " + processId + " ] ";
     }
 
 }
diff --git a/asterix-installer/src/main/resources/clusters/local/local.xml b/asterix-installer/src/main/resources/clusters/local/local.xml
index 7a8e78f..b6589d0 100644
--- a/asterix-installer/src/main/resources/clusters/local/local.xml
+++ b/asterix-installer/src/main/resources/clusters/local/local.xml
@@ -1,20 +1,21 @@
 <cluster xmlns="cluster">
   <name>local</name>
   <workingDir>
-     <dir>/tmp/asterix-installer</dir>
-     <NFS>true</NFS> 
+    <dir>/tmp/asterix-installer</dir>
+    <NFS>true</NFS>
   </workingDir>
   <logdir>/tmp/asterix/logs</logdir>
-  <store>/tmp/asterix/storage</store>
+  <iodevices>/tmp</iodevices>
+  <store>asterix/storage</store>
   <java_home></java_home>
   <java_heap>1024m</java_heap>
   <master-node>
-     <id>master</id>
-     <ip>127.0.0.1</ip>
-     <cluster-ip>127.0.0.1</cluster-ip>
+    <id>master</id>
+    <client-ip>127.0.0.1</client-ip>
+    <cluster-ip>127.0.0.1</cluster-ip>
   </master-node>
   <node>
-     <id>node1</id>
-     <ip>127.0.0.1</ip>
+    <id>node1</id>
+    <cluster-ip>127.0.0.1</cluster-ip>
   </node>
 </cluster>
diff --git a/asterix-installer/src/main/resources/conf/managix-conf.xml b/asterix-installer/src/main/resources/conf/managix-conf.xml
index ed3f8a2..10a62a9 100644
--- a/asterix-installer/src/main/resources/conf/managix-conf.xml
+++ b/asterix-installer/src/main/resources/conf/managix-conf.xml
@@ -10,7 +10,7 @@
     <homeDir>/tmp/zookeeper</homeDir>
     <clientPort>2900</clientPort>
     <servers>
-      <server>localhost</server>
+      <server>127.0.0.1</server>
     </servers>
   </zookeeper>
 </configuration>
