Merge asterix_lsm_stabilization into madhusudancs/parallelize_result_distribution.
diff --git a/.gitignore b/.gitignore
index 6d41006..d748fde 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,4 +7,4 @@
 asterix-app/mdtest/
 asterix-app/opttest/
 build
-asterix_logs
+asterix_logs
\ No newline at end of file
diff --git a/asterix-algebra/pom.xml b/asterix-algebra/pom.xml
index 6e24513..350734b 100644
--- a/asterix-algebra/pom.xml
+++ b/asterix-algebra/pom.xml
@@ -3,7 +3,7 @@
 	<parent>
 		<artifactId>asterix</artifactId>
 		<groupId>edu.uci.ics.asterix</groupId>
-		<version>0.0.5-SNAPSHOT</version>
+		<version>0.0.6-SNAPSHOT</version>
 	</parent>
 	<artifactId>asterix-algebra</artifactId>
 
@@ -77,19 +77,19 @@
 		<dependency>
 			<groupId>edu.uci.ics.asterix</groupId>
 			<artifactId>asterix-runtime</artifactId>
-			<version>0.0.5-SNAPSHOT</version>
+			<version>0.0.6-SNAPSHOT</version>
 			<scope>compile</scope>
 		</dependency>
 		<dependency>
 			<groupId>edu.uci.ics.asterix</groupId>
 			<artifactId>asterix-aql</artifactId>
-			<version>0.0.5-SNAPSHOT</version>
+			<version>0.0.6-SNAPSHOT</version>
 			<scope>compile</scope>
 		</dependency>
 		<dependency>
 			<groupId>edu.uci.ics.asterix</groupId>
 			<artifactId>asterix-metadata</artifactId>
-			<version>0.0.5-SNAPSHOT</version>
+			<version>0.0.6-SNAPSHOT</version>
 			<scope>compile</scope>
 		</dependency>
 		<dependency>
diff --git a/asterix-algebra/src/main/java/edu/uci/ics/asterix/algebra/base/LogicalOperatorDeepCopyVisitor.java b/asterix-algebra/src/main/java/edu/uci/ics/asterix/algebra/base/LogicalOperatorDeepCopyVisitor.java
index d8477f1..718c0f1 100644
--- a/asterix-algebra/src/main/java/edu/uci/ics/asterix/algebra/base/LogicalOperatorDeepCopyVisitor.java
+++ b/asterix-algebra/src/main/java/edu/uci/ics/asterix/algebra/base/LogicalOperatorDeepCopyVisitor.java
@@ -20,7 +20,6 @@
 import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.AggregateOperator;
 import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.AssignOperator;
 import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.DataSourceScanOperator;
-import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.DieOperator;
 import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.DistinctOperator;
 import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.DistributeResultOperator;
 import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.EmptyTupleSourceOperator;
@@ -296,11 +295,6 @@
     }
 
     @Override
-    public ILogicalOperator visitDieOperator(DieOperator op, ILogicalOperator arg) {
-        throw new UnsupportedOperationException();
-    }
-
-    @Override
     public ILogicalOperator visitNestedTupleSourceOperator(NestedTupleSourceOperator op, ILogicalOperator arg)
             throws AlgebricksException {
         NestedTupleSourceOperator opCopy = new NestedTupleSourceOperator(new MutableObject<ILogicalOperator>(arg));
diff --git a/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/base/RuleCollections.java b/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/base/RuleCollections.java
index 3f434b7..f14fff8 100644
--- a/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/base/RuleCollections.java
+++ b/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/base/RuleCollections.java
@@ -31,6 +31,7 @@
 import edu.uci.ics.asterix.optimizer.rules.IntroduceDynamicTypeCastRule;
 import edu.uci.ics.asterix.optimizer.rules.IntroduceEnforcedListTypeRule;
 import edu.uci.ics.asterix.optimizer.rules.IntroduceInstantLockSearchCallbackRule;
+import edu.uci.ics.asterix.optimizer.rules.IntroduceRapidFrameFlushProjectRule;
 import edu.uci.ics.asterix.optimizer.rules.IntroduceSecondaryIndexInsertDeleteRule;
 import edu.uci.ics.asterix.optimizer.rules.IntroduceStaticTypeCastRule;
 import edu.uci.ics.asterix.optimizer.rules.LoadRecordFieldsRule;
@@ -80,7 +81,6 @@
 import edu.uci.ics.hyracks.algebricks.rewriter.rules.PullSelectOutOfEqJoin;
 import edu.uci.ics.hyracks.algebricks.rewriter.rules.PushAssignBelowUnionAllRule;
 import edu.uci.ics.hyracks.algebricks.rewriter.rules.PushAssignDownThroughProductRule;
-import edu.uci.ics.hyracks.algebricks.rewriter.rules.PushDieUpRule;
 import edu.uci.ics.hyracks.algebricks.rewriter.rules.PushLimitDownRule;
 import edu.uci.ics.hyracks.algebricks.rewriter.rules.PushNestedOrderByUnderPreSortedGroupByRule;
 import edu.uci.ics.hyracks.algebricks.rewriter.rules.PushProjectDownRule;
@@ -134,7 +134,6 @@
         List<IAlgebraicRewriteRule> condPushDownAndJoinInference = new LinkedList<IAlgebraicRewriteRule>();
 
         condPushDownAndJoinInference.add(new PushSelectDownRule());
-        condPushDownAndJoinInference.add(new PushDieUpRule());
         condPushDownAndJoinInference.add(new RemoveRedundantListifyRule());
         condPushDownAndJoinInference.add(new SimpleUnnestToProductRule());
         condPushDownAndJoinInference.add(new ComplexUnnestToProductRule());
@@ -253,6 +252,7 @@
         physicalRewritesTopLevel.add(new PushLimitDownRule());
         physicalRewritesTopLevel.add(new IntroduceProjectsRule());
         physicalRewritesTopLevel.add(new SetAlgebricksPhysicalOperatorsRule());
+        physicalRewritesTopLevel.add(new IntroduceRapidFrameFlushProjectRule());
         physicalRewritesTopLevel.add(new SetExecutionModeRule());
         return physicalRewritesTopLevel;
     }
diff --git a/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/IntroduceRapidFrameFlushProjectRule.java b/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/IntroduceRapidFrameFlushProjectRule.java
new file mode 100644
index 0000000..d3e11ed2
--- /dev/null
+++ b/asterix-algebra/src/main/java/edu/uci/ics/asterix/optimizer/rules/IntroduceRapidFrameFlushProjectRule.java
@@ -0,0 +1,95 @@
+/*
+ * Copyright 2009-2013 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.optimizer.rules;
+
+import org.apache.commons.lang3.mutable.Mutable;
+
+import edu.uci.ics.asterix.algebra.operators.CommitOperator;
+import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
+import edu.uci.ics.hyracks.algebricks.core.algebra.base.ILogicalOperator;
+import edu.uci.ics.hyracks.algebricks.core.algebra.base.IOptimizationContext;
+import edu.uci.ics.hyracks.algebricks.core.algebra.base.LogicalOperatorTag;
+import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.AbstractLogicalOperator;
+import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.ExtensionOperator;
+import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.ProjectOperator;
+import edu.uci.ics.hyracks.algebricks.core.algebra.operators.physical.StreamProjectPOperator;
+import edu.uci.ics.hyracks.algebricks.core.rewriter.base.IAlgebraicRewriteRule;
+
+/**
+ * This rule will search for project operators in an insert/delete/update plan and
+ * pass a hint to all those projects between the first "insert" and the commit
+ * operator. This hint is used by the project operator so that frames are pushed to
+ * the next operator without waiting until they get full. The purpose of this is to
+ * reduce the time of holding exclusive locks on the keys that have been inserted.
+ * 
+ * @author salsubaiee
+ */
+public class IntroduceRapidFrameFlushProjectRule implements IAlgebraicRewriteRule {
+
+    @Override
+    public boolean rewritePre(Mutable<ILogicalOperator> opRef, IOptimizationContext context) throws AlgebricksException {
+        return false;
+    }
+
+    private boolean checkIfRuleIsApplicable(AbstractLogicalOperator op) {
+        if (op.getOperatorTag() != LogicalOperatorTag.EXTENSION_OPERATOR) {
+            return false;
+        }
+        ExtensionOperator extensionOp = (ExtensionOperator) op;
+        if (!(extensionOp.getDelegate() instanceof CommitOperator)) {
+            return false;
+        }
+
+        AbstractLogicalOperator descendantOp = op;
+        while (descendantOp != null) {
+            if (descendantOp.getOperatorTag() == LogicalOperatorTag.PROJECT) {
+                if (descendantOp.getPhysicalOperator() == null) {
+                    return false;
+                }
+            } else if (descendantOp.getOperatorTag() == LogicalOperatorTag.INSERT_DELETE) {
+                break;
+            }
+            descendantOp = (AbstractLogicalOperator) descendantOp.getInputs().get(0).getValue();
+        }
+        return true;
+    }
+
+    @Override
+    public boolean rewritePost(Mutable<ILogicalOperator> opRef, IOptimizationContext context)
+            throws AlgebricksException {
+
+        AbstractLogicalOperator op = (AbstractLogicalOperator) opRef.getValue();
+
+        if (!checkIfRuleIsApplicable(op)) {
+            return false;
+        }
+        AbstractLogicalOperator descendantOp = op;
+        ProjectOperator projectOp = null;
+
+        boolean planModified = false;
+        while (descendantOp != null) {
+            if (descendantOp.getOperatorTag() == LogicalOperatorTag.PROJECT) {
+                projectOp = (ProjectOperator) descendantOp;
+                StreamProjectPOperator physicalOp = (StreamProjectPOperator) projectOp.getPhysicalOperator();
+                physicalOp.setRapidFrameFlush(true);
+                planModified = true;
+            } else if (descendantOp.getOperatorTag() == LogicalOperatorTag.INSERT_DELETE) {
+                break;
+            }
+            descendantOp = (AbstractLogicalOperator) descendantOp.getInputs().get(0).getValue();
+        }
+        return planModified;
+    }
+}
\ No newline at end of file
diff --git a/asterix-algebra/src/main/java/edu/uci/ics/asterix/translator/AqlExpressionToPlanTranslator.java b/asterix-algebra/src/main/java/edu/uci/ics/asterix/translator/AqlExpressionToPlanTranslator.java
index b6df741..09fc2b9 100644
--- a/asterix-algebra/src/main/java/edu/uci/ics/asterix/translator/AqlExpressionToPlanTranslator.java
+++ b/asterix-algebra/src/main/java/edu/uci/ics/asterix/translator/AqlExpressionToPlanTranslator.java
@@ -22,7 +22,6 @@
 import edu.uci.ics.asterix.aql.expression.DataverseDecl;
 import edu.uci.ics.asterix.aql.expression.DataverseDropStatement;
 import edu.uci.ics.asterix.aql.expression.DeleteStatement;
-import edu.uci.ics.asterix.aql.expression.DieClause;
 import edu.uci.ics.asterix.aql.expression.DistinctClause;
 import edu.uci.ics.asterix.aql.expression.DropStatement;
 import edu.uci.ics.asterix.aql.expression.FLWOGRExpression;
@@ -72,6 +71,7 @@
 import edu.uci.ics.asterix.aql.expression.WriteStatement;
 import edu.uci.ics.asterix.aql.expression.visitor.IAqlExpressionVisitor;
 import edu.uci.ics.asterix.aql.util.FunctionUtils;
+import edu.uci.ics.asterix.common.config.AsterixProperties;
 import edu.uci.ics.asterix.common.config.DatasetConfig.DatasetType;
 import edu.uci.ics.asterix.common.exceptions.AsterixException;
 import edu.uci.ics.asterix.common.functions.FunctionConstants;
@@ -79,7 +79,6 @@
 import edu.uci.ics.asterix.formats.base.IDataFormat;
 import edu.uci.ics.asterix.metadata.MetadataException;
 import edu.uci.ics.asterix.metadata.MetadataManager;
-import edu.uci.ics.asterix.metadata.bootstrap.AsterixProperties;
 import edu.uci.ics.asterix.metadata.declared.AqlDataSource;
 import edu.uci.ics.asterix.metadata.declared.AqlMetadataProvider;
 import edu.uci.ics.asterix.metadata.declared.AqlSourceId;
@@ -124,7 +123,6 @@
 import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.AbstractLogicalOperator;
 import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.AggregateOperator;
 import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.AssignOperator;
-import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.DieOperator;
 import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.DistinctOperator;
 import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.DistributeResultOperator;
 import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.EmptyTupleSourceOperator;
@@ -185,7 +183,6 @@
                 new EmptyTupleSourceOperator()));
 
         ArrayList<Mutable<ILogicalOperator>> globalPlanRoots = new ArrayList<Mutable<ILogicalOperator>>();
-        boolean isTransactionalWrite = false;
         ILogicalOperator topOp = p.first;
         ProjectOperator project = (ProjectOperator) topOp;
         LogicalVariable resVar = project.getVariables().get(0);
@@ -244,7 +241,6 @@
                     insertOp.getInputs().add(new MutableObject<ILogicalOperator>(assign));
                     leafOperator = new SinkOperator();
                     leafOperator.getInputs().add(new MutableObject<ILogicalOperator>(insertOp));
-                    isTransactionalWrite = true;
                     break;
                 }
                 case DELETE: {
@@ -253,7 +249,6 @@
                     deleteOp.getInputs().add(new MutableObject<ILogicalOperator>(assign));
                     leafOperator = new SinkOperator();
                     leafOperator.getInputs().add(new MutableObject<ILogicalOperator>(deleteOp));
-                    isTransactionalWrite = true;
                     break;
                 }
                 case BEGIN_FEED: {
@@ -262,7 +257,6 @@
                     insertOp.getInputs().add(new MutableObject<ILogicalOperator>(assign));
                     leafOperator = new SinkOperator();
                     leafOperator.getInputs().add(new MutableObject<ILogicalOperator>(insertOp));
-                    isTransactionalWrite = false;
                     break;
                 }
             }
@@ -291,12 +285,9 @@
     }
 
     private FileSplit getDefaultOutputFileLocation() throws MetadataException {
-        if (AsterixProperties.INSTANCE.getOutputDir() == null) {
-            throw new MetadataException(
-                    "Output location for query result not specified at the time of deployment, must specify explicitly using 'write output to ..' statement");
-        }
-        String filePath = AsterixProperties.INSTANCE.getOutputDir() + System.getProperty("file.separator")
-                + OUTPUT_FILE_PREFIX + outputFileID.incrementAndGet();
+        String outputDir = System.getProperty("java.io.tmpDir");
+        String filePath = outputDir + System.getProperty("file.separator") + OUTPUT_FILE_PREFIX
+                + outputFileID.incrementAndGet();
         return new FileSplit(AsterixProperties.INSTANCE.getMetadataNodeName(), new FileReference(new File(filePath)));
     }
 
@@ -925,15 +916,6 @@
     }
 
     @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitDieClause(DieClause lc, Mutable<ILogicalOperator> tupSource)
-            throws AsterixException {
-        Pair<ILogicalExpression, Mutable<ILogicalOperator>> p1 = aqlExprToAlgExpression(lc.getDieExpr(), tupSource);
-        DieOperator opDie = new DieOperator(p1.first);
-        opDie.getInputs().add(p1.second);
-        return new Pair<ILogicalOperator, LogicalVariable>(opDie, null);
-    }
-
-    @Override
     public Pair<ILogicalOperator, LogicalVariable> visitDistinctClause(DistinctClause dc,
             Mutable<ILogicalOperator> tupSource) throws AsterixException {
         List<Mutable<ILogicalExpression>> exprList = new ArrayList<Mutable<ILogicalExpression>>();
diff --git a/asterix-algebra/src/main/java/edu/uci/ics/asterix/translator/AqlPlusExpressionToPlanTranslator.java b/asterix-algebra/src/main/java/edu/uci/ics/asterix/translator/AqlPlusExpressionToPlanTranslator.java
index 3440ce8..9f28113 100644
--- a/asterix-algebra/src/main/java/edu/uci/ics/asterix/translator/AqlPlusExpressionToPlanTranslator.java
+++ b/asterix-algebra/src/main/java/edu/uci/ics/asterix/translator/AqlPlusExpressionToPlanTranslator.java
@@ -22,7 +22,6 @@
 import edu.uci.ics.asterix.aql.expression.DataverseDecl;
 import edu.uci.ics.asterix.aql.expression.DataverseDropStatement;
 import edu.uci.ics.asterix.aql.expression.DeleteStatement;
-import edu.uci.ics.asterix.aql.expression.DieClause;
 import edu.uci.ics.asterix.aql.expression.DistinctClause;
 import edu.uci.ics.asterix.aql.expression.DropStatement;
 import edu.uci.ics.asterix.aql.expression.FLWOGRExpression;
@@ -123,7 +122,6 @@
 import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.AbstractLogicalOperator;
 import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.AggregateOperator;
 import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.AssignOperator;
-import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.DieOperator;
 import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.DistinctOperator;
 import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.EmptyTupleSourceOperator;
 import edu.uci.ics.hyracks.algebricks.core.algebra.operators.logical.GroupByOperator;
@@ -192,7 +190,7 @@
     }
 
     private final JobId jobId;
-   private TranslationContext context;
+    private TranslationContext context;
     private String outputDatasetName;
     private ICompiledDmlStatement stmt;
     private AqlMetadataProvider metadataProvider;
@@ -201,8 +199,6 @@
     private MetaScopeILogicalOperator metaScopeOp = new MetaScopeILogicalOperator();
     private static LogicalVariable METADATA_DUMMY_VAR = new LogicalVariable(-1);
 
-    
-    
     public AqlPlusExpressionToPlanTranslator(JobId jobId, AqlMetadataProvider metadataProvider,
             Counter currentVarCounter, String outputDatasetName, ICompiledDmlStatement stmt) {
         this.jobId = jobId;
@@ -221,8 +217,8 @@
         return translate(expr, null);
     }
 
-    public ILogicalPlan translate(Query expr, AqlMetadataProvider metadata)
-            throws AlgebricksException, AsterixException {
+    public ILogicalPlan translate(Query expr, AqlMetadataProvider metadata) throws AlgebricksException,
+            AsterixException {
         IDataFormat format = metadata.getFormat();
         if (format == null) {
             throw new AlgebricksException("Data format has not been set.");
@@ -877,15 +873,6 @@
     }
 
     @Override
-    public Pair<ILogicalOperator, LogicalVariable> visitDieClause(DieClause lc, Mutable<ILogicalOperator> tupSource)
-            throws AsterixException {
-        Pair<ILogicalExpression, Mutable<ILogicalOperator>> p1 = aqlExprToAlgExpression(lc.getDieExpr(), tupSource);
-        DieOperator opDie = new DieOperator(p1.first);
-        opDie.getInputs().add(p1.second);
-        return new Pair<ILogicalOperator, LogicalVariable>(opDie, null);
-    }
-
-    @Override
     public Pair<ILogicalOperator, LogicalVariable> visitDistinctClause(DistinctClause dc,
             Mutable<ILogicalOperator> tupSource) throws AsterixException {
         List<Mutable<ILogicalExpression>> exprList = new ArrayList<Mutable<ILogicalExpression>>();
diff --git a/asterix-algebra/src/main/java/edu/uci/ics/asterix/translator/CompiledStatements.java b/asterix-algebra/src/main/java/edu/uci/ics/asterix/translator/CompiledStatements.java
index 625fed1..6cf8d28 100644
--- a/asterix-algebra/src/main/java/edu/uci/ics/asterix/translator/CompiledStatements.java
+++ b/asterix-algebra/src/main/java/edu/uci/ics/asterix/translator/CompiledStatements.java
@@ -49,527 +49,490 @@
  */
 public class CompiledStatements {
 
-	public static interface ICompiledStatement {
+    public static interface ICompiledStatement {
 
-		public Kind getKind();
-	}
+        public Kind getKind();
+    }
 
-	public static class CompiledWriteFromQueryResultStatement implements
-			ICompiledDmlStatement {
+    public static class CompiledWriteFromQueryResultStatement implements ICompiledDmlStatement {
 
-		private String dataverseName;
-		private String datasetName;
-		private Query query;
-		private int varCounter;
+        private String dataverseName;
+        private String datasetName;
+        private Query query;
+        private int varCounter;
 
-		public CompiledWriteFromQueryResultStatement(String dataverseName,
-				String datasetName, Query query, int varCounter) {
-			this.dataverseName = dataverseName;
-			this.datasetName = datasetName;
-			this.query = query;
-			this.varCounter = varCounter;
-		}
+        public CompiledWriteFromQueryResultStatement(String dataverseName, String datasetName, Query query,
+                int varCounter) {
+            this.dataverseName = dataverseName;
+            this.datasetName = datasetName;
+            this.query = query;
+            this.varCounter = varCounter;
+        }
 
-		public String getDataverseName() {
-			return dataverseName;
-		}
+        public String getDataverseName() {
+            return dataverseName;
+        }
 
-		public String getDatasetName() {
-			return datasetName;
-		}
+        public String getDatasetName() {
+            return datasetName;
+        }
 
-		public int getVarCounter() {
-			return varCounter;
-		}
+        public int getVarCounter() {
+            return varCounter;
+        }
 
-		public Query getQuery() {
-			return query;
-		}
+        public Query getQuery() {
+            return query;
+        }
 
-		@Override
-		public Kind getKind() {
-			return Kind.WRITE_FROM_QUERY_RESULT;
-		}
+        @Override
+        public Kind getKind() {
+            return Kind.WRITE_FROM_QUERY_RESULT;
+        }
 
-	}
+    }
 
-	public static class CompiledDatasetDropStatement implements
-			ICompiledStatement {
-		private final String dataverseName;
-		private final String datasetName;
+    public static class CompiledDatasetDropStatement implements ICompiledStatement {
+        private final String dataverseName;
+        private final String datasetName;
 
-		public CompiledDatasetDropStatement(String dataverseName,
-				String datasetName) {
-			this.dataverseName = dataverseName;
-			this.datasetName = datasetName;
-		}
+        public CompiledDatasetDropStatement(String dataverseName, String datasetName) {
+            this.dataverseName = dataverseName;
+            this.datasetName = datasetName;
+        }
 
-		public String getDataverseName() {
-			return dataverseName;
-		}
+        public String getDataverseName() {
+            return dataverseName;
+        }
 
-		public String getDatasetName() {
-			return datasetName;
-		}
+        public String getDatasetName() {
+            return datasetName;
+        }
 
-		@Override
-		public Kind getKind() {
-			return Kind.DATASET_DROP;
-		}
-	}
+        @Override
+        public Kind getKind() {
+            return Kind.DATASET_DROP;
+        }
+    }
 
-	// added by yasser
-	public static class CompiledCreateDataverseStatement implements
-			ICompiledStatement {
-		private String dataverseName;
-		private String format;
+    // added by yasser
+    public static class CompiledCreateDataverseStatement implements ICompiledStatement {
+        private String dataverseName;
+        private String format;
 
-		public CompiledCreateDataverseStatement(String dataverseName,
-				String format) {
-			this.dataverseName = dataverseName;
-			this.format = format;
-		}
+        public CompiledCreateDataverseStatement(String dataverseName, String format) {
+            this.dataverseName = dataverseName;
+            this.format = format;
+        }
 
-		public String getDataverseName() {
-			return dataverseName;
-		}
+        public String getDataverseName() {
+            return dataverseName;
+        }
 
-		public String getFormat() {
-			return format;
-		}
+        public String getFormat() {
+            return format;
+        }
 
-		@Override
-		public Kind getKind() {
-			return Kind.CREATE_DATAVERSE;
-		}
-	}
+        @Override
+        public Kind getKind() {
+            return Kind.CREATE_DATAVERSE;
+        }
+    }
 
-	public static class CompiledNodeGroupDropStatement implements
-			ICompiledStatement {
-		private String nodeGroupName;
+    public static class CompiledNodeGroupDropStatement implements ICompiledStatement {
+        private String nodeGroupName;
 
-		public CompiledNodeGroupDropStatement(String nodeGroupName) {
-			this.nodeGroupName = nodeGroupName;
-		}
+        public CompiledNodeGroupDropStatement(String nodeGroupName) {
+            this.nodeGroupName = nodeGroupName;
+        }
 
-		public String getNodeGroupName() {
-			return nodeGroupName;
-		}
+        public String getNodeGroupName() {
+            return nodeGroupName;
+        }
 
-		@Override
-		public Kind getKind() {
-			return Kind.NODEGROUP_DROP;
-		}
-	}
+        @Override
+        public Kind getKind() {
+            return Kind.NODEGROUP_DROP;
+        }
+    }
 
-	public static class CompiledIndexDropStatement implements
-			ICompiledStatement {
-		private String dataverseName;
-		private String datasetName;
-		private String indexName;
+    public static class CompiledIndexDropStatement implements ICompiledStatement {
+        private String dataverseName;
+        private String datasetName;
+        private String indexName;
 
-		public CompiledIndexDropStatement(String dataverseName,
-				String datasetName, String indexName) {
-			this.dataverseName = dataverseName;
-			this.datasetName = datasetName;
-			this.indexName = indexName;
-		}
+        public CompiledIndexDropStatement(String dataverseName, String datasetName, String indexName) {
+            this.dataverseName = dataverseName;
+            this.datasetName = datasetName;
+            this.indexName = indexName;
+        }
 
-		public String getDataverseName() {
-			return dataverseName;
-		}
+        public String getDataverseName() {
+            return dataverseName;
+        }
 
-		public String getDatasetName() {
-			return datasetName;
-		}
+        public String getDatasetName() {
+            return datasetName;
+        }
 
-		public String getIndexName() {
-			return indexName;
-		}
+        public String getIndexName() {
+            return indexName;
+        }
 
-		@Override
-		public Kind getKind() {
-			return Kind.INDEX_DROP;
-		}
-	}
+        @Override
+        public Kind getKind() {
+            return Kind.INDEX_DROP;
+        }
+    }
 
-	public static class CompiledDataverseDropStatement implements
-			ICompiledStatement {
-		private String dataverseName;
-		private boolean ifExists;
+    public static class CompiledDataverseDropStatement implements ICompiledStatement {
+        private String dataverseName;
+        private boolean ifExists;
 
-		public CompiledDataverseDropStatement(String dataverseName,
-				boolean ifExists) {
-			this.dataverseName = dataverseName;
-			this.ifExists = ifExists;
-		}
+        public CompiledDataverseDropStatement(String dataverseName, boolean ifExists) {
+            this.dataverseName = dataverseName;
+            this.ifExists = ifExists;
+        }
 
-		public String getDataverseName() {
-			return dataverseName;
-		}
+        public String getDataverseName() {
+            return dataverseName;
+        }
 
-		public boolean getIfExists() {
-			return ifExists;
-		}
+        public boolean getIfExists() {
+            return ifExists;
+        }
 
-		@Override
-		public Kind getKind() {
-			return Kind.DATAVERSE_DROP;
-		}
-	}
+        @Override
+        public Kind getKind() {
+            return Kind.DATAVERSE_DROP;
+        }
+    }
 
-	public static class CompiledTypeDropStatement implements ICompiledStatement {
-		private String typeName;
+    public static class CompiledTypeDropStatement implements ICompiledStatement {
+        private String typeName;
 
-		public CompiledTypeDropStatement(String nodeGroupName) {
-			this.typeName = nodeGroupName;
-		}
+        public CompiledTypeDropStatement(String nodeGroupName) {
+            this.typeName = nodeGroupName;
+        }
 
-		public String getTypeName() {
-			return typeName;
-		}
+        public String getTypeName() {
+            return typeName;
+        }
 
-		@Override
-		public Kind getKind() {
-			return Kind.TYPE_DROP;
-		}
-	}
+        @Override
+        public Kind getKind() {
+            return Kind.TYPE_DROP;
+        }
+    }
 
-	public static interface ICompiledDmlStatement extends ICompiledStatement {
+    public static interface ICompiledDmlStatement extends ICompiledStatement {
 
-		public String getDataverseName();
+        public String getDataverseName();
 
-		public String getDatasetName();
-	}
+        public String getDatasetName();
+    }
 
-	public static class CompiledCreateIndexStatement implements
-			ICompiledDmlStatement {
-		private final String indexName;
-		private final String dataverseName;
-		private final String datasetName;
-		private final List<String> keyFields;
-		private final IndexType indexType;
+    public static class CompiledCreateIndexStatement implements ICompiledDmlStatement {
+        private final String indexName;
+        private final String dataverseName;
+        private final String datasetName;
+        private final List<String> keyFields;
+        private final IndexType indexType;
 
-		// Specific to NGram index.
-		private final int gramLength;
+        // Specific to NGram index.
+        private final int gramLength;
 
-		public CompiledCreateIndexStatement(String indexName,
-				String dataverseName, String datasetName,
-				List<String> keyFields, int gramLength, IndexType indexType) {
-			this.indexName = indexName;
-			this.dataverseName = dataverseName;
-			this.datasetName = datasetName;
-			this.keyFields = keyFields;
-			this.gramLength = gramLength;
-			this.indexType = indexType;
-		}
+        public CompiledCreateIndexStatement(String indexName, String dataverseName, String datasetName,
+                List<String> keyFields, int gramLength, IndexType indexType) {
+            this.indexName = indexName;
+            this.dataverseName = dataverseName;
+            this.datasetName = datasetName;
+            this.keyFields = keyFields;
+            this.gramLength = gramLength;
+            this.indexType = indexType;
+        }
 
-		public String getDatasetName() {
-			return datasetName;
-		}
+        public String getDatasetName() {
+            return datasetName;
+        }
 
-		public String getDataverseName() {
-			return dataverseName;
-		}
+        public String getDataverseName() {
+            return dataverseName;
+        }
 
-		public String getIndexName() {
-			return indexName;
-		}
+        public String getIndexName() {
+            return indexName;
+        }
 
-		public List<String> getKeyFields() {
-			return keyFields;
-		}
+        public List<String> getKeyFields() {
+            return keyFields;
+        }
 
-		public IndexType getIndexType() {
-			return indexType;
-		}
+        public IndexType getIndexType() {
+            return indexType;
+        }
 
-		public int getGramLength() {
-			return gramLength;
-		}
+        public int getGramLength() {
+            return gramLength;
+        }
 
-		@Override
-		public Kind getKind() {
-			return Kind.CREATE_INDEX;
-		}
-	}
+        @Override
+        public Kind getKind() {
+            return Kind.CREATE_INDEX;
+        }
+    }
 
-	public static class CompiledLoadFromFileStatement implements
-			ICompiledDmlStatement {
-		private String dataverseName;
-		private String datasetName;
-		private boolean alreadySorted;
-		private String adapter;
-		private Map<String, String> properties;
+    public static class CompiledLoadFromFileStatement implements ICompiledDmlStatement {
+        private String dataverseName;
+        private String datasetName;
+        private boolean alreadySorted;
+        private String adapter;
+        private Map<String, String> properties;
 
-		public CompiledLoadFromFileStatement(String dataverseName,
-				String datasetName, String adapter,
-				Map<String, String> properties, boolean alreadySorted) {
-			this.dataverseName = dataverseName;
-			this.datasetName = datasetName;
-			this.alreadySorted = alreadySorted;
-			this.adapter = adapter;
-			this.properties = properties;
-		}
+        public CompiledLoadFromFileStatement(String dataverseName, String datasetName, String adapter,
+                Map<String, String> properties, boolean alreadySorted) {
+            this.dataverseName = dataverseName;
+            this.datasetName = datasetName;
+            this.alreadySorted = alreadySorted;
+            this.adapter = adapter;
+            this.properties = properties;
+        }
 
-		public String getDataverseName() {
-			return dataverseName;
-		}
-
-		public String getDatasetName() {
-			return datasetName;
-		}
+        public String getDataverseName() {
+            return dataverseName;
+        }
 
-		public boolean alreadySorted() {
-			return alreadySorted;
-		}
+        public String getDatasetName() {
+            return datasetName;
+        }
 
-		public String getAdapter() {
-			return adapter;
-		}
+        public boolean alreadySorted() {
+            return alreadySorted;
+        }
 
-		public Map<String, String> getProperties() {
-			return properties;
-		}
+        public String getAdapter() {
+            return adapter;
+        }
 
-		@Override
-		public Kind getKind() {
-			return Kind.LOAD_FROM_FILE;
-		}
-	}
+        public Map<String, String> getProperties() {
+            return properties;
+        }
 
-	public static class CompiledInsertStatement implements
-			ICompiledDmlStatement {
-		private final String dataverseName;
-		private final String datasetName;
-		private final Query query;
-		private final int varCounter;
+        @Override
+        public Kind getKind() {
+            return Kind.LOAD_FROM_FILE;
+        }
+    }
 
-		public CompiledInsertStatement(String dataverseName,
-				String datasetName, Query query, int varCounter) {
-			this.dataverseName = dataverseName;
-			this.datasetName = datasetName;
-			this.query = query;
-			this.varCounter = varCounter;
-		}
+    public static class CompiledInsertStatement implements ICompiledDmlStatement {
+        private final String dataverseName;
+        private final String datasetName;
+        private final Query query;
+        private final int varCounter;
 
-		public String getDataverseName() {
-			return dataverseName;
-		}
+        public CompiledInsertStatement(String dataverseName, String datasetName, Query query, int varCounter) {
+            this.dataverseName = dataverseName;
+            this.datasetName = datasetName;
+            this.query = query;
+            this.varCounter = varCounter;
+        }
 
-		public String getDatasetName() {
-			return datasetName;
-		}
+        public String getDataverseName() {
+            return dataverseName;
+        }
 
-		public int getVarCounter() {
-			return varCounter;
-		}
+        public String getDatasetName() {
+            return datasetName;
+        }
 
-		public Query getQuery() {
-			return query;
-		}
+        public int getVarCounter() {
+            return varCounter;
+        }
 
-		@Override
-		public Kind getKind() {
-			return Kind.INSERT;
-		}
-	}
+        public Query getQuery() {
+            return query;
+        }
 
-	public static class CompiledBeginFeedStatement implements
-			ICompiledDmlStatement {
-		private String dataverseName;
-		private String datasetName;
-		private Query query;
-		private int varCounter;
+        @Override
+        public Kind getKind() {
+            return Kind.INSERT;
+        }
+    }
 
-		public CompiledBeginFeedStatement(String dataverseName,
-				String datasetName, Query query, int varCounter) {
-			this.dataverseName = dataverseName;
-			this.datasetName = datasetName;
-			this.query = query;
-			this.varCounter = varCounter;
-		}
+    public static class CompiledBeginFeedStatement implements ICompiledDmlStatement {
+        private String dataverseName;
+        private String datasetName;
+        private Query query;
+        private int varCounter;
 
-		@Override
-		public String getDataverseName() {
-			return dataverseName;
-		}
+        public CompiledBeginFeedStatement(String dataverseName, String datasetName, Query query, int varCounter) {
+            this.dataverseName = dataverseName;
+            this.datasetName = datasetName;
+            this.query = query;
+            this.varCounter = varCounter;
+        }
 
-		@Override
-		public String getDatasetName() {
-			return datasetName;
-		}
+        @Override
+        public String getDataverseName() {
+            return dataverseName;
+        }
 
-		public int getVarCounter() {
-			return varCounter;
-		}
+        @Override
+        public String getDatasetName() {
+            return datasetName;
+        }
 
-		public Query getQuery() {
-			return query;
-		}
+        public int getVarCounter() {
+            return varCounter;
+        }
 
-		public void setQuery(Query query) {
-			this.query = query;
-		}
+        public Query getQuery() {
+            return query;
+        }
 
-		@Override
-		public Kind getKind() {
-			return Kind.BEGIN_FEED;
-		}
-	}
+        public void setQuery(Query query) {
+            this.query = query;
+        }
 
-	public static class CompiledControlFeedStatement implements
-			ICompiledDmlStatement {
-		private String dataverseName;
-		private String datasetName;
-		private OperationType operationType;
-		private Query query;
-		private int varCounter;
-		private Map<String, String> alteredParams;
+        @Override
+        public Kind getKind() {
+            return Kind.BEGIN_FEED;
+        }
+    }
 
-		public CompiledControlFeedStatement(OperationType operationType,
-				String dataverseName, String datasetName,
-				Map<String, String> alteredParams) {
-			this.dataverseName = dataverseName;
-			this.datasetName = datasetName;
-			this.operationType = operationType;
-			this.alteredParams = alteredParams;
-		}
+    public static class CompiledControlFeedStatement implements ICompiledDmlStatement {
+        private String dataverseName;
+        private String datasetName;
+        private OperationType operationType;
+        private Query query;
+        private int varCounter;
+        private Map<String, String> alteredParams;
 
-		@Override
-		public String getDataverseName() {
-			return dataverseName;
-		}
+        public CompiledControlFeedStatement(OperationType operationType, String dataverseName, String datasetName,
+                Map<String, String> alteredParams) {
+            this.dataverseName = dataverseName;
+            this.datasetName = datasetName;
+            this.operationType = operationType;
+            this.alteredParams = alteredParams;
+        }
 
-		@Override
-		public String getDatasetName() {
-			return datasetName;
-		}
+        @Override
+        public String getDataverseName() {
+            return dataverseName;
+        }
 
-		public OperationType getOperationType() {
-			return operationType;
-		}
+        @Override
+        public String getDatasetName() {
+            return datasetName;
+        }
 
-		public int getVarCounter() {
-			return varCounter;
-		}
+        public OperationType getOperationType() {
+            return operationType;
+        }
 
-		public Query getQuery() {
-			return query;
-		}
+        public int getVarCounter() {
+            return varCounter;
+        }
 
-		@Override
-		public Kind getKind() {
-			return Kind.CONTROL_FEED;
-		}
+        public Query getQuery() {
+            return query;
+        }
 
-		public Map<String, String> getProperties() {
-			return alteredParams;
-		}
+        @Override
+        public Kind getKind() {
+            return Kind.CONTROL_FEED;
+        }
 
-		public void setProperties(Map<String, String> properties) {
-			this.alteredParams = properties;
-		}
-	}
+        public Map<String, String> getProperties() {
+            return alteredParams;
+        }
 
-	public static class CompiledDeleteStatement implements
-			ICompiledDmlStatement {
-		private VariableExpr var;
-		private String dataverseName;
-		private String datasetName;
-		private Expression condition;
-		private Clause dieClause;
-		private int varCounter;
-		private AqlMetadataProvider metadataProvider;
+        public void setProperties(Map<String, String> properties) {
+            this.alteredParams = properties;
+        }
+    }
 
-		public CompiledDeleteStatement(VariableExpr var, String dataverseName,
-				String datasetName, Expression condition, Clause dieClause,
-				int varCounter, AqlMetadataProvider metadataProvider) {
-			this.var = var;
-			this.dataverseName = dataverseName;
-			this.datasetName = datasetName;
-			this.condition = condition;
-			this.dieClause = dieClause;
-			this.varCounter = varCounter;
-			this.metadataProvider = metadataProvider;
-		}
+    public static class CompiledDeleteStatement implements ICompiledDmlStatement {
+        private VariableExpr var;
+        private String dataverseName;
+        private String datasetName;
+        private Expression condition;
+        private int varCounter;
+        private AqlMetadataProvider metadataProvider;
 
-		@Override
-		public String getDatasetName() {
-			return datasetName;
-		}
+        public CompiledDeleteStatement(VariableExpr var, String dataverseName, String datasetName,
+                Expression condition, int varCounter, AqlMetadataProvider metadataProvider) {
+            this.var = var;
+            this.dataverseName = dataverseName;
+            this.datasetName = datasetName;
+            this.condition = condition;
+            this.varCounter = varCounter;
+            this.metadataProvider = metadataProvider;
+        }
 
-		@Override
-		public String getDataverseName() {
-			return dataverseName;
-		}
+        @Override
+        public String getDatasetName() {
+            return datasetName;
+        }
 
-		public int getVarCounter() {
-			return varCounter;
-		}
+        @Override
+        public String getDataverseName() {
+            return dataverseName;
+        }
 
-		public Expression getCondition() {
-			return condition;
-		}
+        public int getVarCounter() {
+            return varCounter;
+        }
 
-		public Clause getDieClause() {
-			return dieClause;
-		}
+        public Expression getCondition() {
+            return condition;
+        }
 
-		public Query getQuery() throws AlgebricksException {
+        public Query getQuery() throws AlgebricksException {
 
-			List<Expression> arguments = new ArrayList<Expression>();
-			String arg = dataverseName == null ? datasetName : dataverseName
-					+ "." + datasetName;
-			LiteralExpr argumentLiteral = new LiteralExpr(
-					new StringLiteral(arg));
-			arguments.add(argumentLiteral);
+            List<Expression> arguments = new ArrayList<Expression>();
+            String arg = dataverseName == null ? datasetName : dataverseName + "." + datasetName;
+            LiteralExpr argumentLiteral = new LiteralExpr(new StringLiteral(arg));
+            arguments.add(argumentLiteral);
 
-			CallExpr callExpression = new CallExpr(new FunctionSignature(
-					FunctionConstants.ASTERIX_NS, "dataset", 1), arguments);
-			List<Clause> clauseList = new ArrayList<Clause>();
-			Clause forClause = new ForClause(var, callExpression);
-			clauseList.add(forClause);
-			Clause whereClause = null;
-			if (condition != null) {
-				whereClause = new WhereClause(condition);
-				clauseList.add(whereClause);
-			}
-			if (dieClause != null) {
-				clauseList.add(dieClause);
-			}
+            CallExpr callExpression = new CallExpr(new FunctionSignature(FunctionConstants.ASTERIX_NS, "dataset", 1),
+                    arguments);
+            List<Clause> clauseList = new ArrayList<Clause>();
+            Clause forClause = new ForClause(var, callExpression);
+            clauseList.add(forClause);
+            Clause whereClause = null;
+            if (condition != null) {
+                whereClause = new WhereClause(condition);
+                clauseList.add(whereClause);
+            }
 
-			Dataset dataset = metadataProvider.findDataset(dataverseName,
-					datasetName);
-			if (dataset == null) {
-				throw new AlgebricksException("Unknown dataset " + datasetName);
-			}
-			String itemTypeName = dataset.getItemTypeName();
-			IAType itemType = metadataProvider.findType(
-					dataset.getDataverseName(), itemTypeName);
-			ARecordType recType = (ARecordType) itemType;
-			String[] fieldNames = recType.getFieldNames();
-			List<FieldBinding> fieldBindings = new ArrayList<FieldBinding>();
-			for (int i = 0; i < fieldNames.length; i++) {
-				FieldAccessor fa = new FieldAccessor(var, new Identifier(
-						fieldNames[i]));
-				FieldBinding fb = new FieldBinding(new LiteralExpr(
-						new StringLiteral(fieldNames[i])), fa);
-				fieldBindings.add(fb);
-			}
-			RecordConstructor rc = new RecordConstructor(fieldBindings);
+            Dataset dataset = metadataProvider.findDataset(dataverseName, datasetName);
+            if (dataset == null) {
+                throw new AlgebricksException("Unknown dataset " + datasetName);
+            }
+            String itemTypeName = dataset.getItemTypeName();
+            IAType itemType = metadataProvider.findType(dataset.getDataverseName(), itemTypeName);
+            ARecordType recType = (ARecordType) itemType;
+            String[] fieldNames = recType.getFieldNames();
+            List<FieldBinding> fieldBindings = new ArrayList<FieldBinding>();
+            for (int i = 0; i < fieldNames.length; i++) {
+                FieldAccessor fa = new FieldAccessor(var, new Identifier(fieldNames[i]));
+                FieldBinding fb = new FieldBinding(new LiteralExpr(new StringLiteral(fieldNames[i])), fa);
+                fieldBindings.add(fb);
+            }
+            RecordConstructor rc = new RecordConstructor(fieldBindings);
 
-			FLWOGRExpression flowgr = new FLWOGRExpression(clauseList, rc);
-			Query query = new Query();
-			query.setBody(flowgr);
-			return query;
-		}
+            FLWOGRExpression flowgr = new FLWOGRExpression(clauseList, rc);
+            Query query = new Query();
+            query.setBody(flowgr);
+            return query;
+        }
 
-		@Override
-		public Kind getKind() {
-			return Kind.DELETE;
-		}
+        @Override
+        public Kind getKind() {
+            return Kind.DELETE;
+        }
 
-	}
+    }
 
 }
diff --git a/asterix-app/pom.xml b/asterix-app/pom.xml
index 48c4ee5..15af3bc 100644
--- a/asterix-app/pom.xml
+++ b/asterix-app/pom.xml
@@ -3,7 +3,7 @@
 	<parent>
 		<artifactId>asterix</artifactId>
 		<groupId>edu.uci.ics.asterix</groupId>
-		<version>0.0.5-SNAPSHOT</version>
+		<version>0.0.6-SNAPSHOT</version>
 	</parent>
 	<artifactId>asterix-app</artifactId>
 
@@ -94,7 +94,7 @@
 		<dependency>
 			<groupId>edu.uci.ics.asterix</groupId>
 			<artifactId>asterix-algebra</artifactId>
-			<version>0.0.5-SNAPSHOT</version>
+			<version>0.0.6-SNAPSHOT</version>
 			<scope>compile</scope>
 		</dependency>
 		<dependency>
@@ -143,44 +143,45 @@
 		<dependency>
 			<groupId>edu.uci.ics.asterix</groupId>
 			<artifactId>asterix-aql</artifactId>
-			<version>0.0.5-SNAPSHOT</version>
+			<version>0.0.6-SNAPSHOT</version>
 			<type>jar</type>
 			<scope>compile</scope>
 		</dependency>
 		<dependency>
 			<groupId>edu.uci.ics.asterix</groupId>
 			<artifactId>asterix-om</artifactId>
-			<version>0.0.5-SNAPSHOT</version>
+			<version>0.0.6-SNAPSHOT</version>
 			<type>jar</type>
 			<scope>compile</scope>
 		</dependency>
 		<dependency>
 			<groupId>edu.uci.ics.asterix</groupId>
 			<artifactId>asterix-metadata</artifactId>
-			<version>0.0.5-SNAPSHOT</version>
+			<version>0.0.6-SNAPSHOT</version>
 			<type>jar</type>
 			<scope>compile</scope>
 		</dependency>
 		<dependency>
 			<groupId>edu.uci.ics.asterix</groupId>
 			<artifactId>asterix-tools</artifactId>
-			<version>0.0.5-SNAPSHOT</version>
+			<version>0.0.6-SNAPSHOT</version>
 			<type>jar</type>
 			<scope>compile</scope>
 		</dependency>
 		<dependency>
 			<groupId>edu.uci.ics.asterix</groupId>
 			<artifactId>asterix-common</artifactId>
-			<version>0.0.5-SNAPSHOT</version>
+			<version>0.0.6-SNAPSHOT</version>
 			<type>jar</type>
 			<scope>compile</scope>
 		</dependency>
-		<dependency>
-			<groupId>com.kenai.nbpwr</groupId>
-			<artifactId>org-apache-commons-io</artifactId>
-			<version>1.3.1-201002241208</version>
-			<scope>test</scope>
-		</dependency>
+                <dependency>
+                        <groupId>edu.uci.ics.asterix</groupId>
+                        <artifactId>asterix-common</artifactId>
+                        <version>0.0.6-SNAPSHOT</version>
+                        <type>test-jar</type>
+                        <scope>test</scope>
+                </dependency>
 		<dependency>
 			<groupId>org.apache.hadoop</groupId>
 			<artifactId>hadoop-core</artifactId>
@@ -216,7 +217,7 @@
                 <dependency>
                 	<groupId>edu.uci.ics.asterix</groupId>
                 	<artifactId>asterix-test-framework</artifactId>
-                	<version>0.0.5-SNAPSHOT</version>
+                	<version>0.0.6-SNAPSHOT</version>
                 	<scope>test</scope>
                 </dependency>
 	</dependencies>
diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/api/http/servlet/RESTAPIServlet.java b/asterix-app/src/main/java/edu/uci/ics/asterix/api/http/servlet/RESTAPIServlet.java
index 29feb5e..2c15578 100644
--- a/asterix-app/src/main/java/edu/uci/ics/asterix/api/http/servlet/RESTAPIServlet.java
+++ b/asterix-app/src/main/java/edu/uci/ics/asterix/api/http/servlet/RESTAPIServlet.java
@@ -17,6 +17,7 @@
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.util.List;
+import java.util.logging.Level;
 
 import javax.servlet.ServletContext;
 import javax.servlet.http.HttpServlet;
@@ -32,6 +33,7 @@
 import edu.uci.ics.asterix.aql.parser.AQLParser;
 import edu.uci.ics.asterix.aql.parser.ParseException;
 import edu.uci.ics.asterix.aql.translator.AqlTranslator;
+import edu.uci.ics.asterix.common.config.GlobalConfig;
 import edu.uci.ics.asterix.metadata.MetadataManager;
 import edu.uci.ics.asterix.result.ResultReader;
 import edu.uci.ics.asterix.result.ResultUtils;
@@ -95,6 +97,7 @@
             aqlTranslator.compileAndExecute(hcc, hds, asyncResults);
 
         } catch (ParseException pe) {
+            GlobalConfig.ASTERIX_LOGGER.log(Level.INFO, pe.getMessage(), pe);
             StringBuilder errorMessage = new StringBuilder();
             String message = pe.getMessage();
             message = message.replace("<", "&lt");
@@ -110,6 +113,7 @@
             JSONObject errorResp = ResultUtils.getErrorResponse(2, errorMessage.toString());
             out.write(errorResp.toString());
         } catch (Exception e) {
+            GlobalConfig.ASTERIX_LOGGER.log(Level.INFO, e.getMessage(), e);
             StringBuilder errorMessage = new StringBuilder();
             errorMessage.append(e.getMessage());
             JSONObject errorResp = ResultUtils.getErrorResponse(99, errorMessage.toString());
diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/aql/translator/AqlTranslator.java b/asterix-app/src/main/java/edu/uci/ics/asterix/aql/translator/AqlTranslator.java
index 976ec7c..428781f 100644
--- a/asterix-app/src/main/java/edu/uci/ics/asterix/aql/translator/AqlTranslator.java
+++ b/asterix-app/src/main/java/edu/uci/ics/asterix/aql/translator/AqlTranslator.java
@@ -82,6 +82,7 @@
 import edu.uci.ics.asterix.metadata.entities.Index;
 import edu.uci.ics.asterix.metadata.entities.InternalDatasetDetails;
 import edu.uci.ics.asterix.metadata.entities.NodeGroup;
+import edu.uci.ics.asterix.om.types.ARecordType;
 import edu.uci.ics.asterix.om.types.ATypeTag;
 import edu.uci.ics.asterix.om.types.IAType;
 import edu.uci.ics.asterix.om.types.TypeSignature;
@@ -122,6 +123,11 @@
  */
 public class AqlTranslator extends AbstractAqlTranslator {
 
+    private enum ProgressState {
+        NO_PROGRESS,
+        ADDED_PENDINGOP_RECORD_TO_METADATA
+    }
+
     private final List<Statement> aqlStatements;
     private final PrintWriter out;
     private final SessionConfig sessionConfig;
@@ -310,7 +316,7 @@
     }
 
     private Dataverse handleUseDataverseStatement(AqlMetadataProvider metadataProvider, Statement stmt)
-            throws MetadataException, RemoteException, ACIDException {
+            throws Exception {
 
         MetadataTransactionContext mdTxnCtx = MetadataManager.INSTANCE.beginTransaction();
         metadataProvider.setMetadataTxnContext(mdTxnCtx);
@@ -326,15 +332,14 @@
             MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
             return dv;
         } catch (Exception e) {
-            MetadataManager.INSTANCE.abortTransaction(mdTxnCtx);
+            abort(e, e, mdTxnCtx);
             throw new MetadataException(e);
         } finally {
             releaseReadLatch();
         }
     }
 
-    private void handleCreateDataverseStatement(AqlMetadataProvider metadataProvider, Statement stmt)
-            throws MetadataException, AlgebricksException, RemoteException, ACIDException {
+    private void handleCreateDataverseStatement(AqlMetadataProvider metadataProvider, Statement stmt) throws Exception {
 
         MetadataTransactionContext mdTxnCtx = MetadataManager.INSTANCE.beginTransaction();
         metadataProvider.setMetadataTxnContext(mdTxnCtx);
@@ -344,14 +349,19 @@
             CreateDataverseStatement stmtCreateDataverse = (CreateDataverseStatement) stmt;
             String dvName = stmtCreateDataverse.getDataverseName().getValue();
             Dataverse dv = MetadataManager.INSTANCE.getDataverse(metadataProvider.getMetadataTxnContext(), dvName);
-            if (dv != null && !stmtCreateDataverse.getIfNotExists()) {
-                throw new AlgebricksException("A dataverse with this name " + dvName + " already exists.");
+            if (dv != null) {
+                if (stmtCreateDataverse.getIfNotExists()) {
+                    MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
+                    return;
+                } else {
+                    throw new AlgebricksException("A dataverse with this name " + dvName + " already exists.");
+                }
             }
             MetadataManager.INSTANCE.addDataverse(metadataProvider.getMetadataTxnContext(), new Dataverse(dvName,
                     stmtCreateDataverse.getFormat(), IMetadataEntity.PENDING_NO_OP));
             MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
         } catch (Exception e) {
-            MetadataManager.INSTANCE.abortTransaction(mdTxnCtx);
+            abort(e, e, mdTxnCtx);
             throw new AlgebricksException(e);
         } finally {
             releaseWriteLatch();
@@ -361,6 +371,7 @@
     private void handleCreateDatasetStatement(AqlMetadataProvider metadataProvider, Statement stmt,
             IHyracksClientConnection hcc) throws AsterixException, Exception {
 
+        ProgressState progress = ProgressState.NO_PROGRESS;
         MetadataTransactionContext mdTxnCtx = MetadataManager.INSTANCE.beginTransaction();
         boolean bActiveTxn = true;
         metadataProvider.setMetadataTxnContext(mdTxnCtx);
@@ -368,6 +379,7 @@
 
         String dataverseName = null;
         String datasetName = null;
+        Dataset dataset = null;
         try {
             DatasetDecl dd = (DatasetDecl) stmt;
             dataverseName = dd.getDataverse() != null ? dd.getDataverse().getValue()
@@ -404,6 +416,8 @@
                     }
                     List<String> partitioningExprs = ((InternalDetailsDecl) dd.getDatasetDetailsDecl())
                             .getPartitioningExprs();
+                    ARecordType aRecordType = (ARecordType) itemType;
+                    aRecordType.validatePartitioningExpressions(partitioningExprs);
                     String ngName = ((InternalDetailsDecl) dd.getDatasetDetailsDecl()).getNodegroupName().getValue();
                     datasetDetails = new InternalDatasetDetails(InternalDatasetDetails.FileStructure.BTREE,
                             InternalDatasetDetails.PartitioningStrategy.HASH, partitioningExprs, partitioningExprs,
@@ -423,6 +437,8 @@
                     }
                     List<String> partitioningExprs = ((FeedDetailsDecl) dd.getDatasetDetailsDecl())
                             .getPartitioningExprs();
+                    ARecordType aRecordType = (ARecordType) itemType;
+                    aRecordType.validatePartitioningExpressions(partitioningExprs);
                     String ngName = ((FeedDetailsDecl) dd.getDatasetDetailsDecl()).getNodegroupName().getValue();
                     String adapter = ((FeedDetailsDecl) dd.getDatasetDetailsDecl()).getAdapterFactoryClassname();
                     Map<String, String> configuration = ((FeedDetailsDecl) dd.getDatasetDetailsDecl())
@@ -435,9 +451,14 @@
                 }
             }
 
+            //#. initialize DatasetIdFactory if it is not initialized.
+            if (!DatasetIdFactory.isInitialized()) {
+                DatasetIdFactory.initialize(MetadataManager.INSTANCE.getMostRecentDatasetId());
+            }
+
             //#. add a new dataset with PendingAddOp
-            Dataset dataset = new Dataset(dataverseName, datasetName, itemTypeName, datasetDetails, dd.getHints(),
-                    dsType, DatasetIdFactory.generateDatasetId(), IMetadataEntity.PENDING_ADD_OP);
+            dataset = new Dataset(dataverseName, datasetName, itemTypeName, datasetDetails, dd.getHints(), dsType,
+                    DatasetIdFactory.generateDatasetId(), IMetadataEntity.PENDING_ADD_OP);
             MetadataManager.INSTANCE.addDataset(metadataProvider.getMetadataTxnContext(), dataset);
 
             if (dd.getDatasetType() == DatasetType.INTERNAL || dd.getDatasetType() == DatasetType.FEED) {
@@ -449,6 +470,7 @@
                 //#. make metadataTxn commit before calling runJob.
                 MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
                 bActiveTxn = false;
+                progress = ProgressState.ADDED_PENDINGOP_RECORD_TO_METADATA;
 
                 //#. runJob
                 runJob(hcc, jobSpec, true);
@@ -461,44 +483,51 @@
 
             //#. add a new dataset with PendingNoOp after deleting the dataset with PendingAddOp
             MetadataManager.INSTANCE.dropDataset(metadataProvider.getMetadataTxnContext(), dataverseName, datasetName);
-            MetadataManager.INSTANCE.addDataset(metadataProvider.getMetadataTxnContext(), new Dataset(dataverseName,
-                    datasetName, itemTypeName, datasetDetails, dd.getHints(), dsType, dataset.getDatasetId(),
-                    IMetadataEntity.PENDING_NO_OP));
+            dataset.setPendingOp(IMetadataEntity.PENDING_NO_OP);
+            MetadataManager.INSTANCE.addDataset(metadataProvider.getMetadataTxnContext(), dataset);
             MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
         } catch (Exception e) {
             if (bActiveTxn) {
-                MetadataManager.INSTANCE.abortTransaction(mdTxnCtx);
+                abort(e, e, mdTxnCtx);
             }
 
-            //#. execute compensation operations
-            //   remove the index in NC
-            mdTxnCtx = MetadataManager.INSTANCE.beginTransaction();
-            bActiveTxn = true;
-            metadataProvider.setMetadataTxnContext(mdTxnCtx);
-            CompiledDatasetDropStatement cds = new CompiledDatasetDropStatement(dataverseName, datasetName);
-            try {
-                JobSpecification jobSpec = DatasetOperations.createDropDatasetJobSpec(cds, metadataProvider);
-                MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
-                bActiveTxn = false;
+            if (progress == ProgressState.ADDED_PENDINGOP_RECORD_TO_METADATA) {
 
-                runJob(hcc, jobSpec, true);
-            } catch (Exception e3) {
-                if (bActiveTxn) {
-                    MetadataManager.INSTANCE.abortTransaction(mdTxnCtx);
+                //#. execute compensation operations
+                //   remove the index in NC
+                //   [Notice]
+                //   As long as we updated(and committed) metadata, we should remove any effect of the job 
+                //   because an exception occurs during runJob.
+                mdTxnCtx = MetadataManager.INSTANCE.beginTransaction();
+                bActiveTxn = true;
+                metadataProvider.setMetadataTxnContext(mdTxnCtx);
+                CompiledDatasetDropStatement cds = new CompiledDatasetDropStatement(dataverseName, datasetName);
+                try {
+                    JobSpecification jobSpec = DatasetOperations.createDropDatasetJobSpec(cds, metadataProvider);
+                    MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
+                    bActiveTxn = false;
+
+                    runJob(hcc, jobSpec, true);
+                } catch (Exception e2) {
+                    e.addSuppressed(e2);
+                    if (bActiveTxn) {
+                        abort(e, e2, mdTxnCtx);
+                    }
                 }
-                //do no throw exception since still the metadata needs to be compensated. 
-            }
 
-            //   remove the record from the metadata.
-            mdTxnCtx = MetadataManager.INSTANCE.beginTransaction();
-            metadataProvider.setMetadataTxnContext(mdTxnCtx);
-            try {
-                MetadataManager.INSTANCE.dropDataset(metadataProvider.getMetadataTxnContext(), dataverseName,
-                        datasetName);
-                MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
-            } catch (Exception e2) {
-                MetadataManager.INSTANCE.abortTransaction(mdTxnCtx);
-                throw new AlgebricksException(e2);
+                //   remove the record from the metadata.
+                mdTxnCtx = MetadataManager.INSTANCE.beginTransaction();
+                metadataProvider.setMetadataTxnContext(mdTxnCtx);
+                try {
+                    MetadataManager.INSTANCE.dropDataset(metadataProvider.getMetadataTxnContext(), dataverseName,
+                            datasetName);
+                    MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
+                } catch (Exception e2) {
+                    e.addSuppressed(e2);
+                    abort(e, e2, mdTxnCtx);
+                    throw new IllegalStateException("System is inconsistent state: pending dataset(" + dataverseName
+                            + "." + datasetName + ") couldn't be removed from the metadata", e);
+                }
             }
 
             throw new AlgebricksException(e);
@@ -510,6 +539,7 @@
     private void handleCreateIndexStatement(AqlMetadataProvider metadataProvider, Statement stmt,
             IHyracksClientConnection hcc) throws Exception {
 
+        ProgressState progress = ProgressState.NO_PROGRESS;
         MetadataTransactionContext mdTxnCtx = MetadataManager.INSTANCE.beginTransaction();
         boolean bActiveTxn = true;
         metadataProvider.setMetadataTxnContext(mdTxnCtx);
@@ -518,6 +548,7 @@
         String dataverseName = null;
         String datasetName = null;
         String indexName = null;
+        JobSpecification spec = null;
         try {
             CreateIndexStatement stmtCreateIndex = (CreateIndexStatement) stmt;
             dataverseName = stmtCreateIndex.getDataverseName() == null ? activeDefaultDataverse == null ? null
@@ -538,13 +569,19 @@
             Index idx = MetadataManager.INSTANCE.getIndex(metadataProvider.getMetadataTxnContext(), dataverseName,
                     datasetName, indexName);
 
+            String itemTypeName = ds.getItemTypeName();
+            Datatype dt = MetadataManager.INSTANCE.getDatatype(metadataProvider.getMetadataTxnContext(), dataverseName,
+                    itemTypeName);
+            IAType itemType = dt.getDatatype();
+            ARecordType aRecordType = (ARecordType) itemType;
+            aRecordType.validateKeyFields(stmtCreateIndex.getFieldExprs(), stmtCreateIndex.getIndexType());
+
             if (idx != null) {
-                if (!stmtCreateIndex.getIfNotExists()) {
-                    throw new AlgebricksException("An index with this name " + indexName + " already exists.");
-                } else {
-                    stmtCreateIndex.setNeedToCreate(false);
+                if (stmtCreateIndex.getIfNotExists()) {
                     MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
                     return;
+                } else {
+                    throw new AlgebricksException("An index with this name " + indexName + " already exists.");
                 }
             }
 
@@ -554,17 +591,19 @@
                     IMetadataEntity.PENDING_ADD_OP);
             MetadataManager.INSTANCE.addIndex(metadataProvider.getMetadataTxnContext(), index);
 
-            //#. create the index artifact in NC.
+            //#. prepare to create the index artifact in NC.
             CompiledCreateIndexStatement cis = new CompiledCreateIndexStatement(index.getIndexName(), dataverseName,
                     index.getDatasetName(), index.getKeyFieldNames(), index.getGramLength(), index.getIndexType());
-            JobSpecification spec = IndexOperations.buildSecondaryIndexCreationJobSpec(cis, metadataProvider);
+            spec = IndexOperations.buildSecondaryIndexCreationJobSpec(cis, metadataProvider);
             if (spec == null) {
                 throw new AsterixException("Failed to create job spec for creating index '"
                         + stmtCreateIndex.getDatasetName() + "." + stmtCreateIndex.getIndexName() + "'");
             }
             MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
             bActiveTxn = false;
+            progress = ProgressState.ADDED_PENDINGOP_RECORD_TO_METADATA;
 
+            //#. create the index artifact in NC.
             runJob(hcc, spec, true);
 
             mdTxnCtx = MetadataManager.INSTANCE.beginTransaction();
@@ -588,56 +627,56 @@
             //#. add another new index with PendingNoOp after deleting the index with PendingAddOp
             MetadataManager.INSTANCE.dropIndex(metadataProvider.getMetadataTxnContext(), dataverseName, datasetName,
                     indexName);
-            index = new Index(dataverseName, datasetName, indexName, stmtCreateIndex.getIndexType(),
-                    stmtCreateIndex.getFieldExprs(), stmtCreateIndex.getGramLength(), false,
-                    IMetadataEntity.PENDING_NO_OP);
+            index.setPendingOp(IMetadataEntity.PENDING_NO_OP);
             MetadataManager.INSTANCE.addIndex(metadataProvider.getMetadataTxnContext(), index);
             MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
 
         } catch (Exception e) {
             if (bActiveTxn) {
-                MetadataManager.INSTANCE.abortTransaction(mdTxnCtx);
+                abort(e, e, mdTxnCtx);
             }
 
-            //#. execute compensation operations
-            //   remove the index in NC
-            mdTxnCtx = MetadataManager.INSTANCE.beginTransaction();
-            bActiveTxn = true;
-            metadataProvider.setMetadataTxnContext(mdTxnCtx);
-            CompiledIndexDropStatement cds = new CompiledIndexDropStatement(dataverseName, datasetName, indexName);
-            try {
-                JobSpecification jobSpec = IndexOperations.buildDropSecondaryIndexJobSpec(cds, metadataProvider);
-                MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
-                bActiveTxn = false;
+            if (progress == ProgressState.ADDED_PENDINGOP_RECORD_TO_METADATA) {
+                //#. execute compensation operations
+                //   remove the index in NC
+                mdTxnCtx = MetadataManager.INSTANCE.beginTransaction();
+                bActiveTxn = true;
+                metadataProvider.setMetadataTxnContext(mdTxnCtx);
+                CompiledIndexDropStatement cds = new CompiledIndexDropStatement(dataverseName, datasetName, indexName);
+                try {
+                    JobSpecification jobSpec = IndexOperations.buildDropSecondaryIndexJobSpec(cds, metadataProvider);
+                    MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
+                    bActiveTxn = false;
 
-                runJob(hcc, jobSpec, true);
-            } catch (Exception e3) {
-                if (bActiveTxn) {
-                    MetadataManager.INSTANCE.abortTransaction(mdTxnCtx);
+                    runJob(hcc, jobSpec, true);
+                } catch (Exception e2) {
+                    e.addSuppressed(e2);
+                    if (bActiveTxn) {
+                        abort(e, e2, mdTxnCtx);
+                    }
                 }
-                //do no throw exception since still the metadata needs to be compensated. 
-            }
 
-            //   remove the record from the metadata.
-            mdTxnCtx = MetadataManager.INSTANCE.beginTransaction();
-            metadataProvider.setMetadataTxnContext(mdTxnCtx);
-            try {
-                MetadataManager.INSTANCE.dropIndex(metadataProvider.getMetadataTxnContext(), dataverseName,
-                        datasetName, indexName);
-                MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
-            } catch (Exception e2) {
-                MetadataManager.INSTANCE.abortTransaction(mdTxnCtx);
-                throw new AlgebricksException(e2);
+                //   remove the record from the metadata.
+                mdTxnCtx = MetadataManager.INSTANCE.beginTransaction();
+                metadataProvider.setMetadataTxnContext(mdTxnCtx);
+                try {
+                    MetadataManager.INSTANCE.dropIndex(metadataProvider.getMetadataTxnContext(), dataverseName,
+                            datasetName, indexName);
+                    MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
+                } catch (Exception e2) {
+                    e.addSuppressed(e2);
+                    abort(e, e2, mdTxnCtx);
+                    throw new IllegalStateException("System is inconsistent state: pending index(" + dataverseName
+                            + "." + datasetName + "." + indexName + ") couldn't be removed from the metadata", e);
+                }
             }
-
             throw new AlgebricksException(e);
         } finally {
             releaseWriteLatch();
         }
     }
 
-    private void handleCreateTypeStatement(AqlMetadataProvider metadataProvider, Statement stmt)
-            throws AlgebricksException, RemoteException, ACIDException, MetadataException {
+    private void handleCreateTypeStatement(AqlMetadataProvider metadataProvider, Statement stmt) throws Exception {
 
         MetadataTransactionContext mdTxnCtx = MetadataManager.INSTANCE.beginTransaction();
         metadataProvider.setMetadataTxnContext(mdTxnCtx);
@@ -673,7 +712,7 @@
             }
             MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
         } catch (Exception e) {
-            MetadataManager.INSTANCE.abortTransaction(mdTxnCtx);
+            abort(e, e, mdTxnCtx);
             throw new AlgebricksException(e);
         } finally {
             releaseWriteLatch();
@@ -683,43 +722,46 @@
     private void handleDataverseDropStatement(AqlMetadataProvider metadataProvider, Statement stmt,
             IHyracksClientConnection hcc) throws Exception {
 
+        ProgressState progress = ProgressState.NO_PROGRESS;
         MetadataTransactionContext mdTxnCtx = MetadataManager.INSTANCE.beginTransaction();
         boolean bActiveTxn = true;
         metadataProvider.setMetadataTxnContext(mdTxnCtx);
         acquireWriteLatch();
 
-        String dvName = null;
+        String dataverseName = null;
         List<JobSpecification> jobsToExecute = new ArrayList<JobSpecification>();
         try {
             DataverseDropStatement stmtDelete = (DataverseDropStatement) stmt;
-            dvName = stmtDelete.getDataverseName().getValue();
+            dataverseName = stmtDelete.getDataverseName().getValue();
 
-            Dataverse dv = MetadataManager.INSTANCE.getDataverse(mdTxnCtx, dvName);
+            Dataverse dv = MetadataManager.INSTANCE.getDataverse(mdTxnCtx, dataverseName);
             if (dv == null) {
-                if (!stmtDelete.getIfExists()) {
-                    throw new AlgebricksException("There is no dataverse with this name " + dvName + ".");
+                if (stmtDelete.getIfExists()) {
+                    MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
+                    return;
+                } else {
+                    throw new AlgebricksException("There is no dataverse with this name " + dataverseName + ".");
                 }
-                MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
-                return;
             }
 
             //#. prepare jobs which will drop corresponding datasets with indexes. 
-            List<Dataset> datasets = MetadataManager.INSTANCE.getDataverseDatasets(mdTxnCtx, dvName);
+            List<Dataset> datasets = MetadataManager.INSTANCE.getDataverseDatasets(mdTxnCtx, dataverseName);
             for (int j = 0; j < datasets.size(); j++) {
                 String datasetName = datasets.get(j).getDatasetName();
                 DatasetType dsType = datasets.get(j).getDatasetType();
                 if (dsType == DatasetType.INTERNAL || dsType == DatasetType.FEED) {
 
-                    List<Index> indexes = MetadataManager.INSTANCE.getDatasetIndexes(mdTxnCtx, dvName, datasetName);
+                    List<Index> indexes = MetadataManager.INSTANCE.getDatasetIndexes(mdTxnCtx, dataverseName,
+                            datasetName);
                     for (int k = 0; k < indexes.size(); k++) {
                         if (indexes.get(k).isSecondaryIndex()) {
-                            CompiledIndexDropStatement cds = new CompiledIndexDropStatement(dvName, datasetName,
+                            CompiledIndexDropStatement cds = new CompiledIndexDropStatement(dataverseName, datasetName,
                                     indexes.get(k).getIndexName());
                             jobsToExecute.add(IndexOperations.buildDropSecondaryIndexJobSpec(cds, metadataProvider));
                         }
                     }
 
-                    CompiledDatasetDropStatement cds = new CompiledDatasetDropStatement(dvName, datasetName);
+                    CompiledDatasetDropStatement cds = new CompiledDatasetDropStatement(dataverseName, datasetName);
                     jobsToExecute.add(DatasetOperations.createDropDatasetJobSpec(cds, metadataProvider));
                 }
             }
@@ -727,12 +769,13 @@
             //#. mark PendingDropOp on the dataverse record by 
             //   first, deleting the dataverse record from the DATAVERSE_DATASET
             //   second, inserting the dataverse record with the PendingDropOp value into the DATAVERSE_DATASET
-            MetadataManager.INSTANCE.dropDataverse(mdTxnCtx, dvName);
-            MetadataManager.INSTANCE.addDataverse(mdTxnCtx, new Dataverse(dvName, dv.getDataFormat(),
+            MetadataManager.INSTANCE.dropDataverse(mdTxnCtx, dataverseName);
+            MetadataManager.INSTANCE.addDataverse(mdTxnCtx, new Dataverse(dataverseName, dv.getDataFormat(),
                     IMetadataEntity.PENDING_DROP_OP));
 
             MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
             bActiveTxn = false;
+            progress = ProgressState.ADDED_PENDINGOP_RECORD_TO_METADATA;
 
             for (JobSpecification jobSpec : jobsToExecute) {
                 runJob(hcc, jobSpec, true);
@@ -743,32 +786,44 @@
             metadataProvider.setMetadataTxnContext(mdTxnCtx);
 
             //#. finally, delete the dataverse.
-            MetadataManager.INSTANCE.dropDataverse(mdTxnCtx, dvName);
-            if (activeDefaultDataverse != null && activeDefaultDataverse.getDataverseName() == dvName) {
+            MetadataManager.INSTANCE.dropDataverse(mdTxnCtx, dataverseName);
+            if (activeDefaultDataverse != null && activeDefaultDataverse.getDataverseName() == dataverseName) {
                 activeDefaultDataverse = null;
             }
 
             MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
         } catch (Exception e) {
             if (bActiveTxn) {
-                MetadataManager.INSTANCE.abortTransaction(mdTxnCtx);
+                abort(e, e, mdTxnCtx);
             }
 
-            //#. execute compensation operations
-            //   remove the all indexes in NC
-            for (JobSpecification jobSpec : jobsToExecute) {
-                runJob(hcc, jobSpec, true);
-            }
+            if (progress == ProgressState.ADDED_PENDINGOP_RECORD_TO_METADATA) {
+                if (activeDefaultDataverse != null && activeDefaultDataverse.getDataverseName() == dataverseName) {
+                    activeDefaultDataverse = null;
+                }
 
-            //   remove the record from the metadata.
-            mdTxnCtx = MetadataManager.INSTANCE.beginTransaction();
-            metadataProvider.setMetadataTxnContext(mdTxnCtx);
-            try {
-                MetadataManager.INSTANCE.dropDataverse(metadataProvider.getMetadataTxnContext(), dvName);
-                MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
-            } catch (Exception e2) {
-                MetadataManager.INSTANCE.abortTransaction(mdTxnCtx);
-                throw new AlgebricksException(e2);
+                //#. execute compensation operations
+                //   remove the all indexes in NC
+                try {
+                    for (JobSpecification jobSpec : jobsToExecute) {
+                        runJob(hcc, jobSpec, true);
+                    }
+                } catch (Exception e2) {
+                    //do no throw exception since still the metadata needs to be compensated. 
+                    e.addSuppressed(e2);
+                }
+
+                //   remove the record from the metadata.
+                mdTxnCtx = MetadataManager.INSTANCE.beginTransaction();
+                try {
+                    MetadataManager.INSTANCE.dropDataverse(mdTxnCtx, dataverseName);
+                    MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
+                } catch (Exception e2) {
+                    e.addSuppressed(e2);
+                    abort(e, e2, mdTxnCtx);
+                    throw new IllegalStateException("System is inconsistent state: pending dataverse(" + dataverseName
+                            + ") couldn't be removed from the metadata", e);
+                }
             }
 
             throw new AlgebricksException(e);
@@ -780,6 +835,7 @@
     private void handleDatasetDropStatement(AqlMetadataProvider metadataProvider, Statement stmt,
             IHyracksClientConnection hcc) throws Exception {
 
+        ProgressState progress = ProgressState.NO_PROGRESS;
         MetadataTransactionContext mdTxnCtx = MetadataManager.INSTANCE.beginTransaction();
         boolean bActiveTxn = true;
         metadataProvider.setMetadataTxnContext(mdTxnCtx);
@@ -799,12 +855,13 @@
 
             Dataset ds = MetadataManager.INSTANCE.getDataset(mdTxnCtx, dataverseName, datasetName);
             if (ds == null) {
-                if (!stmtDelete.getIfExists()) {
+                if (stmtDelete.getIfExists()) {
+                    MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
+                    return;
+                } else {
                     throw new AlgebricksException("There is no dataset with this name " + datasetName
                             + " in dataverse " + dataverseName + ".");
                 }
-                MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
-                return;
             }
 
             if (ds.getDatasetType() == DatasetType.INTERNAL || ds.getDatasetType() == DatasetType.FEED) {
@@ -830,6 +887,7 @@
 
                 MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
                 bActiveTxn = false;
+                progress = ProgressState.ADDED_PENDINGOP_RECORD_TO_METADATA;
 
                 //#. run the jobs
                 for (JobSpecification jobSpec : jobsToExecute) {
@@ -847,25 +905,34 @@
             MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
         } catch (Exception e) {
             if (bActiveTxn) {
-                MetadataManager.INSTANCE.abortTransaction(mdTxnCtx);
+                abort(e, e, mdTxnCtx);
             }
 
-            //#. execute compensation operations
-            //   remove the all indexes in NC
-            for (JobSpecification jobSpec : jobsToExecute) {
-                runJob(hcc, jobSpec, true);
-            }
+            if (progress == ProgressState.ADDED_PENDINGOP_RECORD_TO_METADATA) {
+                //#. execute compensation operations
+                //   remove the all indexes in NC
+                try {
+                    for (JobSpecification jobSpec : jobsToExecute) {
+                        runJob(hcc, jobSpec, true);
+                    }
+                } catch (Exception e2) {
+                    //do no throw exception since still the metadata needs to be compensated. 
+                    e.addSuppressed(e2);
+                }
 
-            //   remove the record from the metadata.
-            mdTxnCtx = MetadataManager.INSTANCE.beginTransaction();
-            metadataProvider.setMetadataTxnContext(mdTxnCtx);
-            try {
-                MetadataManager.INSTANCE.dropDataset(metadataProvider.getMetadataTxnContext(), dataverseName,
-                        datasetName);
-                MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
-            } catch (Exception e2) {
-                MetadataManager.INSTANCE.abortTransaction(mdTxnCtx);
-                throw new AlgebricksException(e2);
+                //   remove the record from the metadata.
+                mdTxnCtx = MetadataManager.INSTANCE.beginTransaction();
+                metadataProvider.setMetadataTxnContext(mdTxnCtx);
+                try {
+                    MetadataManager.INSTANCE.dropDataset(metadataProvider.getMetadataTxnContext(), dataverseName,
+                            datasetName);
+                    MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
+                } catch (Exception e2) {
+                    e.addSuppressed(e2);
+                    abort(e, e2, mdTxnCtx);
+                    throw new IllegalStateException("System is inconsistent state: pending dataset(" + dataverseName
+                            + "." + datasetName + ") couldn't be removed from the metadata", e);
+                }
             }
 
             throw new AlgebricksException(e);
@@ -877,6 +944,7 @@
     private void handleIndexDropStatement(AqlMetadataProvider metadataProvider, Statement stmt,
             IHyracksClientConnection hcc) throws Exception {
 
+        ProgressState progress = ProgressState.NO_PROGRESS;
         MetadataTransactionContext mdTxnCtx = MetadataManager.INSTANCE.beginTransaction();
         boolean bActiveTxn = true;
         metadataProvider.setMetadataTxnContext(mdTxnCtx);
@@ -905,38 +973,39 @@
                 indexName = stmtIndexDrop.getIndexName().getValue();
                 Index index = MetadataManager.INSTANCE.getIndex(mdTxnCtx, dataverseName, datasetName, indexName);
                 if (index == null) {
-                    if (!stmtIndexDrop.getIfExists()) {
+                    if (stmtIndexDrop.getIfExists()) {
+                        MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
+                        return;
+                    } else {
                         throw new AlgebricksException("There is no index with this name " + indexName + ".");
                     }
-                } else {
-                    //#. prepare a job to drop the index in NC.
-                    CompiledIndexDropStatement cds = new CompiledIndexDropStatement(dataverseName, datasetName,
-                            indexName);
-                    jobsToExecute.add(IndexOperations.buildDropSecondaryIndexJobSpec(cds, metadataProvider));
-
-                    //#. mark PendingDropOp on the existing index
-                    MetadataManager.INSTANCE.dropIndex(mdTxnCtx, dataverseName, datasetName, indexName);
-                    MetadataManager.INSTANCE.addIndex(
-                            mdTxnCtx,
-                            new Index(dataverseName, datasetName, indexName, index.getIndexType(), index
-                                    .getKeyFieldNames(), index.isPrimaryIndex(), IMetadataEntity.PENDING_DROP_OP));
-
-                    //#. commit the existing transaction before calling runJob. 
-                    MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
-                    bActiveTxn = false;
-
-                    for (JobSpecification jobSpec : jobsToExecute) {
-                        runJob(hcc, jobSpec, true);
-                    }
-
-                    //#. begin a new transaction
-                    mdTxnCtx = MetadataManager.INSTANCE.beginTransaction();
-                    bActiveTxn = true;
-                    metadataProvider.setMetadataTxnContext(mdTxnCtx);
-
-                    //#. finally, delete the existing index
-                    MetadataManager.INSTANCE.dropIndex(mdTxnCtx, dataverseName, datasetName, indexName);
                 }
+                //#. prepare a job to drop the index in NC.
+                CompiledIndexDropStatement cds = new CompiledIndexDropStatement(dataverseName, datasetName, indexName);
+                jobsToExecute.add(IndexOperations.buildDropSecondaryIndexJobSpec(cds, metadataProvider));
+
+                //#. mark PendingDropOp on the existing index
+                MetadataManager.INSTANCE.dropIndex(mdTxnCtx, dataverseName, datasetName, indexName);
+                MetadataManager.INSTANCE.addIndex(mdTxnCtx,
+                        new Index(dataverseName, datasetName, indexName, index.getIndexType(),
+                                index.getKeyFieldNames(), index.isPrimaryIndex(), IMetadataEntity.PENDING_DROP_OP));
+
+                //#. commit the existing transaction before calling runJob. 
+                MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
+                bActiveTxn = false;
+                progress = ProgressState.ADDED_PENDINGOP_RECORD_TO_METADATA;
+
+                for (JobSpecification jobSpec : jobsToExecute) {
+                    runJob(hcc, jobSpec, true);
+                }
+
+                //#. begin a new transaction
+                mdTxnCtx = MetadataManager.INSTANCE.beginTransaction();
+                bActiveTxn = true;
+                metadataProvider.setMetadataTxnContext(mdTxnCtx);
+
+                //#. finally, delete the existing index
+                MetadataManager.INSTANCE.dropIndex(mdTxnCtx, dataverseName, datasetName, indexName);
             } else {
                 throw new AlgebricksException(datasetName
                         + " is an external dataset. Indexes are not maintained for external datasets.");
@@ -945,25 +1014,34 @@
 
         } catch (Exception e) {
             if (bActiveTxn) {
-                MetadataManager.INSTANCE.abortTransaction(mdTxnCtx);
+                abort(e, e, mdTxnCtx);
             }
 
-            //#. execute compensation operations
-            //   remove the all indexes in NC
-            for (JobSpecification jobSpec : jobsToExecute) {
-                runJob(hcc, jobSpec, true);
-            }
+            if (progress == ProgressState.ADDED_PENDINGOP_RECORD_TO_METADATA) {
+                //#. execute compensation operations
+                //   remove the all indexes in NC
+                try {
+                    for (JobSpecification jobSpec : jobsToExecute) {
+                        runJob(hcc, jobSpec, true);
+                    }
+                } catch (Exception e2) {
+                    //do no throw exception since still the metadata needs to be compensated.
+                    e.addSuppressed(e2);
+                }
 
-            //   remove the record from the metadata.
-            mdTxnCtx = MetadataManager.INSTANCE.beginTransaction();
-            metadataProvider.setMetadataTxnContext(mdTxnCtx);
-            try {
-                MetadataManager.INSTANCE.dropIndex(metadataProvider.getMetadataTxnContext(), dataverseName,
-                        datasetName, indexName);
-                MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
-            } catch (Exception e2) {
-                MetadataManager.INSTANCE.abortTransaction(mdTxnCtx);
-                throw new AlgebricksException(e2);
+                //   remove the record from the metadata.
+                mdTxnCtx = MetadataManager.INSTANCE.beginTransaction();
+                metadataProvider.setMetadataTxnContext(mdTxnCtx);
+                try {
+                    MetadataManager.INSTANCE.dropIndex(metadataProvider.getMetadataTxnContext(), dataverseName,
+                            datasetName, indexName);
+                    MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
+                } catch (Exception e2) {
+                    e.addSuppressed(e2);
+                    abort(e, e2, mdTxnCtx);
+                    throw new IllegalStateException("System is inconsistent state: pending index(" + dataverseName
+                            + "." + datasetName + "." + indexName + ") couldn't be removed from the metadata", e);
+                }
             }
 
             throw new AlgebricksException(e);
@@ -973,8 +1051,7 @@
         }
     }
 
-    private void handleTypeDropStatement(AqlMetadataProvider metadataProvider, Statement stmt)
-            throws AlgebricksException, MetadataException, RemoteException, ACIDException {
+    private void handleTypeDropStatement(AqlMetadataProvider metadataProvider, Statement stmt) throws Exception {
 
         MetadataTransactionContext mdTxnCtx = MetadataManager.INSTANCE.beginTransaction();
         metadataProvider.setMetadataTxnContext(mdTxnCtx);
@@ -997,15 +1074,14 @@
             }
             MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
         } catch (Exception e) {
-            MetadataManager.INSTANCE.abortTransaction(mdTxnCtx);
+            abort(e, e, mdTxnCtx);
             throw new AlgebricksException(e);
         } finally {
             releaseWriteLatch();
         }
     }
 
-    private void handleNodegroupDropStatement(AqlMetadataProvider metadataProvider, Statement stmt)
-            throws MetadataException, AlgebricksException, RemoteException, ACIDException {
+    private void handleNodegroupDropStatement(AqlMetadataProvider metadataProvider, Statement stmt) throws Exception {
 
         MetadataTransactionContext mdTxnCtx = MetadataManager.INSTANCE.beginTransaction();
         metadataProvider.setMetadataTxnContext(mdTxnCtx);
@@ -1024,15 +1100,14 @@
 
             MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
         } catch (Exception e) {
-            MetadataManager.INSTANCE.abortTransaction(mdTxnCtx);
+            abort(e, e, mdTxnCtx);
             throw new AlgebricksException(e);
         } finally {
             releaseWriteLatch();
         }
     }
 
-    private void handleCreateFunctionStatement(AqlMetadataProvider metadataProvider, Statement stmt)
-            throws AlgebricksException, MetadataException, RemoteException, ACIDException {
+    private void handleCreateFunctionStatement(AqlMetadataProvider metadataProvider, Statement stmt) throws Exception {
         MetadataTransactionContext mdTxnCtx = MetadataManager.INSTANCE.beginTransaction();
         metadataProvider.setMetadataTxnContext(mdTxnCtx);
         acquireWriteLatch();
@@ -1055,15 +1130,14 @@
 
             MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
         } catch (Exception e) {
-            MetadataManager.INSTANCE.abortTransaction(mdTxnCtx);
+            abort(e, e, mdTxnCtx);
             throw new AlgebricksException(e);
         } finally {
             releaseWriteLatch();
         }
     }
 
-    private void handleFunctionDropStatement(AqlMetadataProvider metadataProvider, Statement stmt)
-            throws MetadataException, RemoteException, ACIDException, AlgebricksException {
+    private void handleFunctionDropStatement(AqlMetadataProvider metadataProvider, Statement stmt) throws Exception {
         MetadataTransactionContext mdTxnCtx = MetadataManager.INSTANCE.beginTransaction();
         metadataProvider.setMetadataTxnContext(mdTxnCtx);
         acquireWriteLatch();
@@ -1080,7 +1154,7 @@
             }
             MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
         } catch (Exception e) {
-            MetadataManager.INSTANCE.abortTransaction(mdTxnCtx);
+            abort(e, e, mdTxnCtx);
             throw new AlgebricksException(e);
         } finally {
             releaseWriteLatch();
@@ -1127,7 +1201,7 @@
             }
         } catch (Exception e) {
             if (bActiveTxn) {
-                MetadataManager.INSTANCE.abortTransaction(mdTxnCtx);
+                abort(e, e, mdTxnCtx);
             }
 
             throw new AlgebricksException(e);
@@ -1159,7 +1233,7 @@
             }
         } catch (Exception e) {
             if (bActiveTxn) {
-                MetadataManager.INSTANCE.abortTransaction(mdTxnCtx);
+                abort(e, e, mdTxnCtx);
             }
             throw new AlgebricksException(e);
         } finally {
@@ -1193,7 +1267,7 @@
 
         } catch (Exception e) {
             if (bActiveTxn) {
-                MetadataManager.INSTANCE.abortTransaction(mdTxnCtx);
+                abort(e, e, mdTxnCtx);
             }
             throw new AlgebricksException(e);
         } finally {
@@ -1215,8 +1289,8 @@
             String dataverseName = stmtDelete.getDataverseName() == null ? activeDefaultDataverse == null ? null
                     : activeDefaultDataverse.getDataverseName() : stmtDelete.getDataverseName().getValue();
             CompiledDeleteStatement clfrqs = new CompiledDeleteStatement(stmtDelete.getVariableExpr(), dataverseName,
-                    stmtDelete.getDatasetName().getValue(), stmtDelete.getCondition(), stmtDelete.getDieClause(),
-                    stmtDelete.getVarCounter(), metadataProvider);
+                    stmtDelete.getDatasetName().getValue(), stmtDelete.getCondition(), stmtDelete.getVarCounter(),
+                    metadataProvider);
             JobSpecification compiled = rewriteCompileQuery(metadataProvider, clfrqs.getQuery(), clfrqs);
 
             MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
@@ -1228,7 +1302,7 @@
 
         } catch (Exception e) {
             if (bActiveTxn) {
-                MetadataManager.INSTANCE.abortTransaction(mdTxnCtx);
+                abort(e, e, mdTxnCtx);
             }
             throw new AlgebricksException(e);
         } finally {
@@ -1293,7 +1367,7 @@
 
         } catch (Exception e) {
             if (bActiveTxn) {
-                MetadataManager.INSTANCE.abortTransaction(mdTxnCtx);
+                abort(e, e, mdTxnCtx);
             }
             throw new AlgebricksException(e);
         } finally {
@@ -1323,7 +1397,7 @@
 
         } catch (Exception e) {
             if (bActiveTxn) {
-                MetadataManager.INSTANCE.abortTransaction(mdTxnCtx);
+                abort(e, e, mdTxnCtx);
             }
             throw new AlgebricksException(e);
         } finally {
@@ -1385,7 +1459,7 @@
             return queryResult;
         } catch (Exception e) {
             if (bActiveTxn) {
-                MetadataManager.INSTANCE.abortTransaction(mdTxnCtx);
+                abort(e, e, mdTxnCtx);
             }
             throw new AlgebricksException(e);
         } finally {
@@ -1393,8 +1467,7 @@
         }
     }
 
-    private void handleCreateNodeGroupStatement(AqlMetadataProvider metadataProvider, Statement stmt)
-            throws MetadataException, AlgebricksException, RemoteException, ACIDException {
+    private void handleCreateNodeGroupStatement(AqlMetadataProvider metadataProvider, Statement stmt) throws Exception {
 
         MetadataTransactionContext mdTxnCtx = MetadataManager.INSTANCE.beginTransaction();
         metadataProvider.setMetadataTxnContext(mdTxnCtx);
@@ -1417,7 +1490,7 @@
             }
             MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
         } catch (Exception e) {
-            MetadataManager.INSTANCE.abortTransaction(mdTxnCtx);
+            abort(e, e, mdTxnCtx);
             throw new AlgebricksException(e);
         } finally {
             releaseWriteLatch();
@@ -1472,4 +1545,13 @@
     private void releaseReadLatch() {
         MetadataManager.INSTANCE.releaseReadLatch();
     }
-}
+
+    private void abort(Exception rootE, Exception parentE, MetadataTransactionContext mdTxnCtx) {
+        try {
+            MetadataManager.INSTANCE.abortTransaction(mdTxnCtx);
+        } catch (Exception e2) {
+            parentE.addSuppressed(e2);
+            throw new IllegalStateException(rootE);
+        }
+    }
+}
\ No newline at end of file
diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/file/DatasetOperations.java b/asterix-app/src/main/java/edu/uci/ics/asterix/file/DatasetOperations.java
index d4c8c34..b9b9524 100644
--- a/asterix-app/src/main/java/edu/uci/ics/asterix/file/DatasetOperations.java
+++ b/asterix-app/src/main/java/edu/uci/ics/asterix/file/DatasetOperations.java
@@ -148,17 +148,6 @@
             throw new AsterixException("Could not find dataset " + datasetName + " in datavetse " + dataverseName);
         }
         ARecordType itemType = (ARecordType) metadata.findType(dataverseName, dataset.getItemTypeName());
-        for (String keyField : DatasetUtils.getPartitioningKeys(dataset)) {
-            try {
-                if (!itemType.isClosedField(keyField)) {
-                    throw new AsterixException("Cannot partition dataset \"" + dataset.getDatasetName()
-                            + "\" by key \"" + keyField + "\" since it is not a valid field of \""
-                            + itemType.getTypeName() + "\"");
-                }
-            } catch (IOException e) {
-                throw new AsterixException(e);
-            }
-        }
         JobSpecification spec = new JobSpecification();
         IBinaryComparatorFactory[] comparatorFactories = DatasetUtils.computeKeysBinaryComparatorFactories(dataset,
                 itemType, format.getBinaryComparatorFactoryProvider());
diff --git a/asterix-app/src/main/java/edu/uci/ics/asterix/hyracks/bootstrap/CCApplicationEntryPoint.java b/asterix-app/src/main/java/edu/uci/ics/asterix/hyracks/bootstrap/CCApplicationEntryPoint.java
index 5ab94f3..1b8990b 100644
--- a/asterix-app/src/main/java/edu/uci/ics/asterix/hyracks/bootstrap/CCApplicationEntryPoint.java
+++ b/asterix-app/src/main/java/edu/uci/ics/asterix/hyracks/bootstrap/CCApplicationEntryPoint.java
@@ -14,10 +14,10 @@
 import edu.uci.ics.asterix.api.http.servlet.QueryStatusAPIServlet;
 import edu.uci.ics.asterix.api.http.servlet.UpdateAPIServlet;
 import edu.uci.ics.asterix.common.api.AsterixAppContextInfoImpl;
+import edu.uci.ics.asterix.common.config.AsterixProperties;
 import edu.uci.ics.asterix.common.config.GlobalConfig;
 import edu.uci.ics.asterix.metadata.MetadataManager;
 import edu.uci.ics.asterix.metadata.api.IAsterixStateProxy;
-import edu.uci.ics.asterix.metadata.bootstrap.AsterixProperties;
 import edu.uci.ics.asterix.metadata.bootstrap.AsterixStateProxy;
 import edu.uci.ics.hyracks.api.application.ICCApplicationContext;
 import edu.uci.ics.hyracks.api.application.ICCApplicationEntryPoint;
@@ -79,11 +79,8 @@
     }
 
     private void setupWebServer() throws Exception {
-        String portStr = System.getProperty(GlobalConfig.WEB_SERVER_PORT_PROPERTY);
-        int port = DEFAULT_WEB_SERVER_PORT;
-        if (portStr != null) {
-            port = Integer.parseInt(portStr);
-        }
+        int port = Integer.parseInt((String) AsterixProperties.INSTANCE
+                .getProperty(AsterixProperties.AsterixConfigurationKeys.WEB_INTERFACE_PORT));
         webServer = new Server(port);
 
         ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
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 f332155..8ad8c67 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,153 +18,145 @@
 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 (LOGGER.isLoggable(Level.INFO)) {
+            LOGGER.info("System is in a state: " + systemState);
+        }
 
-	@Override
-	public void stop() throws Exception {
-		if (!stopInitiated) {
-		    runtimeContext.setShuttingdown(true);
-			stopInitiated = true;
-			if (LOGGER.isLoggable(Level.INFO)) {
-				LOGGER.info("Stopping Asterix node controller: " + nodeId);
-			}
+        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);
+        }
+    }
 
-			IRecoveryManager recoveryMgr = runtimeContext
-					.getTransactionSubsystem().getRecoveryManager();
-			recoveryMgr.checkpoint(true);
+    @Override
+    public void stop() throws Exception {
+        if (!stopInitiated) {
+            runtimeContext.setShuttingdown(true);
+            stopInitiated = true;
+            if (LOGGER.isLoggable(Level.INFO)) {
+                LOGGER.info("Stopping Asterix node controller: " + nodeId);
+            }
 
-			if (isMetadataNode) {
-				MetadataBootstrap.stopUniverse();
-			}
-			runtimeContext.deinitialize();
-		} else {
-			if (LOGGER.isLoggable(Level.INFO)) {
-				LOGGER.info("Duplicate attempt to stop ignored: " + nodeId);
-			}
-		}
-	}
+            IRecoveryManager recoveryMgr = runtimeContext.getTransactionSubsystem().getRecoveryManager();
+            recoveryMgr.checkpoint(true);
 
-	@Override
-	public void notifyStartupComplete() throws Exception {
-		IAsterixStateProxy proxy = (IAsterixStateProxy) ncApplicationContext
-				.getDistributedState();
+            if (isMetadataNode) {
+                MetadataBootstrap.stopUniverse();
+            }
+            runtimeContext.deinitialize();
+        } else {
+            if (LOGGER.isLoggable(Level.INFO)) {
+                LOGGER.info("Duplicate attempt to stop ignored: " + nodeId);
+            }
+        }
+    }
 
-		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]);
+    @Override
+    public void notifyStartupComplete() throws Exception {
+        IAsterixStateProxy proxy = (IAsterixStateProxy) ncApplicationContext.getDistributedState();
 
-			localResourceRepository.initialize(nodeId, proxy
-					.getAsterixProperties().getStores().get(nodeId)[0], true,
-					null);
-		}
+        if (systemState == SystemState.NEW_UNIVERSE) {
+            PersistentLocalResourceRepository localResourceRepository = (PersistentLocalResourceRepository) runtimeContext
+                    .getLocalResourceRepository();
 
-		isMetadataNode = nodeId.equals(proxy.getAsterixProperties()
-				.getMetadataNodeName());
-		if (isMetadataNode) {
-			registerRemoteMetadataNode(proxy);
+            if (LOGGER.isLoggable(Level.INFO)) {
+                LOGGER.info("nodeid" + nodeId);
+                LOGGER.info("proxy" + proxy);
+                LOGGER.info("stores" + proxy.getAsterixProperties().getStores());
+                LOGGER.info("store" + proxy.getAsterixProperties().getStores().get(nodeId)[0]);
+            }
 
-			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();
-		}
+            localResourceRepository.initialize(nodeId, proxy.getAsterixProperties().getStores().get(nodeId)[0], true,
+                    null);
+        }
 
-		IRecoveryManager recoveryMgr = runtimeContext.getTransactionSubsystem()
-				.getRecoveryManager();
-		recoveryMgr.checkpoint(true);
+        isMetadataNode = nodeId.equals(proxy.getAsterixProperties().getMetadataNodeName());
+        if (isMetadataNode) {
+            registerRemoteMetadataNode(proxy);
 
-		// TODO
-		// reclaim storage for orphaned index artifacts in NCs.
-	}
+            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();
+        }
 
-	public void registerRemoteMetadataNode(IAsterixStateProxy proxy)
-			throws RemoteException {
-		IMetadataNode stub = null;
-		MetadataNode.INSTANCE.initialize(runtimeContext);
-		stub = (IMetadataNode) UnicastRemoteObject.exportObject(
-				MetadataNode.INSTANCE, 0);
-		proxy.setMetadataNode(stub);
+        IRecoveryManager recoveryMgr = runtimeContext.getTransactionSubsystem().getRecoveryManager();
+        recoveryMgr.checkpoint(true);
 
-		if (LOGGER.isLoggable(Level.INFO)) {
-			LOGGER.info("Metadata node bound");
-		}
-	}
+        // TODO
+        // reclaim storage for orphaned index artifacts in NCs.
+    }
 
-	/**
-	 * Shutdown hook that invokes {@link NCApplicationEntryPoint#stop() stop}
-	 * method.
-	 */
-	private static class JVMShutdownHook extends Thread {
+    public void registerRemoteMetadataNode(IAsterixStateProxy proxy) throws RemoteException {
+        IMetadataNode stub = null;
+        MetadataNode.INSTANCE.initialize(runtimeContext);
+        stub = (IMetadataNode) UnicastRemoteObject.exportObject(MetadataNode.INSTANCE, 0);
+        proxy.setMetadataNode(stub);
 
-		private final NCApplicationEntryPoint ncAppEntryPoint;
+        if (LOGGER.isLoggable(Level.INFO)) {
+            LOGGER.info("Metadata node bound");
+        }
+    }
 
-		public JVMShutdownHook(NCApplicationEntryPoint ncAppEntryPoint) {
-			this.ncAppEntryPoint = ncAppEntryPoint;
-		}
+    /**
+     * Shutdown hook that invokes {@link NCApplicationEntryPoint#stop() stop} method.
+     */
+    private static class JVMShutdownHook extends Thread {
 
-		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);
-				}
-			}
-		}
-	}
+        private final NCApplicationEntryPoint ncAppEntryPoint;
+
+        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-app/src/main/resources/asterix-build-configuration.xml b/asterix-app/src/main/resources/asterix-build-configuration.xml
new file mode 100644
index 0000000..bd984f0
--- /dev/null
+++ b/asterix-app/src/main/resources/asterix-build-configuration.xml
@@ -0,0 +1,16 @@
+<asterixConfiguration xmlns="asterixconf">
+  <metadataNode>nc1</metadataNode>
+  <store>
+     <ncId>nc1</ncId>
+     <storeDirs>nc1data</storeDirs> 
+  </store>
+  <store>
+     <ncId>nc2</ncId>
+     <storeDirs>nc2data</storeDirs> 
+  </store>
+  <property>
+     <name>log_level</name>
+     <value>WARNING</value>
+     <description></description>
+  </property>
+</asterixConfiguration>
diff --git a/asterix-app/src/main/resources/asterix-metadata.properties b/asterix-app/src/main/resources/asterix-metadata.properties
deleted file mode 100644
index e9ccc63..0000000
--- a/asterix-app/src/main/resources/asterix-metadata.properties
+++ /dev/null
@@ -1,4 +0,0 @@
-MetadataNode=nc1
-NewUniverse=true
-nc1.stores=/tmp/nc1data/
-nc2.stores=/tmp/nc2data/, /tmp/nc2data1/
\ No newline at end of file
diff --git a/asterix-app/src/test/java/edu/uci/ics/asterix/test/aql/TestsUtils.java b/asterix-app/src/test/java/edu/uci/ics/asterix/test/aql/TestsUtils.java
deleted file mode 100644
index 04f1aae..0000000
--- a/asterix-app/src/test/java/edu/uci/ics/asterix/test/aql/TestsUtils.java
+++ /dev/null
@@ -1,198 +0,0 @@
-package edu.uci.ics.asterix.test.aql;
-
-import static org.junit.Assert.fail;
-
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.PrintWriter;
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-
-import edu.uci.ics.hyracks.algebricks.common.exceptions.NotImplementedException;
-
-public class TestsUtils {
-
-    private static final String EXTENSION_AQL_RESULT = "adm";
-
-    /**
-     * Probably does not work well with symlinks.
-     */
-    public static boolean deleteRec(File path) {
-        if (path.isDirectory()) {
-            for (File f : path.listFiles()) {
-                if (!deleteRec(f)) {
-                    return false;
-                }
-            }
-        }
-        return path.delete();
-    }
-
-    public static void runScriptAndCompareWithResult(File scriptFile, PrintWriter print, File expectedFile,
-            File actualFile) throws Exception {
-        BufferedReader readerExpected = new BufferedReader(new InputStreamReader(new FileInputStream(expectedFile),
-                "UTF-8"));
-        BufferedReader readerActual = new BufferedReader(
-                new InputStreamReader(new FileInputStream(actualFile), "UTF-8"));
-        String lineExpected, lineActual;
-        int num = 1;
-        try {
-            while ((lineExpected = readerExpected.readLine()) != null) {
-                lineActual = readerActual.readLine();
-                // Assert.assertEquals(lineExpected, lineActual);
-                if (lineActual == null) {
-                    if (lineExpected.isEmpty()) {
-                        continue;
-                    }
-                    throw new Exception("Result for " + scriptFile + " changed at line " + num + ":\n< " + lineExpected
-                            + "\n> ");
-                }
-
-                if (!equalStrings(lineExpected.split("Timestamp")[0], lineActual.split("Timestamp")[0])) {
-                    fail("Result for " + scriptFile + " changed at line " + num + ":\n< " + lineExpected + "\n> "
-                            + lineActual);
-                }
-
-                ++num;
-            }
-            lineActual = readerActual.readLine();
-            // Assert.assertEquals(null, lineActual);
-            if (lineActual != null) {
-                throw new Exception("Result for " + scriptFile + " changed at line " + num + ":\n< \n> " + lineActual);
-            }
-            // actualFile.delete();
-        } finally {
-            readerExpected.close();
-            readerActual.close();
-        }
-
-    }
-
-    private static boolean equalStrings(String s1, String s2) {
-        String[] rowsOne = s1.split("\n");
-        String[] rowsTwo = s2.split("\n");
-
-        for (int i = 0; i < rowsOne.length; i++) {
-            String row1 = rowsOne[i];
-            String row2 = rowsTwo[i];
-
-            if (row1.equals(row2))
-                continue;
-
-            String[] fields1 = row1.split(" ");
-            String[] fields2 = row2.split(" ");
-
-            for (int j = 0; j < fields1.length; j++) {
-                if (fields1[j].equals(fields2[j])) {
-                    continue;
-                } else if (fields1[j].indexOf('.') < 0) {
-                    return false;
-                } else {
-                    fields1[j] = fields1[j].split(",")[0];
-                    fields2[j] = fields2[j].split(",")[0];
-                    Double double1 = Double.parseDouble(fields1[j]);
-                    Double double2 = Double.parseDouble(fields2[j]);
-                    float float1 = (float) double1.doubleValue();
-                    float float2 = (float) double2.doubleValue();
-
-                    if (Math.abs(float1 - float2) == 0)
-                        continue;
-                    else {
-                        return false;
-                    }
-                }
-            }
-        }
-        return true;
-    }
-
-    public static String aqlExtToResExt(String fname) {
-        int dot = fname.lastIndexOf('.');
-        return fname.substring(0, dot + 1) + EXTENSION_AQL_RESULT;
-    }
-
-    public static void writeResultsToFile(File actualFile, JSONObject result) throws IOException, JSONException {
-        BufferedWriter writer = new BufferedWriter(new FileWriter(actualFile));
-        Results res = new Results(result);
-        for (String line : res) {
-            writer.write(line);
-            writer.newLine();
-        }
-        writer.close();
-    }
-
-    public static class Results implements Iterable<String> {
-        private final JSONArray chunks;
-
-        public Results(JSONObject result) throws JSONException {
-            chunks = result.getJSONArray("results");
-        }
-
-        public Iterator<String> iterator() {
-            return new ResultIterator(chunks);
-        }
-    }
-
-    public static class ResultIterator implements Iterator<String> {
-        private final JSONArray chunks;
-
-        private int chunkCounter = 0;
-        private int recordCounter = 0;
-
-        public ResultIterator(JSONArray chunks) {
-            this.chunks = chunks;
-        }
-
-        @Override
-        public boolean hasNext() {
-            JSONArray resultArray;
-            try {
-                resultArray = chunks.getJSONArray(chunkCounter);
-                if (resultArray.getString(recordCounter) != null) {
-                    return true;
-                }
-            } catch (JSONException e) {
-                return false;
-            }
-            return false;
-        }
-
-        @Override
-        public String next() throws NoSuchElementException {
-            JSONArray resultArray;
-            String item = "";
-
-            try {
-                resultArray = chunks.getJSONArray(chunkCounter);
-                item = resultArray.getString(recordCounter);
-                if (item == null) {
-                    throw new NoSuchElementException();
-                }
-                item = item.trim();
-
-                recordCounter++;
-                if (recordCounter >= resultArray.length()) {
-                    chunkCounter++;
-                    recordCounter = 0;
-                }
-            } catch (JSONException e) {
-                throw new NoSuchElementException(e.getMessage());
-            }
-            return item;
-        }
-
-        @Override
-        public void remove() {
-            throw new NotImplementedException();
-        }
-    }
-}
diff --git a/asterix-app/src/test/java/edu/uci/ics/asterix/test/metadata/MetadataTest.java b/asterix-app/src/test/java/edu/uci/ics/asterix/test/metadata/MetadataTest.java
index 56259fa..dfbd305 100644
--- a/asterix-app/src/test/java/edu/uci/ics/asterix/test/metadata/MetadataTest.java
+++ b/asterix-app/src/test/java/edu/uci/ics/asterix/test/metadata/MetadataTest.java
@@ -14,23 +14,11 @@
  */
 package edu.uci.ics.asterix.test.metadata;
 
-import java.io.BufferedReader;
 import java.io.File;
-import java.io.FileReader;
-import java.io.PrintWriter;
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.List;
-import java.util.logging.Logger;
 
-import org.apache.commons.httpclient.DefaultHttpMethodRetryHandler;
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.HttpStatus;
-import org.apache.commons.httpclient.NameValuePair;
-import org.apache.commons.httpclient.methods.GetMethod;
-import org.apache.commons.httpclient.params.HttpMethodParams;
 import org.apache.commons.io.FileUtils;
-import org.json.JSONObject;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -42,8 +30,6 @@
 import edu.uci.ics.asterix.common.config.GlobalConfig;
 import edu.uci.ics.asterix.test.aql.TestsUtils;
 import edu.uci.ics.asterix.testframework.context.TestCaseContext;
-import edu.uci.ics.asterix.testframework.context.TestFileContext;
-import edu.uci.ics.asterix.testframework.xml.TestCase.CompilationUnit;
 
 /**
  * Executes the Metadata tests.
@@ -53,10 +39,9 @@
 
     private TestCaseContext tcCtx;
 
-    private static final Logger LOGGER = Logger.getLogger(MetadataTest.class.getName());
     private static final String PATH_ACTUAL = "mdtest/";
     private static final String PATH_BASE = "src/test/resources/metadata/";
-    private static final String TEST_CONFIG_FILE_NAME = "test.properties";
+    private static final String TEST_CONFIG_FILE_NAME = "asterix-build-configuration.xml";
     private static final String WEB_SERVER_PORT = "19002";
 
     @BeforeClass
@@ -109,184 +94,9 @@
         this.tcCtx = tcCtx;
     }
 
-    // Method that reads a DDL/Update/Query File
-    // and returns the contents as a string
-    // This string is later passed to REST API for execution.
-    public String readTestFile(File testFile) throws Exception {
-        BufferedReader reader = new BufferedReader(new FileReader(testFile));
-        String line = null;
-        StringBuilder stringBuilder = new StringBuilder();
-        String ls = System.getProperty("line.separator");
-
-        while ((line = reader.readLine()) != null) {
-            stringBuilder.append(line);
-            stringBuilder.append(ls);
-        }
-
-        return stringBuilder.toString();
-    }
-
-    // To execute DDL and Update statements
-    // create type statement
-    // create dataset statement
-    // create index statement
-    // create dataverse statement
-    // create function statement
-    public void executeDDL(String str) throws Exception {
-        final String url = "http://localhost:19101/ddl";
-
-        // Create an instance of HttpClient.
-        HttpClient client = new HttpClient();
-
-        // Create a method instance.
-        GetMethod method = new GetMethod(url);
-
-        method.setQueryString(new NameValuePair[] { new NameValuePair("ddl", str) });
-
-        // Provide custom retry handler is necessary
-        method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(3, false));
-
-        // Execute the method.
-        int statusCode = client.executeMethod(method);
-
-        // Read the response body as String.
-        String responseBody = method.getResponseBodyAsString();
-
-        // Check if the method was executed successfully.
-        if (statusCode != HttpStatus.SC_OK) {
-            System.err.println("Method failed: " + method.getStatusLine());
-        }
-    }
-
-    // To execute Update statements
-    // Insert and Delete statements are executed here
-    public void executeUpdate(String str) throws Exception {
-        final String url = "http://localhost:19101/update";
-
-        // Create an instance of HttpClient.
-        HttpClient client = new HttpClient();
-
-        // Create a method instance.
-        GetMethod method = new GetMethod(url);
-
-        method.setQueryString(new NameValuePair[] { new NameValuePair("statements", str) });
-
-        // Provide custom retry handler is necessary
-        method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(3, false));
-
-        // Execute the method.
-        int statusCode = client.executeMethod(method);
-
-        // Read the response body as String.
-        String responseBody = method.getResponseBodyAsString();
-
-        // Check if the method was executed successfully.
-        if (statusCode != HttpStatus.SC_OK) {
-            System.err.println("Method failed: " + method.getStatusLine());
-        }
-    }
-
-    // Executes Query and returns results as JSONArray
-    public JSONObject executeQuery(String str) throws Exception {
-
-        final String url = "http://localhost:19101/query";
-
-        // Create an instance of HttpClient.
-        HttpClient client = new HttpClient();
-
-        // Create a method instance.
-        GetMethod method = new GetMethod(url);
-
-        method.setQueryString(new NameValuePair[] { new NameValuePair("query", str) });
-
-        // Provide custom retry handler is necessary
-        method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(3, false));
-
-        JSONObject result = null;
-
-        try {
-            // Execute the method.
-            int statusCode = client.executeMethod(method);
-
-            // Check if the method was executed successfully.
-            if (statusCode != HttpStatus.SC_OK) {
-                System.err.println("Method failed: " + method.getStatusLine());
-            }
-
-            // Read the response body as String.
-            String responseBody = method.getResponseBodyAsString();
-
-            result = new JSONObject(responseBody);
-        } catch (Exception e) {
-            System.out.println(e.getMessage());
-            e.printStackTrace();
-        }
-        return result;
-    }
-
     @Test
     public void test() throws Exception {
-        List<TestFileContext> testFileCtxs;
-        List<TestFileContext> expectedResultFileCtxs;
-
-        File testFile;
-        File expectedResultFile;
-        String statement;
-
-        int queryCount = 0;
-        JSONObject result;
-
-        List<CompilationUnit> cUnits = tcCtx.getTestCase().getCompilationUnit();
-        for (CompilationUnit cUnit : cUnits) {
-            testFileCtxs = tcCtx.getTestFiles(cUnit);
-            expectedResultFileCtxs = tcCtx.getExpectedResultFiles(cUnit);
-
-            for (TestFileContext ctx : testFileCtxs) {
-                testFile = ctx.getFile();
-                statement = readTestFile(testFile);
-                try {
-                    switch (ctx.getType()) {
-                        case "ddl":
-                            executeDDL(statement);
-                            break;
-                        case "update":
-                            executeUpdate(statement);
-                            break;
-                        case "query":
-                            result = executeQuery(statement);
-                            if (!cUnit.getExpectedError().isEmpty()) {
-                                if (!result.has("error")) {
-                                    throw new Exception("Test \"" + testFile + "\" FAILED!");
-                                }
-                            } else {
-                                expectedResultFile = expectedResultFileCtxs.get(queryCount).getFile();
-
-                                File actualFile = new File(PATH_ACTUAL + File.separator
-                                        + tcCtx.getTestCase().getFilePath().replace(File.separator, "_") + "_"
-                                        + cUnit.getName() + ".adm");
-
-                                File actualResultFile = tcCtx.getActualResultFile(cUnit, new File(PATH_ACTUAL));
-                                actualResultFile.getParentFile().mkdirs();
-
-                                TestsUtils.writeResultsToFile(actualFile, result);
-
-                                TestsUtils.runScriptAndCompareWithResult(testFile, new PrintWriter(System.err),
-                                        expectedResultFile, actualFile);
-                            }
-                            queryCount++;
-                            break;
-                        default:
-                            throw new IllegalArgumentException("No statements of type " + ctx.getType());
-                    }
-                } catch (Exception e) {
-                    LOGGER.severe("Test \"" + testFile + "\" FAILED!");
-                    e.printStackTrace();
-                    if (cUnit.getExpectedError().isEmpty()) {
-                        throw new Exception("Test \"" + testFile + "\" FAILED!", e);
-                    }
-                }
-            }
-        }
+        TestsUtils.executeTest(PATH_ACTUAL, tcCtx);
     }
 
-}
+}
\ No newline at end of file
diff --git a/asterix-app/src/test/java/edu/uci/ics/asterix/test/optimizer/OptimizerTest.java b/asterix-app/src/test/java/edu/uci/ics/asterix/test/optimizer/OptimizerTest.java
index 8530ba1..0f1f8b5 100644
--- a/asterix-app/src/test/java/edu/uci/ics/asterix/test/optimizer/OptimizerTest.java
+++ b/asterix-app/src/test/java/edu/uci/ics/asterix/test/optimizer/OptimizerTest.java
@@ -47,7 +47,7 @@
 
     private static final ArrayList<String> ignore = AsterixTestHelper.readFile(FILENAME_IGNORE, PATH_BASE);
     private static final ArrayList<String> only = AsterixTestHelper.readFile(FILENAME_ONLY, PATH_BASE);
-    private static final String TEST_CONFIG_FILE_NAME = "asterix-metadata.properties";
+    private static final String TEST_CONFIG_FILE_NAME = "asterix-build-configuration.xml";
 
     @BeforeClass
     public static void setUp() throws Exception {
@@ -58,12 +58,12 @@
         System.setProperty(GlobalConfig.WEB_SERVER_PORT_PROPERTY, "19002");
         File outdir = new File(PATH_ACTUAL);
         outdir.mkdirs();
-        
+
         File log = new File("asterix_logs");
         if (log.exists()) {
-            FileUtils.deleteDirectory(log); 
+            FileUtils.deleteDirectory(log);
         }
-        
+
         AsterixHyracksIntegrationUtil.init();
         // Set the node resolver to be the identity resolver that expects node names 
         // to be node controller ids; a valid assumption in test environment. 
@@ -79,10 +79,10 @@
         if (files == null || files.length == 0) {
             outdir.delete();
         }
-        
+
         File log = new File("asterix_logs");
         if (log.exists()) {
-            FileUtils.deleteDirectory(log); 
+            FileUtils.deleteDirectory(log);
         }
     }
 
@@ -138,7 +138,7 @@
             }
             Assume.assumeTrue(!skipped);
 
-            LOGGER.severe("RUN TEST: \"" + queryFile.getPath() + "\"");
+            LOGGER.info("RUN TEST: \"" + queryFile.getPath() + "\"");
             Reader query = new BufferedReader(new InputStreamReader(new FileInputStream(queryFile), "UTF-8"));
             PrintWriter plan = new PrintWriter(actualFile);
             AsterixJavaClient asterix = new AsterixJavaClient(
@@ -180,7 +180,7 @@
                     throw new Exception("Result for " + queryFile + " changed at line " + num + ":\n< \n> "
                             + lineActual);
                 }
-                LOGGER.severe("Test \"" + queryFile.getPath() + "\" PASSED!");
+                LOGGER.info("Test \"" + queryFile.getPath() + "\" PASSED!");
                 actualFile.delete();
             } finally {
                 readerExpected.close();
diff --git a/asterix-app/src/test/java/edu/uci/ics/asterix/test/runtime/ExecutionTest.java b/asterix-app/src/test/java/edu/uci/ics/asterix/test/runtime/ExecutionTest.java
index 4bd52fb..2289484 100644
--- a/asterix-app/src/test/java/edu/uci/ics/asterix/test/runtime/ExecutionTest.java
+++ b/asterix-app/src/test/java/edu/uci/ics/asterix/test/runtime/ExecutionTest.java
@@ -1,22 +1,10 @@
 package edu.uci.ics.asterix.test.runtime;
 
-import java.io.BufferedReader;
 import java.io.File;
-import java.io.FileReader;
-import java.io.PrintWriter;
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.List;
-import java.util.logging.Logger;
 
-import org.apache.commons.httpclient.DefaultHttpMethodRetryHandler;
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.HttpStatus;
-import org.apache.commons.httpclient.NameValuePair;
-import org.apache.commons.httpclient.methods.GetMethod;
-import org.apache.commons.httpclient.params.HttpMethodParams;
 import org.apache.commons.io.FileUtils;
-import org.json.JSONObject;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -30,8 +18,6 @@
 import edu.uci.ics.asterix.external.util.IdentitiyResolverFactory;
 import edu.uci.ics.asterix.test.aql.TestsUtils;
 import edu.uci.ics.asterix.testframework.context.TestCaseContext;
-import edu.uci.ics.asterix.testframework.context.TestFileContext;
-import edu.uci.ics.asterix.testframework.xml.TestCase.CompilationUnit;
 
 /**
  * Runs the runtime test cases under 'asterix-app/src/test/resources/runtimets'.
@@ -41,13 +27,9 @@
     private static final String PATH_ACTUAL = "rttest/";
     private static final String PATH_BASE = "src/test/resources/runtimets/";
 
-    private static final String TEST_CONFIG_FILE_NAME = "test.properties";
+    private static final String TEST_CONFIG_FILE_NAME = "asterix-build-configuration.xml";
     private static final String[] ASTERIX_DATA_DIRS = new String[] { "nc1data", "nc2data" };
 
-    private static final Logger LOGGER = Logger.getLogger(ExecutionTest.class.getName());
-
-    // private static NCBootstrapImpl _bootstrap = new NCBootstrapImpl();
-
     @BeforeClass
     public static void setUp() throws Exception {
         System.setProperty(GlobalConfig.CONFIG_FILE_PROPERTY, TEST_CONFIG_FILE_NAME);
@@ -108,181 +90,8 @@
         this.tcCtx = tcCtx;
     }
 
-    // Method that reads a DDL/Update/Query File
-    // and returns the contents as a string
-    // This string is later passed to REST API for execution.
-    public String readTestFile(File testFile) throws Exception {
-        BufferedReader reader = new BufferedReader(new FileReader(testFile));
-        String line = null;
-        StringBuilder stringBuilder = new StringBuilder();
-        String ls = System.getProperty("line.separator");
-
-        while ((line = reader.readLine()) != null) {
-            stringBuilder.append(line);
-            stringBuilder.append(ls);
-        }
-
-        return stringBuilder.toString();
-    }
-
-    // To execute DDL and Update statements
-    // create type statement
-    // create dataset statement
-    // create index statement
-    // create dataverse statement
-    // create function statement
-    public void executeDDL(String str) throws Exception {
-        final String url = "http://localhost:19101/ddl";
-
-        // Create an instance of HttpClient.
-        HttpClient client = new HttpClient();
-
-        // Create a method instance.
-        GetMethod method = new GetMethod(url);
-
-        method.setQueryString(new NameValuePair[] { new NameValuePair("ddl", str) });
-
-        // Provide custom retry handler is necessary
-        method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(3, false));
-
-        // Execute the method.
-        int statusCode = client.executeMethod(method);
-
-        LOGGER.info("DDL: " + method.getResponseBodyAsString());
-
-        // Check if the method was executed successfully.
-        if (statusCode != HttpStatus.SC_OK) {
-            System.err.println("Method failed: " + method.getStatusLine());
-        }
-    }
-
-    // To execute Update statements
-    // Insert and Delete statements are executed here
-    public void executeUpdate(String str) throws Exception {
-        final String url = "http://localhost:19101/update";
-
-        // Create an instance of HttpClient.
-        HttpClient client = new HttpClient();
-
-        // Create a method instance.
-        GetMethod method = new GetMethod(url);
-
-        method.setQueryString(new NameValuePair[] { new NameValuePair("statements", str) });
-
-        // Provide custom retry handler is necessary
-        method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(3, false));
-
-        // Execute the method.
-        int statusCode = client.executeMethod(method);
-
-        LOGGER.info("Update: " + method.getResponseBodyAsString());
-
-        // Check if the method was executed successfully.
-        if (statusCode != HttpStatus.SC_OK) {
-            System.err.println("Method failed: " + method.getStatusLine());
-        }
-    }
-
-    // Executes Query and returns results as JSONArray
-    public JSONObject executeQuery(String str) throws Exception {
-
-        final String url = "http://localhost:19101/query";
-
-        // Create an instance of HttpClient.
-        HttpClient client = new HttpClient();
-
-        // Create a method instance.
-        GetMethod method = new GetMethod(url);
-
-        method.setQueryString(new NameValuePair[] { new NameValuePair("query", str) });
-
-        // Provide custom retry handler is necessary
-        method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(3, false));
-
-        JSONObject result = null;
-
-        try {
-            // Execute the method.
-            int statusCode = client.executeMethod(method);
-
-            // Check if the method was executed successfully.
-            if (statusCode != HttpStatus.SC_OK) {
-                System.err.println("Method failed: " + method.getStatusLine());
-            }
-
-            // Read the response body as String.
-            String responseBody = method.getResponseBodyAsString();
-
-            result = new JSONObject(responseBody);
-        } catch (Exception e) {
-            System.out.println(e.getMessage());
-            e.printStackTrace();
-        }
-        return result;
-    }
-
     @Test
     public void test() throws Exception {
-        List<TestFileContext> testFileCtxs;
-        List<TestFileContext> expectedResultFileCtxs;
-
-        File testFile;
-        File expectedResultFile;
-        String statement;
-
-        int queryCount = 0;
-        JSONObject result;
-
-        List<CompilationUnit> cUnits = tcCtx.getTestCase().getCompilationUnit();
-        for (CompilationUnit cUnit : cUnits) {
-            LOGGER.info("[TEST]: " + tcCtx.getTestCase().getFilePath() + "/" + cUnit.getName());
-
-            testFileCtxs = tcCtx.getTestFiles(cUnit);
-            expectedResultFileCtxs = tcCtx.getExpectedResultFiles(cUnit);
-
-            for (TestFileContext ctx : testFileCtxs) {
-                testFile = ctx.getFile();
-                statement = readTestFile(testFile);
-                try {
-                    switch (ctx.getType()) {
-                        case "ddl":
-                            executeDDL(statement);
-                            break;
-                        case "update":
-                            executeUpdate(statement);
-                            break;
-                        case "query":
-                            result = executeQuery(statement);
-                            if (!cUnit.getExpectedError().isEmpty()) {
-                                if (!result.has("error")) {
-                                    throw new Exception("Test \"" + testFile + "\" FAILED!");
-                                }
-                            } else {
-                                expectedResultFile = expectedResultFileCtxs.get(queryCount).getFile();
-
-                                File actualFile = new File(PATH_ACTUAL + File.separator
-                                        + tcCtx.getTestCase().getFilePath().replace(File.separator, "_") + "_"
-                                        + cUnit.getName() + ".adm");
-
-                                File actualResultFile = tcCtx.getActualResultFile(cUnit, new File(PATH_ACTUAL));
-                                actualResultFile.getParentFile().mkdirs();
-
-                                TestsUtils.writeResultsToFile(actualFile, result);
-
-                                TestsUtils.runScriptAndCompareWithResult(testFile, new PrintWriter(System.err),
-                                        expectedResultFile, actualFile);
-                            }
-                            queryCount++;
-                            break;
-                        default:
-                            throw new IllegalArgumentException("No statements of type " + ctx.getType());
-                    }
-                } catch (Exception e) {
-                    if (cUnit.getExpectedError().isEmpty()) {
-                        throw new Exception("Test \"" + testFile + "\" FAILED!", e);
-                    }
-                }
-            }
-        }
+        TestsUtils.executeTest(PATH_ACTUAL, tcCtx);
     }
 }
diff --git a/asterix-app/src/test/resources/logging.properties b/asterix-app/src/test/resources/logging.properties
index deb88307..6f8cd00 100644
--- a/asterix-app/src/test/resources/logging.properties
+++ b/asterix-app/src/test/resources/logging.properties
@@ -60,6 +60,7 @@
 # For example, set the com.xyz.foo logger to only log SEVERE
 # messages:
 
+edu.uci.ics.asterix.test.level = INFO
 #edu.uci.ics.asterix.level = FINE
 #edu.uci.ics.algebricks.level = FINE
 #edu.uci.ics.hyracks.level = INFO
diff --git a/asterix-app/src/test/resources/metadata/queries/exception/issue_255_create_dataset_error_1/issue_255_create_dataset_error_1.1.ddl.aql b/asterix-app/src/test/resources/metadata/queries/exception/issue_255_create_dataset_error_1/issue_255_create_dataset_error_1.1.ddl.aql
new file mode 100644
index 0000000..132d63e
--- /dev/null
+++ b/asterix-app/src/test/resources/metadata/queries/exception/issue_255_create_dataset_error_1/issue_255_create_dataset_error_1.1.ddl.aql
@@ -0,0 +1,16 @@
+/*
+ * Description  : create a dataset partitioned on non-existent field
+ * Expected Res : Failure
+ * Date         : 14 April 2013
+ * Issue        : 255
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type opentype as open {
+id:int32
+}
+
+create dataset testds(opentype) primary key name;
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/metadata/queries/exception/issue_255_create_dataset_error_2/issue_255_create_dataset_error_2.1.ddl.aql b/asterix-app/src/test/resources/metadata/queries/exception/issue_255_create_dataset_error_2/issue_255_create_dataset_error_2.1.ddl.aql
new file mode 100644
index 0000000..e900e6d
--- /dev/null
+++ b/asterix-app/src/test/resources/metadata/queries/exception/issue_255_create_dataset_error_2/issue_255_create_dataset_error_2.1.ddl.aql
@@ -0,0 +1,21 @@
+/*
+ * Description  : create a dataset partitioned on ARecord type
+ * Expected Res : Failure
+ * Date         : 14 April 2013
+ * Issue        : 255
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type opentype1 as open {
+id:int32
+}
+
+create type opentype2 as open {
+id:int32,
+open-type:opentype1
+}
+
+create dataset testds(opentype2) primary key open-type;
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/metadata/queries/exception/issue_255_create_feed_error/issue_255_create_feed_error.1.ddl.aql b/asterix-app/src/test/resources/metadata/queries/exception/issue_255_create_feed_error/issue_255_create_feed_error.1.ddl.aql
new file mode 100644
index 0000000..7576da7
--- /dev/null
+++ b/asterix-app/src/test/resources/metadata/queries/exception/issue_255_create_feed_error/issue_255_create_feed_error.1.ddl.aql
@@ -0,0 +1,23 @@
+/*
+ * Description  : create a dataset partitioned on non-existent field
+ * Expected Res : Failure
+ * Date         : 14 April 2013
+ * Issue        : 255
+ */
+
+drop dataverse feeds if exists;
+create dataverse feeds;
+use dataverse feeds;
+
+create type TweetType as closed {
+  id: string,
+  username : string,
+  location : string,
+  text : string,
+  timestamp : string
+}      
+
+create feed dataset TweetFeed(TweetType)
+using "edu.uci.ics.asterix.tools.external.data.RateControlledFileSystemBasedAdapterFactory"
+(("output-type-name"="TweetType"),("fs"="localfs"),("path"="nc1://data/twitter/obamatweets.adm"),("format"="adm"),("tuple-interval"="10"))
+primary key name;
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/metadata/queries/exception/issue_266_create_dataset_error_1/issue_266_create_dataset_error_1.1.ddl.aql b/asterix-app/src/test/resources/metadata/queries/exception/issue_266_create_dataset_error_1/issue_266_create_dataset_error_1.1.ddl.aql
new file mode 100644
index 0000000..717ba21
--- /dev/null
+++ b/asterix-app/src/test/resources/metadata/queries/exception/issue_266_create_dataset_error_1/issue_266_create_dataset_error_1.1.ddl.aql
@@ -0,0 +1,16 @@
+/*
+ * Description  : create a dataset partitioned on unallowed key type
+ * Expected Res : Failure
+ * Date         : 22 April 2013
+ * Issue        : 266
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type opentype as open {
+loc:point
+}
+
+create dataset testds(opentype) primary key point;
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/metadata/queries/exception/issue_266_create_dataset_error_2/issue_266_create_dataset_error_2.1.ddl.aql b/asterix-app/src/test/resources/metadata/queries/exception/issue_266_create_dataset_error_2/issue_266_create_dataset_error_2.1.ddl.aql
new file mode 100644
index 0000000..cda7ae9
--- /dev/null
+++ b/asterix-app/src/test/resources/metadata/queries/exception/issue_266_create_dataset_error_2/issue_266_create_dataset_error_2.1.ddl.aql
@@ -0,0 +1,16 @@
+/*
+ * Description  : create a dataset partitioned on nullable key type
+ * Expected Res : Failure
+ * Date         : 22 April 2013
+ * Issue        : 266
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+use dataverse test;
+
+create type opentype as open {
+id:int32?
+}
+
+create dataset testds(opentype) primary key id;
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/metadata/queries/exception/issue_272_create_index_error_1/issue_272_create_index_error_1.1.ddl.aql b/asterix-app/src/test/resources/metadata/queries/exception/issue_272_create_index_error_1/issue_272_create_index_error_1.1.ddl.aql
new file mode 100644
index 0000000..6ba4d86
--- /dev/null
+++ b/asterix-app/src/test/resources/metadata/queries/exception/issue_272_create_index_error_1/issue_272_create_index_error_1.1.ddl.aql
@@ -0,0 +1,13 @@
+/*
+ * Description  : create an index on a non-existent dataset
+ * Expected Res : Failure
+ * Date         : 14 April 2013
+ * Issue        : 272
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+
+use dataverse test;
+create index loc_index on Foo(name);
+
diff --git a/asterix-app/src/test/resources/metadata/queries/exception/issue_272_create_index_error_2/issue_272_create_index_error_2.1.ddl.aql b/asterix-app/src/test/resources/metadata/queries/exception/issue_272_create_index_error_2/issue_272_create_index_error_2.1.ddl.aql
new file mode 100644
index 0000000..a1f9771
--- /dev/null
+++ b/asterix-app/src/test/resources/metadata/queries/exception/issue_272_create_index_error_2/issue_272_create_index_error_2.1.ddl.aql
@@ -0,0 +1,14 @@
+/*
+ * Description  : create an index on a non-existent dataset
+ * Expected Res : Failure
+ * Date         : 14 April 2013
+ * Issue        : 272
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+
+use dataverse test;
+
+create index loc_index if not exists on Foo(name);
+
diff --git a/asterix-app/src/test/resources/metadata/queries/exception/issue_384_create_index_error_1/issue_384_create_index_error_1.1.ddl.aql b/asterix-app/src/test/resources/metadata/queries/exception/issue_384_create_index_error_1/issue_384_create_index_error_1.1.ddl.aql
new file mode 100644
index 0000000..acc89db
--- /dev/null
+++ b/asterix-app/src/test/resources/metadata/queries/exception/issue_384_create_index_error_1/issue_384_create_index_error_1.1.ddl.aql
@@ -0,0 +1,20 @@
+/*
+ * Description  : create a btree index on unallowed key type.
+ * Expected Res : Failure
+ * Date         : 23 April 2013
+ * Issue        : 384
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+
+use dataverse test;
+
+create type opentype as open {
+id:int32,
+loc:point
+}
+
+create dataset testds(opentype) primary key id;
+create index loc_index on testds(loc);
+
diff --git a/asterix-app/src/test/resources/metadata/queries/exception/issue_384_create_index_error_2/issue_384_create_index_error_2.1.ddl.aql b/asterix-app/src/test/resources/metadata/queries/exception/issue_384_create_index_error_2/issue_384_create_index_error_2.1.ddl.aql
new file mode 100644
index 0000000..f3ec8b2
--- /dev/null
+++ b/asterix-app/src/test/resources/metadata/queries/exception/issue_384_create_index_error_2/issue_384_create_index_error_2.1.ddl.aql
@@ -0,0 +1,20 @@
+/*
+ * Description  : create an rtree index on unallowed key type.
+ * Expected Res : Failure
+ * Date         : 23 April 2013
+ * Issue        : 384
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+
+use dataverse test;
+
+create type opentype as open {
+id:int32,
+age:int32
+}
+
+create dataset testds(opentype) primary key id;
+create index loc_index on testds(age) type rtree;
+
diff --git a/asterix-app/src/test/resources/metadata/queries/exception/issue_384_create_index_error_3/issue_384_create_index_error_3.1.ddl.aql b/asterix-app/src/test/resources/metadata/queries/exception/issue_384_create_index_error_3/issue_384_create_index_error_3.1.ddl.aql
new file mode 100644
index 0000000..4d8c488
--- /dev/null
+++ b/asterix-app/src/test/resources/metadata/queries/exception/issue_384_create_index_error_3/issue_384_create_index_error_3.1.ddl.aql
@@ -0,0 +1,20 @@
+/*
+ * Description  : create a keyword index on unallowed key type.
+ * Expected Res : Failure
+ * Date         : 23 April 2013
+ * Issue        : 384
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+
+use dataverse test;
+
+create type opentype as open {
+id:int32,
+loc:point
+}
+
+create dataset testds(opentype) primary key id;
+create index loc_index on testds(loc) type keyword;
+
diff --git a/asterix-app/src/test/resources/metadata/queries/exception/issue_384_create_index_error_4/issue_384_create_index_error_4.1.ddl.aql b/asterix-app/src/test/resources/metadata/queries/exception/issue_384_create_index_error_4/issue_384_create_index_error_4.1.ddl.aql
new file mode 100644
index 0000000..938f137
--- /dev/null
+++ b/asterix-app/src/test/resources/metadata/queries/exception/issue_384_create_index_error_4/issue_384_create_index_error_4.1.ddl.aql
@@ -0,0 +1,20 @@
+/*
+ * Description  : create a fuzzy keyword index on unallowed key type.
+ * Expected Res : Failure
+ * Date         : 23 April 2013
+ * Issue        : 384
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+
+use dataverse test;
+
+create type opentype as open {
+id:int32,
+loc:point
+}
+
+create dataset testds(opentype) primary key id;
+create index loc_index on testds(loc) type fuzzy keyword;
+
diff --git a/asterix-app/src/test/resources/metadata/queries/exception/issue_384_create_index_error_5/issue_384_create_index_error_5.1.ddl.aql b/asterix-app/src/test/resources/metadata/queries/exception/issue_384_create_index_error_5/issue_384_create_index_error_5.1.ddl.aql
new file mode 100644
index 0000000..d9baf04
--- /dev/null
+++ b/asterix-app/src/test/resources/metadata/queries/exception/issue_384_create_index_error_5/issue_384_create_index_error_5.1.ddl.aql
@@ -0,0 +1,20 @@
+/*
+ * Description  : create an ngram index on unallowed key type.
+ * Expected Res : Failure
+ * Date         : 23 April 2013
+ * Issue        : 384
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+
+use dataverse test;
+
+create type opentype as open {
+id:int32,
+loc:point
+}
+
+create dataset testds(opentype) primary key id;
+create index loc_index on testds(loc) type ngram(2);
+
diff --git a/asterix-app/src/test/resources/metadata/queries/exception/issue_384_create_index_error_6/issue_384_create_index_error_6.1.ddl.aql b/asterix-app/src/test/resources/metadata/queries/exception/issue_384_create_index_error_6/issue_384_create_index_error_6.1.ddl.aql
new file mode 100644
index 0000000..dee287d
--- /dev/null
+++ b/asterix-app/src/test/resources/metadata/queries/exception/issue_384_create_index_error_6/issue_384_create_index_error_6.1.ddl.aql
@@ -0,0 +1,20 @@
+/*
+ * Description  : create a fuzzy ngram index on unallowed key type.
+ * Expected Res : Failure
+ * Date         : 23 April 2013
+ * Issue        : 384
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+
+use dataverse test;
+
+create type opentype as open {
+id:int32,
+loc:point
+}
+
+create dataset testds(opentype) primary key id;
+create index loc_index on testds(loc) type fuzzy ngram(2);
+
diff --git a/asterix-app/src/test/resources/metadata/testsuite.xml b/asterix-app/src/test/resources/metadata/testsuite.xml
index d4fb915..47bcafa 100644
--- a/asterix-app/src/test/resources/metadata/testsuite.xml
+++ b/asterix-app/src/test/resources/metadata/testsuite.xml
@@ -212,6 +212,84 @@
         <expected-error>AsterixException</expected-error>
       </compilation-unit>
     </test-case>
+    <test-case FilePath="exception">
+      <compilation-unit name="issue_272_create_index_error_1">
+        <output-dir compare="Text">none</output-dir>
+        <expected-error>edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException</expected-error>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="exception">
+      <compilation-unit name="issue_272_create_index_error_2">
+        <output-dir compare="Text">none</output-dir>
+        <expected-error>edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException</expected-error>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="exception">
+      <compilation-unit name="issue_255_create_dataset_error_1">
+        <output-dir compare="Text">none</output-dir>
+        <expected-error>edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException</expected-error>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="exception">
+      <compilation-unit name="issue_255_create_dataset_error_2">
+        <output-dir compare="Text">none</output-dir>
+        <expected-error>edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException</expected-error>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="exception">
+      <compilation-unit name="issue_255_create_feed_error">
+        <output-dir compare="Text">none</output-dir>
+        <expected-error>edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException</expected-error>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="exception">
+      <compilation-unit name="issue_266_create_dataset_error_1">
+        <output-dir compare="Text">none</output-dir>
+        <expected-error>edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException</expected-error>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="exception">
+      <compilation-unit name="issue_266_create_dataset_error_2">
+        <output-dir compare="Text">none</output-dir>
+        <expected-error>edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException</expected-error>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="exception">
+      <compilation-unit name="issue_384_create_index_error_1">
+        <output-dir compare="Text">none</output-dir>
+        <expected-error>edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException</expected-error>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="exception">
+      <compilation-unit name="issue_384_create_index_error_2">
+        <output-dir compare="Text">none</output-dir>
+        <expected-error>edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException</expected-error>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="exception">
+      <compilation-unit name="issue_384_create_index_error_3">
+        <output-dir compare="Text">none</output-dir>
+        <expected-error>edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException</expected-error>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="exception">
+      <compilation-unit name="issue_384_create_index_error_4">
+        <output-dir compare="Text">none</output-dir>
+        <expected-error>edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException</expected-error>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="exception">
+      <compilation-unit name="issue_384_create_index_error_5">
+        <output-dir compare="Text">none</output-dir>
+        <expected-error>edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException</expected-error>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="exception">
+      <compilation-unit name="issue_384_create_index_error_6">
+        <output-dir compare="Text">none</output-dir>
+        <expected-error>edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException</expected-error>
+      </compilation-unit>
+    </test-case>
   </test-group>
   <test-group name="transaction">
     <test-case FilePath="transaction">
@@ -233,4 +311,4 @@
       </compilation-unit>
     </test-case>
   </test-group>
-</test-suite>
+</test-suite>
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/constructor/rectangle_01/rectangle_01.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/constructor/rectangle_01/rectangle_01.1.ddl.aql
new file mode 100644
index 0000000..efde712
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/constructor/rectangle_01/rectangle_01.1.ddl.aql
@@ -0,0 +1,10 @@
+/*
+ * Description  : create a rectangle constructor
+ * Expected Res : Success
+ * Date         : 18 April 2013
+ * Issue        : 272
+ */
+ 
+drop dataverse test if exists;
+create dataverse test;
+
diff --git a/asterix-app/src/test/resources/runtimets/queries/constructor/rectangle_01/rectangle_01.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/constructor/rectangle_01/rectangle_01.2.update.aql
new file mode 100644
index 0000000..f7e538e
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/constructor/rectangle_01/rectangle_01.2.update.aql
@@ -0,0 +1,7 @@
+/*
+ * Description  : create a rectangle constructor
+ * Expected Res : Success
+ * Date         : 18 April 2013
+ * Issue        : 272
+ */
+ 
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/constructor/rectangle_01/rectangle_01.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/constructor/rectangle_01/rectangle_01.3.query.aql
new file mode 100644
index 0000000..696746f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/constructor/rectangle_01/rectangle_01.3.query.aql
@@ -0,0 +1,12 @@
+/*
+ * Description  : create a rectangle constructor
+ * Expected Res : Success
+ * Date         : 18 April 2013
+ * Issue        : 272
+ */
+ 
+use dataverse test;
+
+let $r1 := rectangle("5.1,11.8 87.6,15.6548")
+let $r2 := rectangle("0.1234,-1.00e-10 5.5487,0.48765")
+return {"rectangle1": $r1,"rectangle2": $r2}
diff --git a/asterix-app/src/test/resources/runtimets/queries/failure/delete-rtree.aql b/asterix-app/src/test/resources/runtimets/queries/failure/delete-rtree.aql
deleted file mode 100644
index 85616e4..0000000
--- a/asterix-app/src/test/resources/runtimets/queries/failure/delete-rtree.aql
+++ /dev/null
@@ -1,30 +0,0 @@
-drop dataverse test if exists;
-  
-create dataverse test;
-use dataverse test;
-
-create type MyRecord as closed {
-	id: int32,
-	tweetid: int64,
-	loc: point,
-	time: datetime,
-	text: string
-}
-
-create dataset MyData(MyRecord)
-  primary key id;
-
-create index rtree_index on MyData(loc) type rtree;
-
-load dataset MyData 
-using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
-(("path"="nc1://data/twitter/smalltweets.txt"),("format"="adm")) pre-sorted;
-
-delete $l from dataset MyData where spatial-intersect($l.loc, create-rectangle(create-point(0.0,-100.0), create-point(55.5,50.0))) die after 1000;
-
-write output to nc1:"rttest/failure_delete-rtree.adm";      
-
-for $o in dataset('MyData')
-where spatial-intersect($o.loc, create-rectangle(create-point(0.0,-100.0), create-point(55.5,50.0)))
-order by $o.id
-return {"id":$o.id}
diff --git a/asterix-app/src/test/resources/runtimets/queries/failure/delete-rtree/delete-rtree.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/failure/delete-rtree/delete-rtree.1.ddl.aql
deleted file mode 100644
index d8ab247..0000000
--- a/asterix-app/src/test/resources/runtimets/queries/failure/delete-rtree/delete-rtree.1.ddl.aql
+++ /dev/null
@@ -1,17 +0,0 @@
-drop dataverse test if exists;
-  
-create dataverse test;
-
-use dataverse test;
-
-create type MyRecord as closed {
-	id: int32,
-	tweetid: int64,
-	loc: point,
-	time: datetime,
-	text: string
-}
-
-create dataset MyData(MyRecord)
-  primary key id;
-
diff --git a/asterix-app/src/test/resources/runtimets/queries/failure/delete-rtree/delete-rtree.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/failure/delete-rtree/delete-rtree.2.update.aql
deleted file mode 100644
index 3556905..0000000
--- a/asterix-app/src/test/resources/runtimets/queries/failure/delete-rtree/delete-rtree.2.update.aql
+++ /dev/null
@@ -1,8 +0,0 @@
-use dataverse test;
-
-load dataset MyData 
-using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
-(("path"="nc1://data/twitter/smalltweets.txt"),("format"="adm")) pre-sorted;
-
-delete $l from dataset MyData where $l.id>=50 die after 1500;
-
diff --git a/asterix-app/src/test/resources/runtimets/queries/failure/delete-rtree/delete-rtree.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/failure/delete-rtree/delete-rtree.3.query.aql
deleted file mode 100644
index b33019b..0000000
--- a/asterix-app/src/test/resources/runtimets/queries/failure/delete-rtree/delete-rtree.3.query.aql
+++ /dev/null
@@ -1,5 +0,0 @@
-use dataverse test;
-
-for $o in dataset('MyData')
-order by $o.id
-return {"id":$o.id}
diff --git a/asterix-app/src/test/resources/runtimets/queries/failure/delete.aql b/asterix-app/src/test/resources/runtimets/queries/failure/delete.aql
deleted file mode 100644
index 125fd99..0000000
--- a/asterix-app/src/test/resources/runtimets/queries/failure/delete.aql
+++ /dev/null
@@ -1,38 +0,0 @@
-drop dataverse test if exists;
-  
-create dataverse test;
-use dataverse test;
-
-create type LineItemType as closed {
-  l_orderkey: int32, 
-  l_partkey: int32, 
-  l_suppkey: int32, 
-  l_linenumber: int32, 
-  l_quantity: int32, 
-  l_extendedprice: double,
-  l_discount: double, 
-  l_tax: double,
-  l_returnflag: string, 
-  l_linestatus: string, 
-  l_shipdate: string,
-  l_commitdate: string, 
-  l_receiptdate: string, 
-  l_shipinstruct: string, 
-  l_shipmode: string, 
-  l_comment: string
-}
-
-create dataset LineItem(LineItemType)
-  primary key l_orderkey, l_linenumber;
-
-load dataset LineItem 
-using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
-(("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
-
-delete $l from dataset LineItem where $l.l_orderkey>=10 die after 1000;
-
-write output to nc1:"rttest/failure_delete.adm";      
-for $c in dataset('LineItem')
-where $c.l_orderkey>=10
-order by $c.l_orderkey, $c.l_linenumber
-return $c 
diff --git a/asterix-app/src/test/resources/runtimets/queries/failure/delete/delete.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/failure/delete/delete.1.ddl.aql
deleted file mode 100644
index ea29045..0000000
--- a/asterix-app/src/test/resources/runtimets/queries/failure/delete/delete.1.ddl.aql
+++ /dev/null
@@ -1,28 +0,0 @@
-drop dataverse test if exists;
-  
-create dataverse test;
-
-use dataverse test;
-
-create type LineItemType as closed {
-  l_orderkey: int32, 
-  l_partkey: int32, 
-  l_suppkey: int32, 
-  l_linenumber: int32, 
-  l_quantity: int32, 
-  l_extendedprice: double,
-  l_discount: double, 
-  l_tax: double,
-  l_returnflag: string, 
-  l_linestatus: string, 
-  l_shipdate: string,
-  l_commitdate: string, 
-  l_receiptdate: string, 
-  l_shipinstruct: string, 
-  l_shipmode: string, 
-  l_comment: string
-}
-
-create dataset LineItem(LineItemType)
-  primary key l_orderkey, l_linenumber;
-
diff --git a/asterix-app/src/test/resources/runtimets/queries/failure/delete/delete.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/failure/delete/delete.2.update.aql
deleted file mode 100644
index ac2bd60..0000000
--- a/asterix-app/src/test/resources/runtimets/queries/failure/delete/delete.2.update.aql
+++ /dev/null
@@ -1,8 +0,0 @@
-use dataverse test;
-
-load dataset LineItem 
-using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
-(("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
-
-delete $l from dataset LineItem where $l.l_orderkey>=10 die after 1500;
-
diff --git a/asterix-app/src/test/resources/runtimets/queries/failure/delete/delete.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/failure/delete/delete.3.query.aql
deleted file mode 100644
index 9375d30..0000000
--- a/asterix-app/src/test/resources/runtimets/queries/failure/delete/delete.3.query.aql
+++ /dev/null
@@ -1,6 +0,0 @@
-use dataverse test;
-    
-for $c in dataset('LineItem')
-where $c.l_orderkey>=10
-order by $c.l_orderkey, $c.l_linenumber
-return $c 
diff --git a/asterix-app/src/test/resources/runtimets/queries/failure/insert-rtree/insert-rtree.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/failure/insert-rtree/insert-rtree.1.ddl.aql
deleted file mode 100644
index 0cb052d..0000000
--- a/asterix-app/src/test/resources/runtimets/queries/failure/insert-rtree/insert-rtree.1.ddl.aql
+++ /dev/null
@@ -1,25 +0,0 @@
-drop dataverse test if exists;
-
-create dataverse test;
-
-use dataverse test;
-
-create type MyRecord as closed {
-	id: int32,
-	tweetid: int64,
-	loc: point,
-	time: datetime,
-	text: string
-}
-
-create type MyMiniRecord as closed {
-  id: int32,
-  loc: point
-}
-
-create dataset MyData(MyRecord)
-  primary key id;
-
-create dataset MyMiniData(MyMiniRecord)
-  primary key id;
-
diff --git a/asterix-app/src/test/resources/runtimets/queries/failure/insert-rtree/insert-rtree.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/failure/insert-rtree/insert-rtree.2.update.aql
deleted file mode 100644
index bffd599..0000000
--- a/asterix-app/src/test/resources/runtimets/queries/failure/insert-rtree/insert-rtree.2.update.aql
+++ /dev/null
@@ -1,11 +0,0 @@
-use dataverse test;
-
-load dataset MyData 
-using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
-(("path"="nc1://data/twitter/smalltweets.txt"),("format"="adm")) pre-sorted;
-
-
-load dataset MyMiniData 
-using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
-(("path"="nc1://data/spatial/spatialData0.json"),("format"="adm")) pre-sorted;
-
diff --git a/asterix-app/src/test/resources/runtimets/queries/failure/insert-rtree/insert-rtree.3.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/failure/insert-rtree/insert-rtree.3.ddl.aql
deleted file mode 100644
index 3626933..0000000
--- a/asterix-app/src/test/resources/runtimets/queries/failure/insert-rtree/insert-rtree.3.ddl.aql
+++ /dev/null
@@ -1,5 +0,0 @@
-use dataverse test;
-
-create index rtree_index_loc_0 on MyData(loc) type rtree;
-create index rtree_index_loc on MyMiniData(loc) type rtree;
-
diff --git a/asterix-app/src/test/resources/runtimets/queries/failure/insert-rtree/insert-rtree.4.update.aql b/asterix-app/src/test/resources/runtimets/queries/failure/insert-rtree/insert-rtree.4.update.aql
deleted file mode 100644
index 5874119..0000000
--- a/asterix-app/src/test/resources/runtimets/queries/failure/insert-rtree/insert-rtree.4.update.aql
+++ /dev/null
@@ -1,23 +0,0 @@
-use dataverse test;
-
-insert into dataset MyMiniData
-(
-	for $m in dataset('MyData')
-	where $m.id<1000
-	return {
-		"id": $m.id,
-		"loc": $m.loc
-	}
-);
-
-insert into dataset MyMiniData
-(
-	for $m in dataset('MyData')
-	where $m.id>=1000
-	die after 1000
-	return {
-		"id": $m.id,
-		"loc": $m.loc
-	}
-);
-
diff --git a/asterix-app/src/test/resources/runtimets/queries/failure/insert-rtree/insert-rtree.5.query.aql b/asterix-app/src/test/resources/runtimets/queries/failure/insert-rtree/insert-rtree.5.query.aql
deleted file mode 100644
index 6c75ca2..0000000
--- a/asterix-app/src/test/resources/runtimets/queries/failure/insert-rtree/insert-rtree.5.query.aql
+++ /dev/null
@@ -1,5 +0,0 @@
-use dataverse test;
-
-for $o in dataset('MyMiniData')
-order by $o.id
-return {"id":$o.id}
diff --git a/asterix-app/src/test/resources/runtimets/queries/failure/insert/insert.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/failure/insert/insert.1.ddl.aql
deleted file mode 100644
index 7f5844e..0000000
--- a/asterix-app/src/test/resources/runtimets/queries/failure/insert/insert.1.ddl.aql
+++ /dev/null
@@ -1,37 +0,0 @@
-drop dataverse test if exists;
-  
-create dataverse test;
-
-use dataverse test;
-
-create type LineItemType as closed {
-  l_orderkey: int32, 
-  l_partkey: int32, 
-  l_suppkey: int32, 
-  l_linenumber: int32, 
-  l_quantity: double, 
-  l_extendedprice: double,
-  l_discount: double, 
-  l_tax: double,
-  l_returnflag: string, 
-  l_linestatus: string, 
-  l_shipdate: string,
-  l_commitdate: string, 
-  l_receiptdate: string, 
-  l_shipinstruct: string, 
-  l_shipmode: string, 
-  l_comment: string
-}
-
-create type LineIDType as closed {
-  l_orderkey: int32, 
-  l_linenumber: int32, 
-  l_suppkey: int32
-}
-
-create dataset LineItem(LineItemType)
-  primary key l_orderkey, l_linenumber;
-
-create dataset LineID(LineIDType)
-  primary key l_orderkey, l_linenumber;
-
diff --git a/asterix-app/src/test/resources/runtimets/queries/failure/insert/insert.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/failure/insert/insert.2.update.aql
deleted file mode 100644
index a1bfc0d..0000000
--- a/asterix-app/src/test/resources/runtimets/queries/failure/insert/insert.2.update.aql
+++ /dev/null
@@ -1,32 +0,0 @@
-use dataverse test;
-
-load dataset LineItem 
-using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
-(("path"="nc1://data/tpch0.001/lineitem.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
-
-load dataset LineID 
-using "edu.uci.ics.asterix.external.dataset.adapter.NCFileSystemAdapter"
-(("path"="nc1://data/tpch0.001/lineitem_0.tbl"),("format"="delimited-text"),("delimiter"="|")) pre-sorted;
-
-insert into dataset LineID (
-for $l in dataset('LineItem')
-	where $l.l_orderkey<1000
-	return {
-		"l_orderkey": $l.l_orderkey,
-		"l_linenumber": $l.l_linenumber,
-		"l_suppkey": $l.l_partkey
-	}
-);
-
-insert into dataset LineID (
-for $l in dataset('LineItem')
-	where $l.l_orderkey>=1000
-	die after 1000
-	return {
-		"l_orderkey": $l.l_orderkey,
-		"l_linenumber": $l.l_linenumber,
-		"l_suppkey": $l.l_partkey
-	}
-);
-
-
diff --git a/asterix-app/src/test/resources/runtimets/queries/failure/insert/insert.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/failure/insert/insert.3.query.aql
deleted file mode 100644
index 4a3e056..0000000
--- a/asterix-app/src/test/resources/runtimets/queries/failure/insert/insert.3.query.aql
+++ /dev/null
@@ -1,6 +0,0 @@
-use dataverse test;
-
-for $c in dataset('LineID')
-order by $c.l_orderkey, $c.l_linenumber
-return $c 
-
diff --git a/asterix-app/src/test/resources/runtimets/queries/failure/verify_delete-rtree.aql b/asterix-app/src/test/resources/runtimets/queries/failure/verify_delete-rtree.aql
deleted file mode 100644
index a8d7d37..0000000
--- a/asterix-app/src/test/resources/runtimets/queries/failure/verify_delete-rtree.aql
+++ /dev/null
@@ -1,8 +0,0 @@
-use dataverse test;
-
-write output to nc1:"rttest/failure_verify_delete-rtree.adm";
-
-for $o in dataset('MyData')
-where spatial-intersect($o.loc, create-rectangle(create-point(0.0,-100.0), create-point(55.5,50.0)))
-order by $o.id
-return {"id":$o.id}
diff --git a/asterix-app/src/test/resources/runtimets/queries/failure/verify_delete-rtree/verify_delete-rtree.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/failure/verify_delete-rtree/verify_delete-rtree.1.ddl.aql
deleted file mode 100644
index e69de29..0000000
--- a/asterix-app/src/test/resources/runtimets/queries/failure/verify_delete-rtree/verify_delete-rtree.1.ddl.aql
+++ /dev/null
diff --git a/asterix-app/src/test/resources/runtimets/queries/failure/verify_delete-rtree/verify_delete-rtree.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/failure/verify_delete-rtree/verify_delete-rtree.2.update.aql
deleted file mode 100644
index e69de29..0000000
--- a/asterix-app/src/test/resources/runtimets/queries/failure/verify_delete-rtree/verify_delete-rtree.2.update.aql
+++ /dev/null
diff --git a/asterix-app/src/test/resources/runtimets/queries/failure/verify_delete-rtree/verify_delete-rtree.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/failure/verify_delete-rtree/verify_delete-rtree.3.query.aql
deleted file mode 100644
index b33019b..0000000
--- a/asterix-app/src/test/resources/runtimets/queries/failure/verify_delete-rtree/verify_delete-rtree.3.query.aql
+++ /dev/null
@@ -1,5 +0,0 @@
-use dataverse test;
-
-for $o in dataset('MyData')
-order by $o.id
-return {"id":$o.id}
diff --git a/asterix-app/src/test/resources/runtimets/queries/failure/verify_delete/verify_delete.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/failure/verify_delete/verify_delete.1.ddl.aql
deleted file mode 100644
index e69de29..0000000
--- a/asterix-app/src/test/resources/runtimets/queries/failure/verify_delete/verify_delete.1.ddl.aql
+++ /dev/null
diff --git a/asterix-app/src/test/resources/runtimets/queries/failure/verify_delete/verify_delete.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/failure/verify_delete/verify_delete.3.query.aql
deleted file mode 100644
index 2a0f3e4..0000000
--- a/asterix-app/src/test/resources/runtimets/queries/failure/verify_delete/verify_delete.3.query.aql
+++ /dev/null
@@ -1,6 +0,0 @@
-use dataverse test;
-
-for $c in dataset('LineItem')
-where $c.l_orderkey>=10
-order by $c.l_orderkey, $c.l_linenumber
-return $c
diff --git a/asterix-app/src/test/resources/runtimets/queries/failure/verify_insert-rtree/verify_insert-rtree.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/failure/verify_insert-rtree/verify_insert-rtree.1.ddl.aql
deleted file mode 100644
index e69de29..0000000
--- a/asterix-app/src/test/resources/runtimets/queries/failure/verify_insert-rtree/verify_insert-rtree.1.ddl.aql
+++ /dev/null
diff --git a/asterix-app/src/test/resources/runtimets/queries/failure/verify_insert-rtree/verify_insert-rtree.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/failure/verify_insert-rtree/verify_insert-rtree.2.update.aql
deleted file mode 100644
index e69de29..0000000
--- a/asterix-app/src/test/resources/runtimets/queries/failure/verify_insert-rtree/verify_insert-rtree.2.update.aql
+++ /dev/null
diff --git a/asterix-app/src/test/resources/runtimets/queries/failure/verify_insert-rtree/verify_insert-rtree.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/failure/verify_insert-rtree/verify_insert-rtree.3.query.aql
deleted file mode 100644
index 6c75ca2..0000000
--- a/asterix-app/src/test/resources/runtimets/queries/failure/verify_insert-rtree/verify_insert-rtree.3.query.aql
+++ /dev/null
@@ -1,5 +0,0 @@
-use dataverse test;
-
-for $o in dataset('MyMiniData')
-order by $o.id
-return {"id":$o.id}
diff --git a/asterix-app/src/test/resources/runtimets/queries/failure/verify_insert/verify_insert.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/failure/verify_insert/verify_insert.1.ddl.aql
deleted file mode 100644
index e69de29..0000000
--- a/asterix-app/src/test/resources/runtimets/queries/failure/verify_insert/verify_insert.1.ddl.aql
+++ /dev/null
diff --git a/asterix-app/src/test/resources/runtimets/queries/failure/verify_insert/verify_insert.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/failure/verify_insert/verify_insert.2.update.aql
deleted file mode 100644
index e69de29..0000000
--- a/asterix-app/src/test/resources/runtimets/queries/failure/verify_insert/verify_insert.2.update.aql
+++ /dev/null
diff --git a/asterix-app/src/test/resources/runtimets/queries/failure/verify_insert/verify_insert.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/failure/verify_insert/verify_insert.3.query.aql
deleted file mode 100644
index 4cb52c5..0000000
--- a/asterix-app/src/test/resources/runtimets/queries/failure/verify_insert/verify_insert.3.query.aql
+++ /dev/null
@@ -1,5 +0,0 @@
-use dataverse test;
-
-for $c in dataset('LineID')
-order by $c.l_orderkey, $c.l_linenumber
-return $c
diff --git a/asterix-app/src/test/resources/runtimets/queries/temporal/duration_comps/duration_comps.1.ddl.aql b/asterix-app/src/test/resources/runtimets/queries/temporal/duration_comps/duration_comps.1.ddl.aql
new file mode 100644
index 0000000..cb55dad
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/temporal/duration_comps/duration_comps.1.ddl.aql
@@ -0,0 +1,8 @@
+/*
+ * Description      :   Test cases for duration comparison functions
+ * Expected Result  :   Success
+ * Date             :   19 Apr, 2013
+ */
+
+drop dataverse test if exists;
+create dataverse test;
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/queries/failure/verify_delete/verify_delete.2.update.aql b/asterix-app/src/test/resources/runtimets/queries/temporal/duration_comps/duration_comps.2.update.aql
similarity index 100%
rename from asterix-app/src/test/resources/runtimets/queries/failure/verify_delete/verify_delete.2.update.aql
rename to asterix-app/src/test/resources/runtimets/queries/temporal/duration_comps/duration_comps.2.update.aql
diff --git a/asterix-app/src/test/resources/runtimets/queries/temporal/duration_comps/duration_comps.3.query.aql b/asterix-app/src/test/resources/runtimets/queries/temporal/duration_comps/duration_comps.3.query.aql
new file mode 100644
index 0000000..77fcc4f
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/queries/temporal/duration_comps/duration_comps.3.query.aql
@@ -0,0 +1,11 @@
+use dataverse test;
+
+let $dr1 := duration("-P3D")
+let $dr2 := duration("P1D")
+let $dr3 := duration("P1Y")
+let $dr4 := duration("P13M")
+let $dr5 := duration("PT24H")
+let $dr6 := duration-from-months(months-of-year-month-duration($dr3))
+let $dr7 := duration-from-ms(ms-of-day-time-duration($dr1))
+
+return { "yearMonthGreaterComp" : year-month-duration-greater-than($dr4, $dr3), "dayTimeGreaterComp" : day-time-duration-greater-than($dr2, $dr1), "yearMonthLessComp" : year-month-duration-less-than($dr4, $dr3), "dayTimeLessComp" : day-time-duration-less-than($dr2, $dr1), "equal1": duration-equal($dr2, $dr5), "equal2": duration-equal($dr1, $dr5), "equal3": duration-equal($dr6, $dr3), "equal4": duration-equal($dr7, $dr1) }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/results/constructor/rectangle_01/rectangle_01.1.adm b/asterix-app/src/test/resources/runtimets/results/constructor/rectangle_01/rectangle_01.1.adm
new file mode 100644
index 0000000..32f14b3
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results/constructor/rectangle_01/rectangle_01.1.adm
@@ -0,0 +1 @@
+{ "rectangle1": rectangle("5.1,11.8 87.6,15.6548"), "rectangle2": rectangle("0.1234,-1.0E-10 5.5487,0.48765") }
diff --git a/asterix-app/src/test/resources/runtimets/results/spatial/cell-aggregation-with-filtering/cell-aggregation-with-filtering.1.adm b/asterix-app/src/test/resources/runtimets/results/spatial/cell-aggregation-with-filtering/cell-aggregation-with-filtering.1.adm
index e95bac0..25859de 100644
--- a/asterix-app/src/test/resources/runtimets/results/spatial/cell-aggregation-with-filtering/cell-aggregation-with-filtering.1.adm
+++ b/asterix-app/src/test/resources/runtimets/results/spatial/cell-aggregation-with-filtering/cell-aggregation-with-filtering.1.adm
@@ -1,2 +1,2 @@
-{ "cell": rectangle("33.5,-101.5 | 36.5,-98.5"), "count": 1 }
-{ "cell": rectangle("33.5,-98.5 | 36.5,-95.5"), "count": 2 }
\ No newline at end of file
+{ "cell": rectangle("33.5,-101.5 36.5,-98.5"), "count": 1 }
+{ "cell": rectangle("33.5,-98.5 36.5,-95.5"), "count": 2 }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/results/spatial/cell-aggregation/cell-aggregation.1.adm b/asterix-app/src/test/resources/runtimets/results/spatial/cell-aggregation/cell-aggregation.1.adm
index 137ed1c..0014d49 100644
--- a/asterix-app/src/test/resources/runtimets/results/spatial/cell-aggregation/cell-aggregation.1.adm
+++ b/asterix-app/src/test/resources/runtimets/results/spatial/cell-aggregation/cell-aggregation.1.adm
@@ -1,3 +1,3 @@
-{ "cell": rectangle("5.0,5.0 | 10.0,10.0"), "count": 1 }
-{ "cell": rectangle("5.0,0.0 | 10.0,5.0"), "count": 3 }
-{ "cell": rectangle("0.0,0.0 | 5.0,5.0"), "count": 12 }
\ No newline at end of file
+{ "cell": rectangle("5.0,5.0 10.0,10.0"), "count": 1 }
+{ "cell": rectangle("5.0,0.0 10.0,5.0"), "count": 3 }
+{ "cell": rectangle("0.0,0.0 5.0,5.0"), "count": 12 }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/results/temporal/duration_comps/duration_comps.1.adm b/asterix-app/src/test/resources/runtimets/results/temporal/duration_comps/duration_comps.1.adm
new file mode 100644
index 0000000..26b32fc
--- /dev/null
+++ b/asterix-app/src/test/resources/runtimets/results/temporal/duration_comps/duration_comps.1.adm
@@ -0,0 +1 @@
+{ "yearMonthGreaterComp": true, "dayTimeGreaterComp": true, "yearMonthLessComp": false, "dayTimeLessComp": false, "equal1": true, "equal2": false, "equal3": true, "equal4": true }
\ No newline at end of file
diff --git a/asterix-app/src/test/resources/runtimets/testsuite.xml b/asterix-app/src/test/resources/runtimets/testsuite.xml
index 77ce68d..c5c0c26 100644
--- a/asterix-app/src/test/resources/runtimets/testsuite.xml
+++ b/asterix-app/src/test/resources/runtimets/testsuite.xml
@@ -555,6 +555,11 @@
       </compilation-unit>
     </test-case>
     <test-case FilePath="constructor">
+      <compilation-unit name="rectangle_01">
+        <output-dir compare="Text">rectangle_01</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="constructor">
       <compilation-unit name="point_01">
         <output-dir compare="Text">point_01</output-dir>
       </compilation-unit>
@@ -1033,42 +1038,6 @@
     </test-case>
   </test-group>
   <test-group name="failure">
-    <test-case FilePath="failure">
-      <compilation-unit name="delete-rtree">
-        <output-dir compare="Text">delete-rtree</output-dir>
-        <expected-error>edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException</expected-error>
-      </compilation-unit>
-      <compilation-unit name="verify_delete-rtree">
-        <output-dir compare="Text">delete-rtree</output-dir>
-      </compilation-unit>
-    </test-case>
-    <test-case FilePath="failure">
-      <compilation-unit name="delete">
-        <output-dir compare="Text">delete</output-dir>
-        <expected-error>edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException</expected-error>
-      </compilation-unit>
-      <compilation-unit name="verify_delete">
-        <output-dir compare="Text">delete</output-dir>
-      </compilation-unit>
-    </test-case>
-    <test-case FilePath="failure">
-      <compilation-unit name="insert-rtree">
-        <output-dir compare="Text">insert-rtree</output-dir>
-        <expected-error>edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException</expected-error>
-      </compilation-unit>
-      <compilation-unit name="verify_insert-rtree">
-        <output-dir compare="Text">insert-rtree</output-dir>
-      </compilation-unit>
-    </test-case>
-    <test-case FilePath="failure">
-      <compilation-unit name="insert">
-        <output-dir compare="Text">insert</output-dir>
-        <expected-error>edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException</expected-error>
-      </compilation-unit>
-      <compilation-unit name="verify_insert">
-        <output-dir compare="Text">insert</output-dir>
-      </compilation-unit>
-    </test-case>
     <!--
     <test-case FilePath="failure">
       <compilation-unit name="q1_pricing_summary_report_failure">
@@ -4204,6 +4173,11 @@
         <output-dir compare="Text">interval</output-dir>
       </compilation-unit>
   	</test-case>
+  	<test-case FilePath="temporal">
+  		<compilation-unit name="duration_comps">
+        <output-dir compare="Text">duration_comps</output-dir>
+      </compilation-unit>
+  	</test-case>
   </test-group>
   <test-group name="leftouterjoin">
     <test-case FilePath="leftouterjoin">
@@ -4218,4 +4192,3 @@
     </test-case>
   </test-group>
 </test-suite>
-
diff --git a/asterix-aql/pom.xml b/asterix-aql/pom.xml
index bb6f4b5..038ec62 100644
--- a/asterix-aql/pom.xml
+++ b/asterix-aql/pom.xml
@@ -3,7 +3,7 @@
 	<parent>
 		<artifactId>asterix</artifactId>
 		<groupId>edu.uci.ics.asterix</groupId>
-		<version>0.0.5-SNAPSHOT</version>
+		<version>0.0.6-SNAPSHOT</version>
 	</parent>
 	<artifactId>asterix-aql</artifactId>
 	<build>
@@ -85,19 +85,19 @@
 		<dependency>
 			<groupId>edu.uci.ics.asterix</groupId>
 			<artifactId>asterix-common</artifactId>
-			<version>0.0.5-SNAPSHOT</version>
+			<version>0.0.6-SNAPSHOT</version>
 			<scope>compile</scope>
 		</dependency>
 		<dependency>
 			<groupId>edu.uci.ics.asterix</groupId>
 			<artifactId>asterix-om</artifactId>
-			<version>0.0.5-SNAPSHOT</version>
+			<version>0.0.6-SNAPSHOT</version>
 			<scope>compile</scope>
 		</dependency>
 		<dependency>
 			<groupId>edu.uci.ics.asterix</groupId>
 			<artifactId>asterix-metadata</artifactId>
-			<version>0.0.5-SNAPSHOT</version>
+			<version>0.0.6-SNAPSHOT</version>
 			<scope>compile</scope>
 		</dependency>
 		<dependency>
diff --git a/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/base/Clause.java b/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/base/Clause.java
index 8be2d40..3e92653 100644
--- a/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/base/Clause.java
+++ b/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/base/Clause.java
@@ -9,7 +9,6 @@
         WHERE_CLAUSE,
         ORDER_BY_CLAUSE,
         LIMIT_CLAUSE,
-        DIE_CLAUSE,
         GROUP_BY_CLAUSE,
         DISTINCT_BY_CLAUSE,
         UPDATE_CLAUSE
diff --git a/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/expression/CreateIndexStatement.java b/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/expression/CreateIndexStatement.java
index ffd0534..7a764ae 100644
--- a/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/expression/CreateIndexStatement.java
+++ b/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/expression/CreateIndexStatement.java
@@ -12,7 +12,6 @@
 public class CreateIndexStatement implements Statement {
 
     private Identifier indexName;
-    private boolean needToCreate = true;
     private Identifier dataverseName;
     private Identifier datasetName;
     private List<String> fieldExprs = new ArrayList<String>();
@@ -33,14 +32,6 @@
         return gramLength;
     }
 
-    public void setNeedToCreate(boolean needToCreate) {
-        this.needToCreate = needToCreate;
-    }
-
-    public boolean getNeedToCreate() {
-        return needToCreate;
-    }
-
     public Identifier getIndexName() {
         return indexName;
     }
diff --git a/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/expression/DeleteStatement.java b/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/expression/DeleteStatement.java
index 48b7909..b56d628 100644
--- a/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/expression/DeleteStatement.java
+++ b/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/expression/DeleteStatement.java
@@ -1,6 +1,5 @@
 package edu.uci.ics.asterix.aql.expression;
 
-import edu.uci.ics.asterix.aql.base.Clause;
 import edu.uci.ics.asterix.aql.base.Expression;
 import edu.uci.ics.asterix.aql.base.Statement;
 import edu.uci.ics.asterix.aql.expression.visitor.IAqlExpressionVisitor;
@@ -13,16 +12,14 @@
     private Identifier dataverseName;
     private Identifier datasetName;
     private Expression condition;
-    private Clause dieClause;
     private int varCounter;
 
     public DeleteStatement(VariableExpr vars, Identifier dataverseName, Identifier datasetName, Expression condition,
-            Clause dieClause, int varCounter) {
+            int varCounter) {
         this.vars = vars;
         this.dataverseName = dataverseName;
         this.datasetName = datasetName;
         this.condition = condition;
-        this.dieClause = dieClause;
         this.varCounter = varCounter;
     }
 
@@ -47,10 +44,6 @@
         return condition;
     }
 
-    public Clause getDieClause() {
-        return dieClause;
-    }
-
     public int getVarCounter() {
         return varCounter;
     }
diff --git a/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/expression/DieClause.java b/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/expression/DieClause.java
deleted file mode 100644
index 3a77d58..0000000
--- a/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/expression/DieClause.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package edu.uci.ics.asterix.aql.expression;
-
-import edu.uci.ics.asterix.aql.base.Clause;
-import edu.uci.ics.asterix.aql.base.Expression;
-import edu.uci.ics.asterix.aql.expression.visitor.IAqlExpressionVisitor;
-import edu.uci.ics.asterix.aql.expression.visitor.IAqlVisitorWithVoidReturn;
-import edu.uci.ics.asterix.common.exceptions.AsterixException;
-
-public class DieClause implements Clause {
-    private Expression expr;
-
-    public DieClause() {
-    }
-
-    public DieClause(Expression dieexpr) {
-        this.expr = dieexpr;
-    }
-
-    public Expression getDieExpr() {
-        return expr;
-    }
-
-    public void setDieExpr(Expression dieexpr) {
-        this.expr = dieexpr;
-    }
-
-    @Override
-    public ClauseType getClauseType() {
-        return ClauseType.DIE_CLAUSE;
-    }
-
-    @Override
-    public <T> void accept(IAqlVisitorWithVoidReturn<T> visitor, T arg) throws AsterixException {
-        visitor.visit(this, arg);
-    }
-
-    @Override
-    public <R, T> R accept(IAqlExpressionVisitor<R, T> visitor, T arg) throws AsterixException {
-        return visitor.visitDieClause(this, arg);
-    }
-}
diff --git a/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/expression/visitor/AQLPrintVisitor.java b/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/expression/visitor/AQLPrintVisitor.java
index ab55e34..3506e61 100644
--- a/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/expression/visitor/AQLPrintVisitor.java
+++ b/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/expression/visitor/AQLPrintVisitor.java
@@ -7,7 +7,6 @@
 import edu.uci.ics.asterix.aql.base.Clause;
 import edu.uci.ics.asterix.aql.base.Expression;
 import edu.uci.ics.asterix.aql.base.Literal;
-import edu.uci.ics.asterix.aql.base.Statement;
 import edu.uci.ics.asterix.aql.expression.BeginFeedStatement;
 import edu.uci.ics.asterix.aql.expression.CallExpr;
 import edu.uci.ics.asterix.aql.expression.ControlFeedStatement;
@@ -18,7 +17,6 @@
 import edu.uci.ics.asterix.aql.expression.DataverseDecl;
 import edu.uci.ics.asterix.aql.expression.DataverseDropStatement;
 import edu.uci.ics.asterix.aql.expression.DeleteStatement;
-import edu.uci.ics.asterix.aql.expression.DieClause;
 import edu.uci.ics.asterix.aql.expression.DistinctClause;
 import edu.uci.ics.asterix.aql.expression.DropStatement;
 import edu.uci.ics.asterix.aql.expression.FLWOGRExpression;
@@ -284,12 +282,6 @@
     }
 
     @Override
-    public void visit(DieClause lc, Integer step) throws AsterixException {
-        out.println(skip(step) + "Limit");
-        lc.getDieExpr().accept(this, step + 1);
-    }
-
-    @Override
     public void visit(FunctionDecl fd, Integer step) throws AsterixException {
         out.println(skip(step) + "FunctionDecl " + fd.getSignature().getName() + "(" + fd.getParamList().toString()
                 + ") {");
diff --git a/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/expression/visitor/IAqlExpressionVisitor.java b/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/expression/visitor/IAqlExpressionVisitor.java
index 6c8b844..1f8e980 100644
--- a/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/expression/visitor/IAqlExpressionVisitor.java
+++ b/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/expression/visitor/IAqlExpressionVisitor.java
@@ -10,7 +10,6 @@
 import edu.uci.ics.asterix.aql.expression.DataverseDecl;
 import edu.uci.ics.asterix.aql.expression.DataverseDropStatement;
 import edu.uci.ics.asterix.aql.expression.DeleteStatement;
-import edu.uci.ics.asterix.aql.expression.DieClause;
 import edu.uci.ics.asterix.aql.expression.DistinctClause;
 import edu.uci.ics.asterix.aql.expression.DropStatement;
 import edu.uci.ics.asterix.aql.expression.FLWOGRExpression;
@@ -141,7 +140,7 @@
     R visitSetStatement(SetStatement ss, T arg) throws AsterixException;
 
     R visitBeginFeedStatement(BeginFeedStatement bf, T arg) throws AsterixException;
-    
+
     R visitControlFeedStatement(ControlFeedStatement del, T arg) throws AsterixException;
 
     R visitCallExpr(CallExpr pf, T arg) throws AsterixException;
@@ -150,8 +149,6 @@
 
     R visitWriteFromQueryResultStatement(WriteFromQueryResultStatement stmtLoad, T arg) throws AsterixException;
 
-    R visitDieClause(DieClause stmtLoad, T arg) throws AsterixException;
-
     R visit(CreateFunctionStatement cfs, T arg) throws AsterixException;
 
     R visitFunctionDropStatement(FunctionDropStatement del, T arg) throws AsterixException;
diff --git a/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/expression/visitor/IAqlVisitorWithVoidReturn.java b/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/expression/visitor/IAqlVisitorWithVoidReturn.java
index d4891ac..ff04032 100644
--- a/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/expression/visitor/IAqlVisitorWithVoidReturn.java
+++ b/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/expression/visitor/IAqlVisitorWithVoidReturn.java
@@ -10,7 +10,6 @@
 import edu.uci.ics.asterix.aql.expression.DataverseDecl;
 import edu.uci.ics.asterix.aql.expression.DataverseDropStatement;
 import edu.uci.ics.asterix.aql.expression.DeleteStatement;
-import edu.uci.ics.asterix.aql.expression.DieClause;
 import edu.uci.ics.asterix.aql.expression.DistinctClause;
 import edu.uci.ics.asterix.aql.expression.DropStatement;
 import edu.uci.ics.asterix.aql.expression.FLWOGRExpression;
@@ -143,13 +142,11 @@
     void visit(DataverseDropStatement stmtDel, T arg) throws AsterixException;
 
     void visit(TypeDropStatement stmtDel, T arg) throws AsterixException;
-    
+
     void visit(BeginFeedStatement stmtDel, T arg) throws AsterixException;
 
     void visit(ControlFeedStatement stmtDel, T arg) throws AsterixException;
 
-    void visit(DieClause stmtDel, T arg) throws AsterixException;
-
     void visit(CreateFunctionStatement cfs, T arg) throws AsterixException;
 
     void visit(FunctionDropStatement fds, T arg) throws AsterixException;
diff --git a/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/rewrites/AqlRewriter.java b/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/rewrites/AqlRewriter.java
index 62e40fa..84d8321 100644
--- a/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/rewrites/AqlRewriter.java
+++ b/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/rewrites/AqlRewriter.java
@@ -20,7 +20,6 @@
 import edu.uci.ics.asterix.aql.expression.DataverseDecl;
 import edu.uci.ics.asterix.aql.expression.DataverseDropStatement;
 import edu.uci.ics.asterix.aql.expression.DeleteStatement;
-import edu.uci.ics.asterix.aql.expression.DieClause;
 import edu.uci.ics.asterix.aql.expression.DistinctClause;
 import edu.uci.ics.asterix.aql.expression.DropStatement;
 import edu.uci.ics.asterix.aql.expression.FLWOGRExpression;
@@ -343,12 +342,6 @@
         }
 
         @Override
-        public Void visitDieClause(DieClause lc, Void arg) throws AsterixException {
-            lc.getDieExpr().accept(this, arg);
-            return null;
-        }
-
-        @Override
         public Void visitListConstructor(ListConstructor lc, Void arg) throws AsterixException {
             for (Expression e : lc.getExprList()) {
                 e.accept(this, arg);
diff --git a/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/rewrites/CloneAndSubstituteVariablesVisitor.java b/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/rewrites/CloneAndSubstituteVariablesVisitor.java
index 5742ac6..cbd15a2 100644
--- a/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/rewrites/CloneAndSubstituteVariablesVisitor.java
+++ b/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/rewrites/CloneAndSubstituteVariablesVisitor.java
@@ -17,7 +17,6 @@
 import edu.uci.ics.asterix.aql.expression.DataverseDecl;
 import edu.uci.ics.asterix.aql.expression.DataverseDropStatement;
 import edu.uci.ics.asterix.aql.expression.DeleteStatement;
-import edu.uci.ics.asterix.aql.expression.DieClause;
 import edu.uci.ics.asterix.aql.expression.DistinctClause;
 import edu.uci.ics.asterix.aql.expression.DropStatement;
 import edu.uci.ics.asterix.aql.expression.FLWOGRExpression;
@@ -187,7 +186,7 @@
         } else {
             // it is a var. from the context
             var = context.getRewrittenVar(v.getVar().getId());
-            if(var == null){
+            if (var == null) {
                 var = v.getVar();
             }
         }
@@ -257,14 +256,6 @@
     }
 
     @Override
-    public Pair<IAqlExpression, List<VariableSubstitution>> visitDieClause(DieClause lc, List<VariableSubstitution> arg)
-            throws AsterixException {
-        Pair<IAqlExpression, List<VariableSubstitution>> p1 = lc.getDieExpr().accept(this, arg);
-        DieClause c = new DieClause((Expression) p1.first);
-        return new Pair<IAqlExpression, List<VariableSubstitution>>(c, arg);
-    }
-
-    @Override
     public Pair<IAqlExpression, List<VariableSubstitution>> visitListConstructor(ListConstructor lc,
             List<VariableSubstitution> arg) throws AsterixException {
         List<Expression> oldExprList = lc.getExprList();
diff --git a/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/rewrites/InlineUdfsVisitor.java b/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/rewrites/InlineUdfsVisitor.java
index f178d88..9834f27 100644
--- a/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/rewrites/InlineUdfsVisitor.java
+++ b/asterix-aql/src/main/java/edu/uci/ics/asterix/aql/rewrites/InlineUdfsVisitor.java
@@ -18,7 +18,6 @@
 import edu.uci.ics.asterix.aql.expression.DataverseDecl;
 import edu.uci.ics.asterix.aql.expression.DataverseDropStatement;
 import edu.uci.ics.asterix.aql.expression.DeleteStatement;
-import edu.uci.ics.asterix.aql.expression.DieClause;
 import edu.uci.ics.asterix.aql.expression.DistinctClause;
 import edu.uci.ics.asterix.aql.expression.DropStatement;
 import edu.uci.ics.asterix.aql.expression.FLWOGRExpression;
@@ -104,15 +103,15 @@
     public Boolean visitRecordConstructor(RecordConstructor rc, List<FunctionDecl> arg) throws AsterixException {
         boolean changed = false;
         for (FieldBinding b : rc.getFbList()) {
-        	Pair<Boolean, Expression> leftExprInlined = inlineUdfsInExpr(b.getLeftExpr(), arg);
-        	b.setLeftExpr(leftExprInlined.second);
-        	changed = changed | leftExprInlined.first;
-        	Pair<Boolean, Expression> rightExprInlined = inlineUdfsInExpr(b.getRightExpr(), arg);
-        	b.setRightExpr(rightExprInlined.second);
-        	changed = changed | rightExprInlined.first;
-        	
-        	/*
-        	if (b.getLeftExpr().accept(this, arg)) {
+            Pair<Boolean, Expression> leftExprInlined = inlineUdfsInExpr(b.getLeftExpr(), arg);
+            b.setLeftExpr(leftExprInlined.second);
+            changed = changed | leftExprInlined.first;
+            Pair<Boolean, Expression> rightExprInlined = inlineUdfsInExpr(b.getRightExpr(), arg);
+            b.setRightExpr(rightExprInlined.second);
+            changed = changed | rightExprInlined.first;
+
+            /*
+            if (b.getLeftExpr().accept(this, arg)) {
                 changed = true;
             }
             if (b.getRightExpr().accept(this, arg)) {
@@ -251,13 +250,6 @@
     }
 
     @Override
-    public Boolean visitDieClause(DieClause lc, List<FunctionDecl> arg) throws AsterixException {
-        Pair<Boolean, Expression> p1 = inlineUdfsInExpr(lc.getDieExpr(), arg);
-        lc.setDieExpr(p1.second);
-        return p1.first;
-    }
-
-    @Override
     public Boolean visitUnaryExpr(UnaryExpr u, List<FunctionDecl> arg) throws AsterixException {
         return u.getExpr().accept(this, arg);
     }
diff --git a/asterix-aql/src/main/javacc/AQL.jj b/asterix-aql/src/main/javacc/AQL.jj
index be7d954..68e1497 100644
--- a/asterix-aql/src/main/javacc/AQL.jj
+++ b/asterix-aql/src/main/javacc/AQL.jj
@@ -270,7 +270,6 @@
     Identifier dataverseName;
     Identifier datasetName = null;
 	Expression condition = null;
-	Clause dieClause = null;
 	Pair<Identifier, Identifier> nameComponents;
 }
 {
@@ -280,8 +279,8 @@
    { 
 	  nameComponents  = getDotSeparatedPair();
    }
-   ("where" condition = Expression())?  (dieClause = DieClause())? (";")?
-   {return new DeleteStatement(var, nameComponents.first, nameComponents.second, condition,  dieClause, getVarCounter()); }
+   ("where" condition = Expression())? (";")?
+   {return new DeleteStatement(var, nameComponents.first, nameComponents.second, condition, getVarCounter()); }
 }
 
 UpdateStatement UpdateStatement() throws ParseException:
@@ -2174,7 +2173,6 @@
        | clause = GroupClause() 
        | clause = LimitClause()
        | clause = DistinctClause()
-       | clause = DieClause()
     )
     {
       return clause;
@@ -2408,21 +2406,6 @@
   }
 }
 
-DieClause DieClause() throws ParseException:
-{
-	DieClause lc = new DieClause();
-	Expression expr;
-	pushForbiddenScope(getCurrentScope());
-}
-{
-  "die" "after" expr = Expression()    { lc.setDieExpr(expr);    }
-  {
-    popForbiddenScope();   
-    return lc;
-  }
-}
-
-
 QuantifiedExpression QuantifiedExpression()throws ParseException:
 {
   QuantifiedExpression qc = new QuantifiedExpression();
diff --git a/asterix-common/pom.xml b/asterix-common/pom.xml
index bb2b97f..1a0e782 100644
--- a/asterix-common/pom.xml
+++ b/asterix-common/pom.xml
@@ -1,9 +1,10 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 	<modelVersion>4.0.0</modelVersion>
 	<parent>
 		<artifactId>asterix</artifactId>
 		<groupId>edu.uci.ics.asterix</groupId>
-		<version>0.0.5-SNAPSHOT</version>
+		<version>0.0.6-SNAPSHOT</version>
 	</parent>
 	<artifactId>asterix-common</artifactId>
 	<build>
@@ -18,6 +19,63 @@
 					<fork>true</fork>
 				</configuration>
 			</plugin>
+			<plugin>
+				<groupId>org.jvnet.jaxb2.maven2</groupId>
+				<artifactId>maven-jaxb2-plugin</artifactId>
+				<executions>
+					<execution>
+						<id>configuration</id>
+						<goals>
+							<goal>generate</goal>
+						</goals>
+						<configuration>
+							<args>
+								<arg>-Xsetters</arg>
+								<arg>-Xvalue-constructor</arg>
+							</args>
+							<plugins>
+								<plugin>
+									<groupId>org.jvnet.jaxb2_commons</groupId>
+									<artifactId>jaxb2-basics</artifactId>
+									<version>0.6.2</version>
+								</plugin>
+								<plugin>
+									<groupId>org.jvnet.jaxb2_commons</groupId>
+									<artifactId>jaxb2-value-constructor</artifactId>
+									<version>3.0</version>
+								</plugin>
+							</plugins>
+							<schemaDirectory>src/main/resources/schema</schemaDirectory>
+							<schemaIncludes>
+								<include>asterix-conf.xsd</include>
+							</schemaIncludes>
+							<generatePackage>edu.uci.ics.asterix.common.configuration</generatePackage>
+							<bindingDirectory>src/main/resources/schema</bindingDirectory>
+							<bindingIncludes>
+								<bindingInclude>jaxb-bindings.xjb</bindingInclude>
+							</bindingIncludes>
+							<generateDirectory>${project.build.directory}/generated-sources/configuration</generateDirectory>
+						</configuration>
+					</execution>
+				</executions>
+			</plugin>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-jar-plugin</artifactId>
+				<version>2.2</version>
+				<configuration>
+					<includes>
+						<include>**/*.class</include>
+					</includes>
+				</configuration>
+				<executions>
+					<execution>
+						<goals>
+							<goal>test-jar</goal>
+						</goals>
+					</execution>
+				</executions>
+			</plugin>
 		</plugins>
 	</build>
 
@@ -31,9 +89,19 @@
 			<artifactId>hyracks-dataflow-std</artifactId>
 		</dependency>
 		<dependency>
+			<groupId>commons-io</groupId>
+			<artifactId>commons-io</artifactId>
+			<version>1.4</version>
+		</dependency>
+		<dependency>
+			<groupId>commons-httpclient</groupId>
+			<artifactId>commons-httpclient</artifactId>
+			<version>3.0.1</version>
+		</dependency>
+		<dependency>
 			<groupId>edu.uci.ics.asterix</groupId>
 			<artifactId>asterix-transactions</artifactId>
-			<version>0.0.5-SNAPSHOT</version>
+			<version>0.0.6-SNAPSHOT</version>
 			<type>jar</type>
 			<scope>compile</scope>
 		</dependency>
@@ -41,6 +109,18 @@
 			<groupId>edu.uci.ics.hyracks</groupId>
 			<artifactId>hyracks-storage-am-lsm-common</artifactId>
 		</dependency>
+		<dependency>
+			<groupId>edu.uci.ics.asterix</groupId>
+			<artifactId>asterix-test-framework</artifactId>
+			<version>0.0.6-SNAPSHOT</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>4.8.1</version>
+			<scope>test</scope>
+		</dependency>
 	</dependencies>
 
 </project>
diff --git a/asterix-common/src/main/java/edu/uci/ics/asterix/common/config/AsterixProperties.java b/asterix-common/src/main/java/edu/uci/ics/asterix/common/config/AsterixProperties.java
new file mode 100644
index 0000000..04e974d
--- /dev/null
+++ b/asterix-common/src/main/java/edu/uci/ics/asterix/common/config/AsterixProperties.java
@@ -0,0 +1,252 @@
+/*
+ * Copyright 2009-2010 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.common.config;
+
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.Unmarshaller;
+
+import edu.uci.ics.asterix.common.configuration.AsterixConfiguration;
+import edu.uci.ics.asterix.common.configuration.Property;
+import edu.uci.ics.asterix.common.configuration.Store;
+import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
+
+/**
+ * Holder for Asterix properties values typically set as Java Properties.
+ * Intended to live in the AsterixStateProxy so it can be accessed remotely.
+ */
+public class AsterixProperties implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+    private static String metadataNodeName;
+    private static HashSet<String> nodeNames;
+    private static Map<String, String[]> stores;
+    private static Map<String, String> asterixConfigurationParams;
+
+    public static AsterixProperties INSTANCE = new AsterixProperties();
+
+    public static class AsterixConfigurationKeys {
+
+        // JVM parameters for each Node Contoller (NC)
+        public static final String NC_JAVA_OPTS = "nc_java_opts";
+        public static final String NC_JAVA_OPTS_DEFAULT = "-Xmx1024m";
+
+        // JVM parameters for the Cluster Contoller (CC)
+        public static final String CC_JAVA_OPTS = "cc_java_opts";
+        public static final String CC_JAVA_OPTS_DEFAULT = "-Xmx1024m";
+
+        public static final String SIZE_MEMORY_COMPONENT = "size_memory_component";
+        public static final String SIZE_MEMORY_COMPONENT_DEFAULT = "512m";
+
+        public static final String TOTAL_SIZE_MEMORY_COMPONENT = "total_size_memory_component";
+        public static final String TOTAL_SIZE_MEMORY_COMPONENT_DEFAULT = "512m";
+
+        public static final String LOG_BUFFER_NUM_PAGES = "log_buffer_num_pages";
+        public static final String LOG_BUFFER_NUM_PAGES_DEFAULT = "8";
+
+        public static final String LOG_BUFFER_PAGE_SIZE = "log_buffer_page_size";
+        public static final String LOG_BUFFER_PAGE_SIZE_DEFAULT = "131072";
+
+        public static final String LOG_PARTITION_SIZE = "log_partition_size";
+        public static final String LOG_PARTITION_SIZE_DEFAULT = "2147483648";
+
+        public static final String GROUP_COMMIT_INTERVAL = "group_commit_interval";
+        public static final String GROUP_COMMIT_INTERVAL_DEFAULT = "200ms";
+
+        public static final String SORT_OP_MEMORY = "sort_op_memory";
+        public static final String SORT_OP_MEMORY_DEFAULT = "512m";
+
+        public static final String JOIN_OP_MEMORY = "join_op_memory";
+        public static final String JOIN_OP_MEMORY_DEFAULT = "512m";
+
+        public static final String WEB_INTERFACE_PORT = "web_interface_port";
+        public static final String WEB_INTERFACE_PORT_DEFAULT = "19001";
+
+        public static final String NUM_PAGES_BUFFER_CACHE = "num_pages_buffer_cache";
+        public static final String NUM_PAGES_BUFFER_CACHE_DEFAULT = "1000";
+
+        public static final String LOG_LEVEL = "log_level";
+        public static final String LOG_LEVEL_DEFAULT = "INFO";
+
+        public static final String LSN_THRESHOLD = "lsn_threshold";
+        public static final String LSN_THRESHOLD_DEFAULT = "64m";
+
+        public static final String CHECKPOINT_TERMS_IN_SECS = "checkpoint_terms_in_secs";
+        public static final String CHECKPOINT_TERMS_IN_SECS_DEFAULT = "120";
+
+        public static final String ESCALATE_THRSHOLD_ENTITY_TO_DATASET = "escalate_threshold_entity_to_dataset";
+        public static final String ESCALATE_THRSHOLD_ENTITY_TO_DATASET_DEFAULT = "8";
+
+        public static final String SHRINK_TIMER_THRESHOLD = "shrink_timer_threshold";
+        public static final String SHRINK_TIMER_THRESHOLD_DEFAULT = "120000";
+
+    }
+
+    private AsterixProperties() {
+        try {
+            String fileName = System.getProperty(GlobalConfig.CONFIG_FILE_PROPERTY);
+            if (fileName == null) {
+                fileName = GlobalConfig.DEFAULT_CONFIG_FILE_NAME;
+            }
+            InputStream is = this.getClass().getClassLoader().getResourceAsStream(fileName);
+            if (is == null) {
+                try {
+                    fileName = GlobalConfig.DEFAULT_CONFIG_FILE_NAME;
+                    is = new FileInputStream(fileName);
+                } catch (FileNotFoundException fnf) {
+                    throw new AlgebricksException("Could not find the configuration file " + fileName);
+                }
+            }
+
+            JAXBContext ctx = JAXBContext.newInstance(AsterixConfiguration.class);
+            Unmarshaller unmarshaller = ctx.createUnmarshaller();
+            AsterixConfiguration asterixConfiguration = (AsterixConfiguration) unmarshaller.unmarshal(is);
+            metadataNodeName = asterixConfiguration.getMetadataNode();
+            stores = new HashMap<String, String[]>();
+            List<Store> configuredStores = asterixConfiguration.getStore();
+            nodeNames = new HashSet<String>();
+            for (Store store : configuredStores) {
+                String trimmedStoreDirs = store.getStoreDirs().trim();
+                stores.put(store.getNcId(), trimmedStoreDirs.split(","));
+                nodeNames.add(store.getNcId());
+            }
+            asterixConfigurationParams = new HashMap<String, String>();
+            for (Property p : asterixConfiguration.getProperty()) {
+                asterixConfigurationParams.put(p.getName(), p.getValue());
+            }
+
+            initializeLogLevel(getProperty(AsterixConfigurationKeys.LOG_LEVEL));
+        } catch (Exception e) {
+            throw new IllegalStateException(e);
+        }
+    }
+
+    public String getMetadataNodeName() {
+        return metadataNodeName;
+    }
+
+    public String getMetadataStore() {
+        return stores.get(metadataNodeName)[0];
+    }
+
+    public Map<String, String[]> getStores() {
+        return stores;
+    }
+
+    public HashSet<String> getNodeNames() {
+        return nodeNames;
+    }
+
+    public String getProperty(String property) {
+        String propValue = asterixConfigurationParams.get(property);
+        if (propValue == null) {
+            switch (property) {
+                case AsterixConfigurationKeys.NC_JAVA_OPTS:
+                    propValue = AsterixConfigurationKeys.NC_JAVA_OPTS_DEFAULT;
+                    break;
+                case AsterixConfigurationKeys.CC_JAVA_OPTS:
+                    propValue = AsterixConfigurationKeys.CC_JAVA_OPTS_DEFAULT;
+                    break;
+                case AsterixConfigurationKeys.SIZE_MEMORY_COMPONENT:
+                    propValue = AsterixConfigurationKeys.SIZE_MEMORY_COMPONENT_DEFAULT;
+                    break;
+                case AsterixConfigurationKeys.TOTAL_SIZE_MEMORY_COMPONENT:
+                    propValue = AsterixConfigurationKeys.TOTAL_SIZE_MEMORY_COMPONENT_DEFAULT;
+                    break;
+                case AsterixConfigurationKeys.LOG_BUFFER_NUM_PAGES:
+                    propValue = AsterixConfigurationKeys.LOG_BUFFER_NUM_PAGES_DEFAULT;
+                    break;
+                case AsterixConfigurationKeys.LOG_BUFFER_PAGE_SIZE:
+                    propValue = AsterixConfigurationKeys.LOG_BUFFER_PAGE_SIZE_DEFAULT;
+                    break;
+                case AsterixConfigurationKeys.LOG_PARTITION_SIZE:
+                    propValue = AsterixConfigurationKeys.LOG_PARTITION_SIZE_DEFAULT;
+                    break;
+                case AsterixConfigurationKeys.GROUP_COMMIT_INTERVAL:
+                    propValue = AsterixConfigurationKeys.GROUP_COMMIT_INTERVAL_DEFAULT;
+                    break;
+                case AsterixConfigurationKeys.SORT_OP_MEMORY:
+                    propValue = AsterixConfigurationKeys.SORT_OP_MEMORY_DEFAULT;
+                    break;
+                case AsterixConfigurationKeys.JOIN_OP_MEMORY:
+                    propValue = AsterixConfigurationKeys.JOIN_OP_MEMORY_DEFAULT;
+                    break;
+                case AsterixConfigurationKeys.WEB_INTERFACE_PORT:
+                    propValue = AsterixConfigurationKeys.WEB_INTERFACE_PORT_DEFAULT;
+                    break;
+                case AsterixConfigurationKeys.NUM_PAGES_BUFFER_CACHE:
+                    propValue = AsterixConfigurationKeys.NUM_PAGES_BUFFER_CACHE_DEFAULT;
+                    break;
+                case AsterixConfigurationKeys.LOG_LEVEL:
+                    propValue = AsterixConfigurationKeys.LOG_LEVEL_DEFAULT;
+                    break;
+                case AsterixConfigurationKeys.LSN_THRESHOLD:
+                    propValue = AsterixConfigurationKeys.LSN_THRESHOLD_DEFAULT;
+                    break;
+                case AsterixConfigurationKeys.CHECKPOINT_TERMS_IN_SECS:
+                    propValue = AsterixConfigurationKeys.CHECKPOINT_TERMS_IN_SECS_DEFAULT;
+                    break;
+                case AsterixConfigurationKeys.ESCALATE_THRSHOLD_ENTITY_TO_DATASET:
+                    propValue = AsterixConfigurationKeys.ESCALATE_THRSHOLD_ENTITY_TO_DATASET_DEFAULT;
+                    break;
+                case AsterixConfigurationKeys.SHRINK_TIMER_THRESHOLD:
+                    propValue = AsterixConfigurationKeys.SHRINK_TIMER_THRESHOLD_DEFAULT;
+                    break;
+            }
+        }
+        return propValue;
+    }
+
+    private void initializeLogLevel(String configuredLogLevel) {
+        Level level = null;
+        switch (configuredLogLevel.toLowerCase()) {
+            case "info":
+                level = Level.INFO;
+                break;
+            case "fine":
+                level = Level.FINE;
+                break;
+            case "finer":
+                level = Level.FINER;
+                break;
+            case "finest":
+                level = Level.FINEST;
+                break;
+            case "severe":
+                level = Level.SEVERE;
+                break;
+            case "off":
+                level = Level.OFF;
+                break;
+            case "warning":
+                level = Level.WARNING;
+                break;
+            default:
+                level = Level.ALL;
+        }
+        Logger.getLogger(".").setLevel(level);
+    }
+}
diff --git a/asterix-common/src/main/java/edu/uci/ics/asterix/common/config/GlobalConfig.java b/asterix-common/src/main/java/edu/uci/ics/asterix/common/config/GlobalConfig.java
index 1183b65..ebce6fe 100644
--- a/asterix-common/src/main/java/edu/uci/ics/asterix/common/config/GlobalConfig.java
+++ b/asterix-common/src/main/java/edu/uci/ics/asterix/common/config/GlobalConfig.java
@@ -3,57 +3,61 @@
 import java.util.logging.Logger;
 
 public class GlobalConfig {
-    public static final boolean DEBUG = true;
+	public static final boolean DEBUG = true;
 
-    public static final String ASTERIX_LOGGER_NAME = "edu.uci.ics.asterix";
+	public static final String ASTERIX_LOGGER_NAME = "edu.uci.ics.asterix";
 
-    public static final Logger ASTERIX_LOGGER = Logger.getLogger(ASTERIX_LOGGER_NAME);
+	public static final Logger ASTERIX_LOGGER = Logger
+			.getLogger(ASTERIX_LOGGER_NAME);
 
-    public static final String ASTERIX_LOGFILE_PATTERN = "%t/asterix.log";
+	public static final String ASTERIX_LOGFILE_PATTERN = "%t/asterix.log";
 
-    public static final String DEFAULT_CONFIG_FILE_NAME = "test.properties";
+	public static final String DEFAULT_CONFIG_FILE_NAME = "asterix-configuration.xml";
 
-    public static final String TEST_CONFIG_FILE_NAME = "src/main/resources/test.properties";
+	public static final String TEST_CONFIG_FILE_NAME = "src/main/resources/asterix-configuration.xml";
 
-    public static final String CONFIG_FILE_PROPERTY = "AsterixConfigFileName";
+	public static final String CONFIG_FILE_PROPERTY = "AsterixConfigFileName";
 
-    public static final String WEB_SERVER_PORT_PROPERTY = "AsterixWebServerPort";
+	public static final String WEB_SERVER_PORT_PROPERTY = "AsterixWebServerPort";
 
-    public static final String JSON_API_SERVER_PORT_PROPERTY = "AsterixJSONAPIServerPort";
+	public static final String JSON_API_SERVER_PORT_PROPERTY = "AsterixJSONAPIServerPort";
 
-    public static final String BUFFER_CACHE_PAGE_SIZE_PROPERTY = "BufferCachePageSize";
+	public static final String BUFFER_CACHE_PAGE_SIZE_PROPERTY = "BufferCachePageSize";
 
-    public static final String BUFFER_CACHE_NUM_PAGES_PROPERTY = "BufferCacheNumPages";
+	public static final String BUFFER_CACHE_NUM_PAGES_PROPERTY = "BufferCacheNumPages";
 
-    public static final int DEFAULT_BUFFER_CACHE_NUM_PAGES = 4096;
+	public static final int DEFAULT_BUFFER_CACHE_NUM_PAGES = 4096;
 
-    public static final int DEFAULT_FRAME_SIZE = 32768;
+	public static final int DEFAULT_FRAME_SIZE = 32768;
 
-    public static final String FRAME_SIZE_PROPERTY = "FrameSize";
+	public static final String FRAME_SIZE_PROPERTY = "FrameSize";
 
-    public static final float DEFAULT_BTREE_FILL_FACTOR = 1.00f;
+	public static final float DEFAULT_BTREE_FILL_FACTOR = 1.00f;
 
-    public static int DEFAULT_INPUT_DATA_COLUMN = 0;
+	public static int DEFAULT_INPUT_DATA_COLUMN = 0;
 
-    public static int DEFAULT_INDEX_MEM_PAGE_SIZE = 32768;
+	public static int DEFAULT_INDEX_MEM_PAGE_SIZE = 32768;
 
-    public static int DEFAULT_INDEX_MEM_NUM_PAGES = 1000;
+	public static int DEFAULT_INDEX_MEM_NUM_PAGES = 1000;
 
-    public static int getFrameSize() {
-        int frameSize = GlobalConfig.DEFAULT_FRAME_SIZE;
-        String frameSizeStr = System.getProperty(GlobalConfig.FRAME_SIZE_PROPERTY);
-        if (frameSizeStr != null) {
-            int fz = -1;
-            try {
-                fz = Integer.parseInt(frameSizeStr);
-            } catch (NumberFormatException nfe) {
-                GlobalConfig.ASTERIX_LOGGER.warning("Wrong frame size size argument. Picking default value ("
-                        + GlobalConfig.DEFAULT_FRAME_SIZE + ") instead.\n");
-            }
-            if (fz >= 0) {
-                frameSize = fz;
-            }
-        }
-        return frameSize;
-    }
+	public static int getFrameSize() {
+		int frameSize = GlobalConfig.DEFAULT_FRAME_SIZE;
+		String frameSizeStr = System
+				.getProperty(GlobalConfig.FRAME_SIZE_PROPERTY);
+		if (frameSizeStr != null) {
+			int fz = -1;
+			try {
+				fz = Integer.parseInt(frameSizeStr);
+			} catch (NumberFormatException nfe) {
+				GlobalConfig.ASTERIX_LOGGER
+						.warning("Wrong frame size size argument. Picking default value ("
+								+ GlobalConfig.DEFAULT_FRAME_SIZE
+								+ ") instead.\n");
+			}
+			if (fz >= 0) {
+				frameSize = fz;
+			}
+		}
+		return frameSize;
+	}
 }
diff --git a/asterix-common/src/main/resources/schema/asterix-conf.xsd b/asterix-common/src/main/resources/schema/asterix-conf.xsd
new file mode 100644
index 0000000..f53fb4b
--- /dev/null
+++ b/asterix-common/src/main/resources/schema/asterix-conf.xsd
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
+	xmlns:mg="asterixconf" targetNamespace="asterixconf"
+	elementFormDefault="qualified">
+
+	<!-- definition of simple types -->
+
+        
+	<xs:element name="metadataNode" type="xs:string" />
+	<xs:element name="storeDirs" type="xs:string" />
+	<xs:element name="ncId" type="xs:string" />
+	<xs:element name="name" type="xs:string" />
+	<xs:element name="value" type="xs:string" />
+	<xs:element name="description" type="xs:string" />
+	
+	<!-- definition of complex elements -->
+	<xs:element name="store">
+		<xs:complexType>
+			<xs:sequence>
+				<xs:element ref="mg:ncId" />
+				<xs:element ref="mg:storeDirs" />
+			</xs:sequence>
+		</xs:complexType>
+	</xs:element>
+
+	<xs:element name="property">
+		<xs:complexType>
+			<xs:sequence>
+				<xs:element ref="mg:name" />
+				<xs:element ref="mg:value" />
+				<xs:element ref="mg:description" />
+			</xs:sequence>
+		</xs:complexType>
+	</xs:element>
+
+
+	<xs:element name="asterixConfiguration">
+		<xs:complexType>
+			<xs:sequence>
+				<xs:element ref="mg:metadataNode" minOccurs="0"/>
+				<xs:element ref="mg:store" maxOccurs="unbounded" />
+				<xs:element ref="mg:property" minOccurs="0" maxOccurs="unbounded" />
+			</xs:sequence>
+		</xs:complexType>
+	</xs:element>
+
+</xs:schema>     
diff --git a/asterix-common/src/main/resources/schema/jaxb-bindings.xjb b/asterix-common/src/main/resources/schema/jaxb-bindings.xjb
new file mode 100644
index 0000000..b5982e0
--- /dev/null
+++ b/asterix-common/src/main/resources/schema/jaxb-bindings.xjb
@@ -0,0 +1,9 @@
+<jxb:bindings version="1.0"
+xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
+xmlns:xs="http://www.w3.org/2001/XMLSchema">
+
+<jxb:globalBindings>
+  <jxb:serializable uid="1"/>
+</jxb:globalBindings>
+
+</jxb:bindings>
diff --git a/asterix-common/src/test/java/edu/uci/ics/asterix/test/aql/TestsUtils.java b/asterix-common/src/test/java/edu/uci/ics/asterix/test/aql/TestsUtils.java
new file mode 100644
index 0000000..8449971
--- /dev/null
+++ b/asterix-common/src/test/java/edu/uci/ics/asterix/test/aql/TestsUtils.java
@@ -0,0 +1,399 @@
+package edu.uci.ics.asterix.test.aql;
+
+import static org.junit.Assert.fail;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.PrintWriter;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.Iterator;
+import java.util.List;
+import java.util.NoSuchElementException;
+import java.util.logging.Logger;
+
+import org.apache.commons.httpclient.DefaultHttpMethodRetryHandler;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpStatus;
+import org.apache.commons.httpclient.NameValuePair;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.commons.httpclient.params.HttpMethodParams;
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import edu.uci.ics.asterix.testframework.context.TestCaseContext;
+import edu.uci.ics.asterix.testframework.context.TestFileContext;
+import edu.uci.ics.asterix.testframework.xml.TestCase.CompilationUnit;
+
+public class TestsUtils {
+
+    private static final String EXTENSION_AQL_RESULT = "adm";
+    private static final Logger LOGGER = Logger.getLogger(TestsUtils.class.getName());
+    private static Method managixExecuteMethod = null;
+
+    /**
+     * Probably does not work well with symlinks.
+     */
+    public static boolean deleteRec(File path) {
+        if (path.isDirectory()) {
+            for (File f : path.listFiles()) {
+                if (!deleteRec(f)) {
+                    return false;
+                }
+            }
+        }
+        return path.delete();
+    }
+
+    public static void runScriptAndCompareWithResult(File scriptFile, PrintWriter print, File expectedFile,
+            File actualFile) throws Exception {
+        BufferedReader readerExpected = new BufferedReader(new InputStreamReader(new FileInputStream(expectedFile),
+                "UTF-8"));
+        BufferedReader readerActual = new BufferedReader(
+                new InputStreamReader(new FileInputStream(actualFile), "UTF-8"));
+        String lineExpected, lineActual;
+        int num = 1;
+        try {
+            while ((lineExpected = readerExpected.readLine()) != null) {
+                lineActual = readerActual.readLine();
+                // Assert.assertEquals(lineExpected, lineActual);
+                if (lineActual == null) {
+                    if (lineExpected.isEmpty()) {
+                        continue;
+                    }
+                    throw new Exception("Result for " + scriptFile + " changed at line " + num + ":\n< " + lineExpected
+                            + "\n> ");
+                }
+
+                if (!equalStrings(lineExpected.split("Timestamp")[0], lineActual.split("Timestamp")[0])) {
+                    fail("Result for " + scriptFile + " changed at line " + num + ":\n< " + lineExpected + "\n> "
+                            + lineActual);
+                }
+
+                ++num;
+            }
+            lineActual = readerActual.readLine();
+            // Assert.assertEquals(null, lineActual);
+            if (lineActual != null) {
+                throw new Exception("Result for " + scriptFile + " changed at line " + num + ":\n< \n> " + lineActual);
+            }
+            // actualFile.delete();
+        } finally {
+            readerExpected.close();
+            readerActual.close();
+        }
+
+    }
+
+    private static boolean equalStrings(String s1, String s2) {
+        String[] rowsOne = s1.split("\n");
+        String[] rowsTwo = s2.split("\n");
+
+        for (int i = 0; i < rowsOne.length; i++) {
+            String row1 = rowsOne[i];
+            String row2 = rowsTwo[i];
+
+            if (row1.equals(row2))
+                continue;
+
+            String[] fields1 = row1.split(" ");
+            String[] fields2 = row2.split(" ");
+
+            for (int j = 0; j < fields1.length; j++) {
+                if (fields1[j].equals(fields2[j])) {
+                    continue;
+                } else if (fields1[j].indexOf('.') < 0) {
+                    return false;
+                } else {
+                    fields1[j] = fields1[j].split(",")[0];
+                    fields2[j] = fields2[j].split(",")[0];
+                    Double double1 = Double.parseDouble(fields1[j]);
+                    Double double2 = Double.parseDouble(fields2[j]);
+                    float float1 = (float) double1.doubleValue();
+                    float float2 = (float) double2.doubleValue();
+
+                    if (Math.abs(float1 - float2) == 0)
+                        continue;
+                    else {
+                        return false;
+                    }
+                }
+            }
+        }
+        return true;
+    }
+
+    public static String aqlExtToResExt(String fname) {
+        int dot = fname.lastIndexOf('.');
+        return fname.substring(0, dot + 1) + EXTENSION_AQL_RESULT;
+    }
+
+    public static void writeResultsToFile(File actualFile, JSONObject result) throws IOException, JSONException {
+        BufferedWriter writer = new BufferedWriter(new FileWriter(actualFile));
+        Results res = new Results(result);
+        for (String line : res) {
+            writer.write(line);
+            writer.newLine();
+        }
+        writer.close();
+    }
+
+    public static class Results implements Iterable<String> {
+        private final JSONArray chunks;
+
+        public Results(JSONObject result) throws JSONException {
+            chunks = result.getJSONArray("results");
+        }
+
+        public Iterator<String> iterator() {
+            return new ResultIterator(chunks);
+        }
+    }
+
+    public static class ResultIterator implements Iterator<String> {
+        private final JSONArray chunks;
+
+        private int chunkCounter = 0;
+        private int recordCounter = 0;
+
+        public ResultIterator(JSONArray chunks) {
+            this.chunks = chunks;
+        }
+
+        @Override
+        public boolean hasNext() {
+            JSONArray resultArray;
+            try {
+                resultArray = chunks.getJSONArray(chunkCounter);
+                if (resultArray.getString(recordCounter) != null) {
+                    return true;
+                }
+            } catch (JSONException e) {
+                return false;
+            }
+            return false;
+        }
+
+        @Override
+        public String next() throws NoSuchElementException {
+            JSONArray resultArray;
+            String item = "";
+
+            try {
+                resultArray = chunks.getJSONArray(chunkCounter);
+                item = resultArray.getString(recordCounter);
+                if (item == null) {
+                    throw new NoSuchElementException();
+                }
+                item = item.trim();
+
+                recordCounter++;
+                if (recordCounter >= resultArray.length()) {
+                    chunkCounter++;
+                    recordCounter = 0;
+                }
+            } catch (JSONException e) {
+                throw new NoSuchElementException(e.getMessage());
+            }
+            return item;
+        }
+
+        @Override
+        public void remove() {
+            throw new UnsupportedOperationException();
+        }
+    }
+
+    // Executes Query and returns results as JSONArray
+    public static JSONObject executeQuery(String str) throws Exception {
+
+        final String url = "http://localhost:19101/query";
+
+        // Create an instance of HttpClient.
+        HttpClient client = new HttpClient();
+
+        // Create a method instance.
+        GetMethod method = new GetMethod(url);
+
+        method.setQueryString(new NameValuePair[] { new NameValuePair("query", str) });
+
+        // Provide custom retry handler is necessary
+        method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(3, false));
+
+        JSONObject result = null;
+
+        try {
+            // Execute the method.
+            int statusCode = client.executeMethod(method);
+
+            // Check if the method was executed successfully.
+            if (statusCode != HttpStatus.SC_OK) {
+                System.err.println("Method failed: " + method.getStatusLine());
+            }
+
+            // Read the response body as String.
+            String responseBody = method.getResponseBodyAsString();
+
+            result = new JSONObject(responseBody);
+        } catch (Exception e) {
+            System.out.println(e.getMessage());
+            e.printStackTrace();
+        }
+        return result;
+    }
+
+    // To execute Update statements
+    // Insert and Delete statements are executed here
+    public static void executeUpdate(String str) throws Exception {
+        final String url = "http://localhost:19101/update";
+
+        // Create an instance of HttpClient.
+        HttpClient client = new HttpClient();
+
+        // Create a method instance.
+        GetMethod method = new GetMethod(url);
+
+        method.setQueryString(new NameValuePair[] { new NameValuePair("statements", str) });
+
+        // Provide custom retry handler is necessary
+        method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(3, false));
+
+        // Execute the method.
+        int statusCode = client.executeMethod(method);
+
+        // Check if the method was executed successfully.
+        if (statusCode != HttpStatus.SC_OK) {
+            System.err.println("Method failed: " + method.getStatusLine());
+        }
+    }
+
+    // To execute DDL and Update statements
+    // create type statement
+    // create dataset statement
+    // create index statement
+    // create dataverse statement
+    // create function statement
+    public static void executeDDL(String str) throws Exception {
+        final String url = "http://localhost:19101/ddl";
+
+        // Create an instance of HttpClient.
+        HttpClient client = new HttpClient();
+
+        // Create a method instance.
+        GetMethod method = new GetMethod(url);
+
+        method.setQueryString(new NameValuePair[] { new NameValuePair("ddl", str) });
+
+        // Provide custom retry handler is necessary
+        method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(3, false));
+
+        // Execute the method.
+        int statusCode = client.executeMethod(method);
+
+        // Check if the method was executed successfully.
+        if (statusCode != HttpStatus.SC_OK) {
+            System.err.println("Method failed: " + method.getStatusLine());
+        }
+    }
+
+    // Method that reads a DDL/Update/Query File
+    // and returns the contents as a string
+    // This string is later passed to REST API for execution.
+    public static String readTestFile(File testFile) throws Exception {
+        BufferedReader reader = new BufferedReader(new FileReader(testFile));
+        String line = null;
+        StringBuilder stringBuilder = new StringBuilder();
+        String ls = System.getProperty("line.separator");
+
+        while ((line = reader.readLine()) != null) {
+            stringBuilder.append(line);
+            stringBuilder.append(ls);
+        }
+
+        return stringBuilder.toString();
+    }
+
+    public static void executeManagixCommand(String command) throws ClassNotFoundException, NoSuchMethodException,
+            SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
+        if (managixExecuteMethod == null) {
+            Class clazz = Class.forName("edu.uci.ics.asterix.installer.test.AsterixInstallerIntegrationUtil");
+            managixExecuteMethod = clazz.getMethod("executeCommand", String.class);
+        }
+        managixExecuteMethod.invoke(null, command);
+    }
+
+    public static void executeTest(String actualPath, TestCaseContext testCaseCtx) throws Exception {
+
+        File testFile;
+        File expectedResultFile;
+        String statement;
+        List<TestFileContext> expectedResultFileCtxs;
+        List<TestFileContext> testFileCtxs;
+
+        int queryCount = 0;
+        JSONObject result;
+
+        List<CompilationUnit> cUnits = testCaseCtx.getTestCase().getCompilationUnit();
+        for (CompilationUnit cUnit : cUnits) {
+            LOGGER.info("[TEST]: " + testCaseCtx.getTestCase().getFilePath() + "/" + cUnit.getName());
+
+            testFileCtxs = testCaseCtx.getTestFiles(cUnit);
+            expectedResultFileCtxs = testCaseCtx.getExpectedResultFiles(cUnit);
+
+            for (TestFileContext ctx : testFileCtxs) {
+                testFile = ctx.getFile();
+                statement = TestsUtils.readTestFile(testFile);
+                try {
+                    switch (ctx.getType()) {
+                        case "ddl":
+                            TestsUtils.executeDDL(statement);
+                            break;
+                        case "update":
+                            TestsUtils.executeUpdate(statement);
+                            break;
+                        case "query":
+                            result = TestsUtils.executeQuery(statement);
+                            if (!cUnit.getExpectedError().isEmpty()) {
+                                if (!result.has("error")) {
+                                    throw new Exception("Test \"" + testFile + "\" FAILED!");
+                                }
+                            } else {
+                                expectedResultFile = expectedResultFileCtxs.get(queryCount).getFile();
+
+                                File actualFile = new File(actualPath + File.separator
+                                        + testCaseCtx.getTestCase().getFilePath().replace(File.separator, "_") + "_"
+                                        + cUnit.getName() + ".adm");
+
+                                File actualResultFile = testCaseCtx.getActualResultFile(cUnit, new File(actualPath));
+                                actualResultFile.getParentFile().mkdirs();
+
+                                TestsUtils.writeResultsToFile(actualFile, result);
+
+                                TestsUtils.runScriptAndCompareWithResult(testFile, new PrintWriter(System.err),
+                                        expectedResultFile, actualFile);
+                            }
+                            queryCount++;
+                            break;
+                        case "mgx":
+                            executeManagixCommand(statement);
+                            break;
+                        default:
+                            throw new IllegalArgumentException("No statements of type " + ctx.getType());
+                    }
+                } catch (Exception e) {
+                    if (cUnit.getExpectedError().isEmpty()) {
+                        throw new Exception("Test \"" + testFile + "\" FAILED!", e);
+                    }
+                }
+            }
+        }
+
+    }
+}
diff --git a/asterix-events/pom.xml b/asterix-events/pom.xml
index 107cc0c..7b187bb 100644
--- a/asterix-events/pom.xml
+++ b/asterix-events/pom.xml
@@ -3,11 +3,11 @@
   <parent>
           <artifactId>asterix</artifactId>
           <groupId>edu.uci.ics.asterix</groupId>
-          <version>0.0.5-SNAPSHOT</version>
+          <version>0.0.6-SNAPSHOT</version>
   </parent>
   <groupId>edu.uci.ics.asterix</groupId>
   <artifactId>asterix-events</artifactId>
-  <version>0.0.5-SNAPSHOT</version>
+  <version>0.0.6-SNAPSHOT</version>
 
   <properties>
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
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 1721666..b6a32e3 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, null);
+    public static final Node CLIENT_NODE = new Node(CLIENT_NODE_ID, "127.0.0.1", null, null, null, null, null);
 
     private static String eventsDir;
     private static Events events;
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 6d89c88..352d787 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
@@ -46,27 +46,38 @@
         pargs.add("/bin/bash");
         pargs.add(client.getEventsDir() + File.separator + "scripts" + File.separator + EXECUTE_SCRIPT);
         StringBuffer envBuffer = new StringBuffer(IP_LOCATION + "=" + node.getClusterIp() + " ");
+        boolean isMasterNode = node.getId().equals(cluster.getMasterNode().getId());
+
         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")) {
-                    StringBuilder builder = new StringBuilder();
-                    builder.append("\"");
-                    String javaOpts = (node.getJavaOpts() == null ? cluster.getJavaOpts() : node.getJavaOpts());
-                    if (javaOpts != null) {
-                        builder.append(javaOpts);
-                    }
-                    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");
+                } else if (p.getKey().equals("NC_JAVA_OPTS")) {
+                    if (!isMasterNode) {
+                        StringBuilder builder = new StringBuilder();
+                        builder.append("\"");
+                        String javaOpts = p.getValue();
+                        if (javaOpts != null) {
+                            builder.append(javaOpts);
                         }
+                        builder.append("\"");
+                        envBuffer.append("JAVA_OPTS" + "=" + builder + " ");
                     }
-                    builder.append("\"");
-                    envBuffer.append(p.getKey() + "=" + builder + " ");
+                } else if (p.getKey().equals("CC_JAVA_OPTS")) {
+                    if (isMasterNode) {
+                        StringBuilder builder = new StringBuilder();
+                        builder.append("\"");
+                        String javaOpts = p.getValue();
+                        if (javaOpts != null) {
+                            builder.append(javaOpts);
+                        }
+                        builder.append("\"");
+                        envBuffer.append("JAVA_OPTS" + "=" + builder + " ");
+                    }
+                } else if (p.getKey().equals("LOG_DIR")) {
+                    String val = node.getLogDir() == null ? p.getValue() : node.getLogDir();
+                    envBuffer.append(p.getKey() + "=" + val + " ");
                 } else {
                     envBuffer.append(p.getKey() + "=" + p.getValue() + " ");
                 }
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 0761c7f..7cbb515 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
@@ -36,251 +36,230 @@
 
 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 LOCALHOST = "localhost";
-	private static final String LOCALHOST_IP = "127.0.0.1";
+    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 LOCALHOST = "localhost";
+    private static final String LOCALHOST_IP = "127.0.0.1";
 
-    public static Cluster getCluster(String clusterConfigurationPath)
-			throws JAXBException {
-		File file = new File(clusterConfigurationPath);
-		JAXBContext ctx = JAXBContext.newInstance(Cluster.class);
-		Unmarshaller unmarshaller = ctx.createUnmarshaller();
-		Cluster cluster = (Cluster) unmarshaller.unmarshal(file);
-		if (cluster.getMasterNode().getClusterIp().equals(LOCALHOST)) {
-			cluster.getMasterNode().setClusterIp(LOCALHOST_IP);
-		}
-		for (Node node : cluster.getNode()) {
-			if (node.getClusterIp().equals(LOCALHOST)) {
-				node.setClusterIp(LOCALHOST_IP);
-			}
-		}
-		return cluster;
-	}
+    public static Cluster getCluster(String clusterConfigurationPath) throws JAXBException {
+        File file = new File(clusterConfigurationPath);
+        JAXBContext ctx = JAXBContext.newInstance(Cluster.class);
+        Unmarshaller unmarshaller = ctx.createUnmarshaller();
+        Cluster cluster = (Cluster) unmarshaller.unmarshal(file);
+        if (cluster.getMasterNode().getClusterIp().equals(LOCALHOST)) {
+            cluster.getMasterNode().setClusterIp(LOCALHOST_IP);
+        }
+        for (Node node : cluster.getNode()) {
+            if (node.getClusterIp().equals(LOCALHOST)) {
+                node.setClusterIp(LOCALHOST_IP);
+            }
+        }
+        return cluster;
+    }
 
-	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 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);
-		}
+        if (nodeid.equals(cluster.getMasterNode().getId())) {
+            String logDir = cluster.getMasterNode().getLogDir() == null ? cluster.getLogDir() : cluster.getMasterNode()
+                    .getLogDir();
+            String javaHome = cluster.getMasterNode().getJavaHome() == null ? cluster.getJavaHome() : cluster
+                    .getMasterNode().getJavaHome();
+            return new Node(cluster.getMasterNode().getId(), cluster.getMasterNode().getClusterIp(), javaHome, logDir,
+                    null, null, null);
+        }
 
-		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.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 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.getClusterIp());
-		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/resources/events/backup/backup.sh b/asterix-events/src/main/resources/events/backup/backup.sh
index 556ca39..fc6e3cc 100755
--- a/asterix-events/src/main/resources/events/backup/backup.sh
+++ b/asterix-events/src/main/resources/events/backup/backup.sh
@@ -3,7 +3,7 @@
 ASTERIX_IODEVICES=$3
 NODE_STORE=$4
 ASTERIX_ROOT_METADATA_DIR=$5
-TXN_LOG_DIR_NAME=$6
+TXN_LOG_DIR=$6
 BACKUP_ID=$7
 BACKUP_DIR=$8
 BACKUP_TYPE=$9
@@ -20,7 +20,6 @@
   for nodeIODevice in $nodeIODevices
   do
     STORE_DIR=$nodeIODevice/$NODE_STORE
-    TXN_LOG_DIR=$nodeIODevice/$TXN_LOG_DIR_NAME
     NODE_BACKUP_DIR=$BACKUP_DIR/$ASTERIX_INSTANCE_NAME/$BACKUP_ID/$NODE_ID/
    
     # make the destination directory 
@@ -46,7 +45,6 @@
   for nodeIODevice in $nodeIODevices
   do
     STORE_DIR=$nodeIODevice/$NODE_STORE
-    TXN_LOG_DIR=$nodeIODevice/$TXN_LOG_DIR_NAME
     NODE_BACKUP_DIR=$BACKUP_DIR/$ASTERIX_INSTANCE_NAME/$BACKUP_ID/$NODE_ID
 
     # create the backup directory, if it does not exists
diff --git a/asterix-events/src/main/resources/events/restore/restore.sh b/asterix-events/src/main/resources/events/restore/restore.sh
index 6396eec..88c5a6f 100755
--- a/asterix-events/src/main/resources/events/restore/restore.sh
+++ b/asterix-events/src/main/resources/events/restore/restore.sh
@@ -3,7 +3,7 @@
 ASTERIX_IODEVICES=$3
 NODE_STORE=$4
 ASTERIX_ROOT_METADATA_DIR=$5
-TXN_LOG_DIR_NAME=$6
+TXN_LOG_DIR=$6
 BACKUP_ID=$7
 BACKUP_DIR=$8
 BACKUP_TYPE=$9
@@ -33,8 +33,9 @@
   rm -rf $DEST_STORE_DIR/$SOURCE_STORE_DIR
 
   # remove the existing log directory
-  DEST_LOG_DIR=$iodevice/$TXN_LOG_DIR_NAME/
-  rm -rf $DEST_LOG_DIR
+  DEST_LOG_DIR=$TXN_LOG_DIR
+  rm -rf $DEST_LOG_DIR/*
+  TXN_LOG_DIR_NAME=${TXN_LOG_DIR%/*}
 
   # remove the existing asterix metadata directory
   rm -rf $iodevice/$ASTERIX_ROOT_METADATA_DIR
@@ -52,7 +53,7 @@
         $HADOOP_HOME/bin/hadoop fs -copyToLocal $HDFS_URL/$NODE_BACKUP_DIR/$ASTERIX_ROOT_METADATA_DIR $iodevice/
 
         # copy transaction logs directory
-        $HADOOP_HOME/bin/hadoop fs -copyToLocal $HDFS_URL/$NODE_BACKUP_DIR/$TXN_LOG_DIR_NAME $iodevice/
+        $HADOOP_HOME/bin/hadoop fs -copyToLocal $HDFS_URL/$NODE_BACKUP_DIR/$TXN_LOG_DIR_NAME $$TXN_LOG_DIR/
       fi
 
   else
@@ -67,7 +68,7 @@
         cp -r $NODE_BACKUP_DIR/$ASTERIX_ROOT_METADATA_DIR $iodevice/
 
         # copy transaction logs directory
-        cp -r $NODE_BACKUP_DIR/$TXN_LOG_DIR_NAME $iodevice/
+        cp -r $NODE_BACKUP_DIR/$TXN_LOG_DIR_NAME $TXN_LOG_DIR/
       fi
 
   fi
diff --git a/asterix-events/src/main/resources/schema/cluster.xsd b/asterix-events/src/main/resources/schema/cluster.xsd
index 0e1adce..718d7b0 100644
--- a/asterix-events/src/main/resources/schema/cluster.xsd
+++ b/asterix-events/src/main/resources/schema/cluster.xsd
@@ -1,98 +1,92 @@
 <?xml version="1.0" encoding="ISO-8859-1" ?>
-<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:cl="cluster" targetNamespace="cluster" elementFormDefault="qualified">
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
+	xmlns:cl="cluster" targetNamespace="cluster" elementFormDefault="qualified">
 
-<!-- definition of simple types --> 
-<xs:element name="name" 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="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 simple types -->
+	<xs:element name="name" type="xs:string" />
+	<xs:element name="log_dir" type="xs:string" />
+	<xs:element name="txn_log_dir" type="xs:string" />
+	<xs:element name="id" 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" />
 
-<!-- definition of complex elements -->
-<xs:element name="workingDir">
-  <xs:complexType>
-    <xs:sequence>
-      <xs:element ref="cl:dir"/>
-      <xs:element ref="cl:NFS"/>
-    </xs:sequence>
-  </xs:complexType>
-</xs:element>
+	<!-- definition of complex elements -->
+	<xs:element name="working_dir">
+		<xs:complexType>
+			<xs:sequence>
+				<xs:element ref="cl:dir" />
+				<xs:element ref="cl:NFS" />
+			</xs:sequence>
+		</xs:complexType>
+	</xs:element>
 
-<xs:element name="master-node">
-  <xs:complexType>
-    <xs:sequence>
-      <xs:element ref="cl:id"/>
-      <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_opts" minOccurs="0"/>
-      <xs:element ref="cl:logdir" minOccurs="0"/>
-      <xs:element ref="cl:debug" minOccurs="0"/>
-    </xs:sequence>
-  </xs:complexType>
-</xs:element>
+	<xs:element name="master_node">
+		<xs:complexType>
+			<xs:sequence>
+				<xs:element ref="cl:id" />
+				<xs:element ref="cl:client_ip" />
+				<xs:element ref="cl:cluster_ip" />
+				<xs:element ref="cl:java_home" minOccurs="0" />
+				<xs:element ref="cl:log_dir" minOccurs="0" />
+			</xs:sequence>
+		</xs:complexType>
+	</xs:element>
 
-<xs:element name="property">
-  <xs:complexType>
-    <xs:sequence>
-      <xs:element ref="cl:key"/>
-      <xs:element ref="cl:value"/>
-    </xs:sequence>
-  </xs:complexType>
-</xs:element>
+	<xs:element name="property">
+		<xs:complexType>
+			<xs:sequence>
+				<xs:element ref="cl:key" />
+				<xs:element ref="cl:value" />
+			</xs:sequence>
+		</xs:complexType>
+	</xs:element>
 
-<xs:element name="env">
-  <xs:complexType>
-    <xs:sequence>
-      <xs:element ref="cl:property" minOccurs="0" maxOccurs="unbounded"/>
-    </xs:sequence>
-  </xs:complexType>
-</xs:element>
+	<xs:element name="env">
+		<xs:complexType>
+			<xs:sequence>
+				<xs:element ref="cl:property" minOccurs="0" maxOccurs="unbounded" />
+			</xs:sequence>
+		</xs:complexType>
+	</xs:element>
 
-<xs:element name="node">
-  <xs:complexType>
-    <xs:sequence>
-      <xs:element ref="cl:id"/>
-      <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>
-</xs:element>
+	<xs:element name="node">
+		<xs:complexType>
+			<xs:sequence>
+				<xs:element ref="cl:id" />
+				<xs:element ref="cl:cluster_ip" />
+				<xs:element ref="cl:java_home" minOccurs="0" />
+				<xs:element ref="cl:log_dir" minOccurs="0" />
+				<xs:element ref="cl:txn_log_dir" minOccurs="0" />
+				<xs:element ref="cl:store" minOccurs="0" />
+				<xs:element ref="cl:iodevices" minOccurs="0" />
+			</xs:sequence>
+		</xs:complexType>
+	</xs:element>
 
-<xs:element name="cluster">
-  <xs:complexType>
-    <xs:sequence>
-      <xs:element ref="cl:name"/>
-      <xs:element ref="cl:username"/>
-      <xs:element ref="cl:env" 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>
-  </xs:complexType>
-</xs:element>
+	<xs:element name="cluster">
+		<xs:complexType>
+			<xs:sequence>
+				<xs:element ref="cl:name" />
+				<xs:element ref="cl:username" />
+				<xs:element ref="cl:env" minOccurs="0" />
+				<xs:element ref="cl:java_home" minOccurs="0" />
+				<xs:element ref="cl:log_dir" minOccurs="0" />
+				<xs:element ref="cl:txn_log_dir" minOccurs="0" />
+				<xs:element ref="cl:store" minOccurs="0" />
+				<xs:element ref="cl:iodevices" minOccurs="0" />
+				<xs:element ref="cl:working_dir" />
+				<xs:element ref="cl:master_node" />
+				<xs:element ref="cl:node" maxOccurs="unbounded" />
+			</xs:sequence>
+		</xs:complexType>
+	</xs:element>
 
 </xs:schema>     
diff --git a/asterix-external-data/pom.xml b/asterix-external-data/pom.xml
index 67ca3df..2e99b7c 100644
--- a/asterix-external-data/pom.xml
+++ b/asterix-external-data/pom.xml
@@ -3,7 +3,7 @@
 	<parent>
 		<artifactId>asterix</artifactId>
 		<groupId>edu.uci.ics.asterix</groupId>
-		<version>0.0.5-SNAPSHOT</version>
+		<version>0.0.6-SNAPSHOT</version>
 	</parent>
 	<artifactId>asterix-external-data</artifactId>
 
@@ -84,14 +84,14 @@
 		<dependency>
 			<groupId>edu.uci.ics.asterix</groupId>
 			<artifactId>asterix-om</artifactId>
-			<version>0.0.5-SNAPSHOT</version>
+			<version>0.0.6-SNAPSHOT</version>
 			<type>jar</type>
 			<scope>compile</scope>
 		</dependency>
 		<dependency>
 			<groupId>edu.uci.ics.asterix</groupId>
 			<artifactId>asterix-runtime</artifactId>
-			<version>0.0.5-SNAPSHOT</version>
+			<version>0.0.6-SNAPSHOT</version>
 			<type>jar</type>
 			<scope>compile</scope>
 		</dependency>
diff --git a/asterix-installer/pom.xml b/asterix-installer/pom.xml
index 87a73af..4b1add5 100644
--- a/asterix-installer/pom.xml
+++ b/asterix-installer/pom.xml
@@ -3,149 +3,186 @@
   <parent>
           <artifactId>asterix</artifactId>
           <groupId>edu.uci.ics.asterix</groupId>
-          <version>0.0.5-SNAPSHOT</version>
+          <version>0.0.6-SNAPSHOT</version>
   </parent>
   <artifactId>asterix-installer</artifactId>
+	<properties>
+		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+	</properties>
 
-  <properties>
-    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
-  </properties>
+	<build>
+		<plugins>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-compiler-plugin</artifactId>
+				<version>2.0.2</version>
+				<configuration>
+					<source>1.6</source>
+					<target>1.6</target>
+				</configuration>
+			</plugin>
 
-  <build>
-    <plugins>
-       <plugin>
-          <groupId>org.apache.maven.plugins</groupId>
-          <artifactId>maven-compiler-plugin</artifactId>
-          <version>2.0.2</version>
-          <configuration>
-             <source>1.6</source>
-             <target>1.6</target>
-          </configuration>
-       </plugin>
+			<plugin>
+				<groupId>org.jvnet.jaxb2.maven2</groupId>
+				<artifactId>maven-jaxb2-plugin</artifactId>
+				<executions>
+					<execution>
+						<id>configuration</id>
+						<goals>
+							<goal>generate</goal>
+						</goals>
+						<configuration>
+							<args>
+								<arg>-Xsetters</arg>
+								<arg>-Xvalue-constructor</arg>
+							</args>
+							<plugins>
+								<plugin>
+									<groupId>org.jvnet.jaxb2_commons</groupId>
+									<artifactId>jaxb2-basics</artifactId>
+									<version>0.6.2</version>
+								</plugin>
+								<plugin>
+									<groupId>org.jvnet.jaxb2_commons</groupId>
+									<artifactId>jaxb2-value-constructor</artifactId>
+									<version>3.0</version>
+								</plugin>
+							</plugins>
+							<schemaDirectory>src/main/resources/schema</schemaDirectory>
+							<schemaIncludes>
+								<include>installer-conf.xsd</include>
+							</schemaIncludes>
+							<generatePackage>edu.uci.ics.asterix.installer.schema.conf</generatePackage>
+							<generateDirectory>${project.build.directory}/generated-sources/configuration</generateDirectory>
+						</configuration>
+					</execution>
+					<execution>
+						<id>cluster</id>
+						<goals>
+							<goal>generate</goal>
+						</goals>
+						<configuration>
+							<args>
+								<arg>-Xsetters</arg>
+								<arg>-Xvalue-constructor</arg>
+							</args>
+							<schemaDirectory>src/main/resources/schema</schemaDirectory>
+							<schemaIncludes>
+								<include>cluster.xsd</include>
+							</schemaIncludes>
+							<generatePackage>edu.uci.ics.asterix.installer.schema.cluster</generatePackage>
+							<bindingDirectory>src/main/resources/schema</bindingDirectory>
+							<bindingIncludes>
+								<bindingInclude>jaxb-bindings.xjb</bindingInclude>
+							</bindingIncludes>
+							<generateDirectory>${project.build.directory}/generated-sources/cluster</generateDirectory>
+						</configuration>
+					</execution>
+				</executions>
+			</plugin>
+			<plugin>
+				<artifactId>maven-assembly-plugin</artifactId>
+				<version>2.2-beta-5</version>
+				<executions>
+					<execution>
+						<configuration>
+							<descriptor>src/main/assembly/binary-assembly.xml</descriptor>
+						</configuration>
+						<phase>package</phase>
+						<goals>
+							<goal>attached</goal>
+						</goals>
+					</execution>
+				</executions>
+			</plugin>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-failsafe-plugin</artifactId>
+				<version>2.6</version>
+				<executions>
+					<execution>
+						<goals>
+							<goal>integration-test</goal>
+							<goal>verify</goal>
+						</goals>
+					</execution>
+				</executions>
+			</plugin>
+		</plugins>
+	</build>
 
-       <plugin>
-          <groupId>org.jvnet.jaxb2.maven2</groupId>
-          <artifactId>maven-jaxb2-plugin</artifactId>
-          <executions>
-            <execution>
-              <id>configuration</id>
-              <goals>
-                <goal>generate</goal>
-              </goals>
-              <configuration>
-                <args>
-                  <arg>-Xsetters</arg>
-                  <arg>-Xvalue-constructor</arg>
-                </args>
-                <plugins>
-                  <plugin>
-                    <groupId>org.jvnet.jaxb2_commons</groupId>
-                    <artifactId>jaxb2-basics</artifactId>
-                    <version>0.6.2</version>
-                  </plugin>
-                  <plugin>
-                    <groupId>org.jvnet.jaxb2_commons</groupId>
-                    <artifactId>jaxb2-value-constructor</artifactId>
-                    <version>3.0</version>
-                  </plugin>
-                </plugins>
-                <schemaDirectory>src/main/resources/schema</schemaDirectory>
-                <schemaIncludes>
-                  <include>installer-conf.xsd</include>
-                </schemaIncludes>
-                <generatePackage>edu.uci.ics.asterix.installer.schema.conf</generatePackage>
-                <generateDirectory>${project.build.directory}/generated-sources/configuration</generateDirectory>
-              </configuration>
-            </execution>
-            <execution>
-              <id>cluster</id>
-              <goals>
-                <goal>generate</goal>
-              </goals>
-              <configuration>
-                <schemaDirectory>src/main/resources/schema</schemaDirectory>
-                <schemaIncludes>
-                  <include>cluster.xsd</include>
-                </schemaIncludes>
-                <generatePackage>edu.uci.ics.asterix.installer.schema.cluster</generatePackage>
-                <bindingDirectory>src/main/resources/schema</bindingDirectory>
-                <bindingIncludes>
-                  <bindingInclude>jaxb-bindings.xjb</bindingInclude>
-                </bindingIncludes>
-                <generateDirectory>${project.build.directory}/generated-sources/cluster</generateDirectory>
-              </configuration>
-            </execution>
-          </executions>
-       </plugin>
-       <plugin>
-         <artifactId>maven-assembly-plugin</artifactId>
-         <version>2.2-beta-2</version>
-         <executions>
-           <execution>
-             <configuration>
-               <descriptor>src/main/assembly/binary-assembly.xml</descriptor>
-             </configuration>
-             <phase>package</phase>
-             <goals>
-               <goal>attached</goal>
-             </goals>
-           </execution>
-         </executions>
-       </plugin>
-    </plugins> 
-  </build>
+	<dependencies>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>4.8.1</version>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>args4j</groupId>
+			<artifactId>args4j</artifactId>
+			<version>2.0.12</version>
+			<type>jar</type>
+			<scope>compile</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.zookeeper</groupId>
+			<artifactId>zookeeper</artifactId>
+			<version>3.4.5</version>
+			<exclusions>
+				<exclusion>
+					<groupId>com.sun.jmx</groupId>
+					<artifactId>jmxri</artifactId>
+				</exclusion>
+				<exclusion>
+					<groupId>com.sun.jdmk</groupId>
+					<artifactId>jmxtools</artifactId>
+				</exclusion>
+				<exclusion>
+					<groupId>javax.jms</groupId>
+					<artifactId>jms</artifactId>
+				</exclusion>
+			</exclusions>
+		</dependency>
+		<dependency>
+			<groupId>commons-io</groupId>
+			<artifactId>commons-io</artifactId>
+			<version>1.4</version>
+		</dependency>
+		<dependency>
+			<groupId>edu.uci.ics.asterix</groupId>
+			<artifactId>asterix-events</artifactId>
+			<version>0.0.6-SNAPSHOT</version>
+			<type>jar</type>
+			<scope>compile</scope>
+		</dependency>
+		<dependency>
+			<groupId>edu.uci.ics.asterix</groupId>
+			<artifactId>asterix-common</artifactId>
+			<version>0.0.6-SNAPSHOT</version>
+			<type>jar</type>
+			<scope>compile</scope>
+		</dependency>
+                <dependency>
+                        <groupId>edu.uci.ics.asterix</groupId>
+                        <artifactId>asterix-common</artifactId>
+                        <version>0.0.6-SNAPSHOT</version>
+                        <type>test-jar</type>
+                        <scope>test</scope>
+                </dependency>
+		<dependency>
+			<groupId>edu.uci.ics.asterix</groupId>
+			<artifactId>asterix-server</artifactId>
+			<version>0.0.6-SNAPSHOT</version>
+			<type>zip</type>
+			<classifier>binary-assembly</classifier>
+		</dependency>
+                <dependency>
+                        <groupId>edu.uci.ics.asterix</groupId>
+                        <artifactId>asterix-test-framework</artifactId>
+                        <version>0.0.6-SNAPSHOT</version>
+                        <scope>test</scope>
+                </dependency>
+	</dependencies>
 
-  <dependencies>
-    <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
-      <version>3.8.1</version>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>args4j</groupId>
-      <artifactId>args4j</artifactId>
-      <version>2.0.12</version>
-      <type>jar</type>
-      <scope>compile</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.apache.zookeeper</groupId>
-      <artifactId>zookeeper</artifactId>
-      <version>3.4.5</version>
-      <exclusions>
-            <exclusion>
-                <groupId>com.sun.jmx</groupId>
-                <artifactId>jmxri</artifactId>
-            </exclusion>
-            <exclusion>
-                <groupId>com.sun.jdmk</groupId>
-                <artifactId>jmxtools</artifactId>
-            </exclusion>
-            <exclusion>
-                <groupId>javax.jms</groupId>
-                <artifactId>jms</artifactId>
-            </exclusion>
-        </exclusions>
-    </dependency>
-    <dependency>
-        <groupId>commons-io</groupId>
-        <artifactId>commons-io</artifactId>
-        <version>1.4</version>
-    </dependency>
-    <dependency>
-        <groupId>edu.uci.ics.asterix</groupId>
-        <artifactId>asterix-events</artifactId>
-        <version>0.0.5-SNAPSHOT</version>
-        <type>jar</type>
-        <scope>compile</scope>
-    </dependency>
-    <dependency>
-        <groupId>edu.uci.ics.asterix</groupId>
-        <artifactId>asterix-server</artifactId>
-        <version>0.0.5-SNAPSHOT</version>
-        <type>zip</type>
-        <classifier>binary-assembly</classifier>
-    </dependency>
-  </dependencies>
 </project>
diff --git a/asterix-installer/src/main/assembly/binary-assembly.xml b/asterix-installer/src/main/assembly/binary-assembly.xml
index 6a0c130..66d6cfe 100644
--- a/asterix-installer/src/main/assembly/binary-assembly.xml
+++ b/asterix-installer/src/main/assembly/binary-assembly.xml
@@ -2,6 +2,7 @@
   <id>binary-assembly</id>
   <formats>
     <format>zip</format>
+    <format>dir</format>
   </formats>
   <includeBaseDirectory>false</includeBaseDirectory>
   <fileSets>
@@ -61,6 +62,7 @@
       <includes>
          <include>log4j:log4j</include>
          <include>edu.uci.ics.asterix:asterix-events</include>
+         <include>edu.uci.ics.asterix:asterix-common</include>
          <include>org.apache.zookeeper:zookeeper</include>
          <include>args4j:args4j</include>
          <include>log4j:log4j</include>
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 5ef7449..814f3c9 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
@@ -15,10 +15,10 @@
 package edu.uci.ics.asterix.installer.command;
 
 import java.util.Date;
-import java.util.Properties;
 
 import org.kohsuke.args4j.Option;
 
+import edu.uci.ics.asterix.common.configuration.AsterixConfiguration;
 import edu.uci.ics.asterix.installer.driver.InstallerDriver;
 import edu.uci.ics.asterix.installer.driver.InstallerUtil;
 import edu.uci.ics.asterix.installer.model.AsterixInstance;
@@ -35,12 +35,14 @@
         InstallerUtil.validateAsterixInstanceExists(instanceName, State.INACTIVE);
         ILookupService lookupService = ServiceProvider.INSTANCE.getLookupService();
         AsterixInstance instance = lookupService.getAsterixInstance(instanceName);
-
-        Properties asterixConfProp = InstallerUtil.getAsterixConfiguration(((AlterConfig) config).confPath);
-        instance.setConfiguration(asterixConfProp);
+        InstallerUtil.createClusterProperties(instance.getCluster(), instance.getAsterixConfiguration());
+        AsterixConfiguration asterixConfiguration = InstallerUtil
+                .getAsterixConfiguration(((AlterConfig) config).confPath);
+        instance.setAsterixConfiguration(asterixConfiguration);
         instance.setModifiedTimestamp(new Date());
         lookupService.updateAsterixInstance(instance);
-        LOGGER.info("Configuration for Asterix instance: " + instanceName + " has been altered");
+        LOGGER.info("Altered configuration settings for Asterix instance: " + instanceName);
+
     }
 
     @Override
@@ -52,8 +54,8 @@
     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.";
+                + "\nChanged configuration settings will be reflected when the instance is started."
+                + "\n\nAvailable arguments/options" + "\n-n name of the ASTERIX instance.";
     }
 
 }
@@ -63,7 +65,7 @@
     @Option(name = "-n", required = true, usage = "Name of Asterix Instance")
     public String name;
 
-    @Option(name = "-conf", required = true, usage = "Path to instance configuration")
+    @Option(name = "-a", required = true, usage = "Path to asterix instance configuration")
     public String confPath;
 
 }
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 e742c4e..43400ea 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,9 @@
         cluster.setWorkingDir(new WorkingDir(workingDir, true));
         cluster.setIodevices(workingDir);
         cluster.setStore("storage");
-        cluster.setLogdir(workingDir + File.separator + "logs");
-        cluster.setJavaHome(System.getenv("JAVA_HOME"));
-        cluster.setJavaOpts("-Xmx1024m");
+        cluster.setLogDir(workingDir + File.separator + "logs");
+        cluster.setTxnLogDir(workingDir + File.separator + "txnLogs");
+        cluster.setJavaHome(System.getProperty("java.home"));
 
         JAXBContext ctx = JAXBContext.newInstance(Cluster.class);
         Marshaller marshaller = ctx.createMarshaller();
@@ -44,7 +44,7 @@
         configuration.getZookeeper().setHomeDir(
                 InstallerDriver.getManagixHome() + File.separator + InstallerDriver.MANAGIX_INTERNAL_DIR
                         + File.separator + "zookeeper_home");
-        configuration.getZookeeper().getServers().setJavaHome(System.getenv("JAVA_HOME"));
+        configuration.getZookeeper().getServers().setJavaHome(System.getProperty("java.home"));
 
         marshaller = ctx.createMarshaller();
         marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
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 2de8e53..01a409e 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
@@ -15,16 +15,13 @@
 package edu.uci.ics.asterix.installer.command;
 
 import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
 
 import org.kohsuke.args4j.Option;
 
+import edu.uci.ics.asterix.common.configuration.AsterixConfiguration;
 import edu.uci.ics.asterix.event.management.EventUtil;
 import edu.uci.ics.asterix.event.management.EventrixClient;
 import edu.uci.ics.asterix.event.schema.cluster.Cluster;
-import edu.uci.ics.asterix.event.schema.cluster.Env;
-import edu.uci.ics.asterix.event.schema.cluster.Property;
 import edu.uci.ics.asterix.event.schema.pattern.Patterns;
 import edu.uci.ics.asterix.installer.driver.InstallerDriver;
 import edu.uci.ics.asterix.installer.driver.InstallerUtil;
@@ -38,6 +35,7 @@
 
     private String asterixInstanceName;
     private Cluster cluster;
+    private AsterixConfiguration asterixConfiguration;
 
     @Override
     protected void execCommand() throws Exception {
@@ -51,24 +49,12 @@
         InstallerUtil.validateAsterixInstanceNotExists(asterixInstanceName);
         CreateConfig createConfig = (CreateConfig) config;
         cluster = EventUtil.getCluster(createConfig.clusterPath);
-        AsterixInstance asterixInstance = InstallerUtil.createAsterixInstance(asterixInstanceName, cluster);
+        asterixConfiguration = InstallerUtil.getAsterixConfiguration(createConfig.asterixConfPath);
+        AsterixInstance asterixInstance = InstallerUtil.createAsterixInstance(asterixInstanceName, cluster,
+                asterixConfiguration);
         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().getClientIp()));
-        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));
-
+        InstallerUtil.createAsterixZip(asterixInstance);
+        InstallerUtil.createClusterProperties(cluster, asterixConfiguration);
         EventrixClient eventrixClient = InstallerUtil.getEventrixClient(cluster);
         PatternCreator pc = new PatternCreator();
 
@@ -104,7 +90,8 @@
         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";
+                + "\n-n Name of the ASTERIX instance." + "\n-c Path to the cluster configuration file"
+                + "\n[-a] Path to asterix configuration file" + "\n [..] indicates optional flag";
     }
 
 }
@@ -117,4 +104,7 @@
     @Option(name = "-c", required = true, usage = "Path to cluster configuration")
     public String clusterPath;
 
+    @Option(name = "-a", required = false, usage = "Path to asterix configuration")
+    public String asterixConfPath;
+
 }
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
index a9864a3..3bc700d 100644
--- 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
@@ -55,6 +55,9 @@
             case VALIDATE:
                 helpMessage = new ValidateCommand().getUsageDescription();
                 break;
+            case ALTER:
+                helpMessage = new AlterCommand().getUsageDescription();
+                break;
             default:
                 helpMessage = "Unknown command " + command;
         }
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 01fdda4..1180a4e 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
@@ -25,8 +25,8 @@
 import edu.uci.ics.asterix.installer.error.VerificationUtil;
 import edu.uci.ics.asterix.installer.events.PatternCreator;
 import edu.uci.ics.asterix.installer.model.AsterixInstance;
-import edu.uci.ics.asterix.installer.model.AsterixInstance.State;
 import edu.uci.ics.asterix.installer.model.AsterixRuntimeState;
+import edu.uci.ics.asterix.installer.model.AsterixInstance.State;
 import edu.uci.ics.asterix.installer.service.ServiceProvider;
 
 public class StartCommand extends AbstractCommand {
@@ -36,13 +36,13 @@
         InstallerDriver.initConfig();
         String asterixInstanceName = ((StartConfig) config).name;
         AsterixInstance instance = InstallerUtil.validateAsterixInstanceExists(asterixInstanceName, State.INACTIVE);
-        InstallerUtil.createAsterixZip(instance, false);
+        InstallerUtil.createAsterixZip(instance);
         PatternCreator pc = new PatternCreator();
         EventrixClient client = InstallerUtil.getEventrixClient(instance.getCluster());
         Patterns asterixBinaryTransferPattern = pc.getAsterixBinaryTransferPattern(asterixInstanceName,
                 instance.getCluster());
         client.submit(asterixBinaryTransferPattern);
-
+        InstallerUtil.createClusterProperties(instance.getCluster(), instance.getAsterixConfiguration());
         Patterns patterns = pc.getStartAsterixPattern(asterixInstanceName, instance.getCluster());
         client.submit(patterns);
         InstallerUtil.deleteDirectory(InstallerDriver.getManagixHome() + File.separator + InstallerDriver.ASTERIX_DIR
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 4e6460b..10e7df2 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
@@ -15,7 +15,6 @@
 package edu.uci.ics.asterix.installer.command;
 
 import java.io.File;
-import java.net.InetAddress;
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.List;
@@ -32,7 +31,6 @@
 import edu.uci.ics.asterix.event.schema.cluster.Node;
 import edu.uci.ics.asterix.installer.driver.InstallerDriver;
 import edu.uci.ics.asterix.installer.driver.InstallerUtil;
-import edu.uci.ics.asterix.installer.model.ProcessInfo;
 import edu.uci.ics.asterix.installer.schema.conf.Configuration;
 import edu.uci.ics.asterix.installer.schema.conf.Zookeeper;
 
@@ -110,8 +108,8 @@
             serverIds.add(cluster.getMasterNode().getId());
 
             MasterNode masterNode = cluster.getMasterNode();
-            Node master = new Node(masterNode.getId(), masterNode.getClusterIp(), masterNode.getJavaOpts(),
-                    masterNode.getJavaHome(), masterNode.getLogdir(), null, null, null);
+            Node master = new Node(masterNode.getId(), masterNode.getClusterIp(), masterNode.getJavaHome(),
+                    masterNode.getLogDir(), null, null, null);
             ipAddresses.add(masterNode.getClusterIp());
 
             valid = valid & validateNodeConfiguration(master, cluster);
@@ -163,8 +161,8 @@
 
     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.getLogDir() != null && checkTemporaryPath(cluster.getLogDir())) {
+            tempDirs.add("Log directory: " + cluster.getLogDir());
         }
         if (cluster.getIodevices() != null && checkTemporaryPath(cluster.getIodevices())) {
             tempDirs.add("IO Device: " + cluster.getIodevices());
@@ -183,7 +181,6 @@
 
     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;
@@ -191,8 +188,8 @@
             }
         }
 
-        if (node.getLogdir() == null || node.getLogdir().length() == 0) {
-            if (cluster.getLogdir() == null || cluster.getLogdir().length() == 0) {
+        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);
             }
@@ -252,33 +249,13 @@
                     + File.separator + InstallerDriver.MANAGIX_CONF_XML);
         }
 
-        for (String server : zk.getServers().getServer()) {
-            valid = valid && checkNodeReachability(server);
-        }
-
-        if (valid)
+        if (valid) {
             valid = valid & checkPasswordLessSSHLogin(System.getProperty("user.name"), zk.getServers().getServer());
-        {
         }
 
         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;
-    }
-
 }
 
 class ValidateConfig extends CommandConfig {
diff --git a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/driver/InstallerDriver.java b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/driver/InstallerDriver.java
index 3596032..08249ee 100644
--- a/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/driver/InstallerDriver.java
+++ b/asterix-installer/src/main/java/edu/uci/ics/asterix/installer/driver/InstallerDriver.java
@@ -34,6 +34,8 @@
     public static final String MANAGIX_EVENT_DIR = MANAGIX_INTERNAL_DIR + File.separator + "eventrix";
     public static final String MANAGIX_EVENT_SCRIPTS_DIR = MANAGIX_INTERNAL_DIR + File.separator + "eventrix"
             + File.separator + "scripts";
+    public static final String DEFAULT_ASTERIX_CONFIGURATION_PATH = "conf" + File.separator + File.separator
+            + "asterix-configuration.xml";
     public static final String ASTERIX_DIR = "asterix";
     public static final String EVENTS_DIR = "events";
 
@@ -92,6 +94,10 @@
         return managixHome;
     }
 
+    public static void setManagixHome(String managixHome) {
+        InstallerDriver.managixHome = managixHome;
+    }
+
     public static String getAsterixDir() {
         return managixHome + File.separator + ASTERIX_DIR;
     }
@@ -125,13 +131,13 @@
         buffer.append("stop     " + ":" + " Stops an asterix instance that is in ACTIVE state" + "\n");
         buffer.append("backup   " + ":" + " Creates a back up for an existing asterix instance" + "\n");
         buffer.append("restore  " + ":" + " Restores an asterix instance" + "\n");
+        buffer.append("alter    " + ":" + " Alter the instance's configuration settings" + "\n");
         buffer.append("describe " + ":" + " Describes an existing asterix instance" + "\n");
         buffer.append("validate " + ":" + " Validates the installer/cluster configuration" + "\n");
-        buffer.append("configure" + ":" + " Auto-generate configuration for local psedu-distributed Asterix instance"
-                + "\n");
+        buffer.append("configure" + ":" + " Configure the Asterix installer" + "\n");
         buffer.append("shutdown " + ":" + " Shutdown the installer service" + "\n");
         buffer.append("help     " + ":" + " Provides usage description of a command" + "\n");
-
+        buffer.append("\nTo get more information about a command, use managix help -cmd <command>");
         LOGGER.info(buffer.toString());
     }
 }
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 e2be142..c9395ca 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
@@ -40,12 +40,21 @@
 import java.util.zip.ZipInputStream;
 import java.util.zip.ZipOutputStream;
 
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
+
 import org.apache.commons.io.IOUtils;
 
+import edu.uci.ics.asterix.common.configuration.AsterixConfiguration;
+import edu.uci.ics.asterix.common.configuration.Store;
 import edu.uci.ics.asterix.event.driver.EventDriver;
 import edu.uci.ics.asterix.event.management.EventrixClient;
 import edu.uci.ics.asterix.event.schema.cluster.Cluster;
+import edu.uci.ics.asterix.event.schema.cluster.Env;
 import edu.uci.ics.asterix.event.schema.cluster.Node;
+import edu.uci.ics.asterix.event.schema.cluster.Property;
 import edu.uci.ics.asterix.installer.error.InstallerException;
 import edu.uci.ics.asterix.installer.error.OutputHandler;
 import edu.uci.ics.asterix.installer.model.AsterixInstance;
@@ -56,40 +65,63 @@
 
     public static final String TXN_LOG_DIR = "txnLogs";
     public static final String TXN_LOG_DIR_KEY_SUFFIX = "txnLogDir";
+    public static final String ASTERIX_CONFIGURATION_FILE = "asterix-configuration.xml";
+    public static final String TXN_LOG_CONFIGURATION_FILE = "log.properties";
 
-    public static AsterixInstance createAsterixInstance(String asterixInstanceName, Cluster cluster)
-            throws FileNotFoundException, IOException {
-        Properties asterixConfProp = new Properties();
-        asterixConfProp.put("output_dir", cluster.getWorkingDir().getDir() + File.separator + "asterix_output");
+    public static AsterixInstance createAsterixInstance(String asterixInstanceName, Cluster cluster,
+            AsterixConfiguration asterixConfiguration) throws FileNotFoundException, IOException {
         Node metadataNode = getMetadataNode(cluster);
         String asterixZipName = InstallerDriver.getAsterixZip().substring(
                 InstallerDriver.getAsterixZip().lastIndexOf(File.separator) + 1);
         String asterixVersion = asterixZipName.substring("asterix-server-".length(),
                 asterixZipName.indexOf("-binary-assembly"));
-        AsterixInstance instance = new AsterixInstance(asterixInstanceName, cluster, asterixConfProp,
+        AsterixInstance instance = new AsterixInstance(asterixInstanceName, cluster, asterixConfiguration,
                 metadataNode.getId(), asterixVersion);
         return instance;
     }
 
-    public static void createAsterixZip(AsterixInstance asterixInstance, boolean newDeployment) throws IOException,
-            InterruptedException {
+    public static void createAsterixZip(AsterixInstance asterixInstance) throws IOException, InterruptedException,
+            JAXBException, InstallerException {
 
-        String modifiedZipPath = injectAsterixPropertyFile(InstallerDriver.getAsterixZip(), asterixInstance,
-                newDeployment);
+        String modifiedZipPath = injectAsterixPropertyFile(InstallerDriver.getAsterixZip(), asterixInstance);
         injectAsterixLogPropertyFile(modifiedZipPath, asterixInstance);
     }
 
-    private static String injectAsterixPropertyFile(String origZipFile, AsterixInstance asterixInstance,
-            boolean newDeployment) throws IOException {
-        writeAsterixConfigurationFile(asterixInstance, newDeployment);
+    public static void createClusterProperties(Cluster cluster, AsterixConfiguration asterixConfiguration) {
+        List<Property> clusterProperties = null;
+        if (cluster.getEnv() != null && cluster.getEnv().getProperty() != null) {
+            clusterProperties = cluster.getEnv().getProperty();
+            clusterProperties.clear();
+        } else {
+            clusterProperties = new ArrayList<Property>();
+        }
+        for (edu.uci.ics.asterix.common.configuration.Property property : asterixConfiguration.getProperty()) {
+            if (property.getName().equalsIgnoreCase(AsterixInstance.CC_JAVA_OPTS)) {
+                clusterProperties.add(new Property("CC_JAVA_OPTS", property.getValue()));
+            } else if (property.getName().equalsIgnoreCase(AsterixInstance.NC_JAVA_OPTS)) {
+                clusterProperties.add(new Property("NC_JAVA_OPTS", property.getValue()));
+            }
+        }
+        clusterProperties.add(new Property("ASTERIX_HOME", cluster.getWorkingDir().getDir() + File.separator
+                + "asterix"));
+        clusterProperties.add(new Property("CLUSTER_NET_IP", cluster.getMasterNode().getClusterIp()));
+        clusterProperties.add(new Property("CLIENT_NET_IP", cluster.getMasterNode().getClientIp()));
+        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));
+    }
+
+    private static String injectAsterixPropertyFile(String origZipFile, AsterixInstance asterixInstance)
+            throws IOException, JAXBException {
+        writeAsterixConfigurationFile(asterixInstance);
         String asterixInstanceDir = InstallerDriver.getAsterixDir() + File.separator + asterixInstance.getName();
         unzip(origZipFile, asterixInstanceDir);
         File sourceJar = new File(asterixInstanceDir + File.separator + "lib" + File.separator + "asterix-app-"
                 + asterixInstance.getAsterixVersion() + ".jar");
-        String asterixPropertyFile = "test.properties";
-        File replacementFile = new File(asterixInstanceDir + File.separator + "test.properties");
-        replaceInJar(sourceJar, asterixPropertyFile, replacementFile);
-        new File(asterixInstanceDir + File.separator + "test.properties").delete();
+        File replacementFile = new File(asterixInstanceDir + File.separator + ASTERIX_CONFIGURATION_FILE);
+        replaceInJar(sourceJar, ASTERIX_CONFIGURATION_FILE, replacementFile);
+        new File(asterixInstanceDir + File.separator + ASTERIX_CONFIGURATION_FILE).delete();
         String asterixZipName = InstallerDriver.getAsterixZip().substring(
                 InstallerDriver.getAsterixZip().lastIndexOf(File.separator) + 1);
         zipDir(new File(asterixInstanceDir), new File(asterixInstanceDir + File.separator + asterixZipName));
@@ -97,25 +129,24 @@
     }
 
     private static String injectAsterixLogPropertyFile(String origZipFile, AsterixInstance asterixInstance)
-            throws IOException {
+            throws IOException, InstallerException {
         String asterixInstanceDir = InstallerDriver.getAsterixDir() + File.separator + asterixInstance.getName();
         unzip(origZipFile, asterixInstanceDir);
         File sourceJar1 = new File(asterixInstanceDir + File.separator + "lib" + File.separator + "asterix-app-"
                 + asterixInstance.getAsterixVersion() + ".jar");
-        String txnLogPropertyFile = "log.properties";
         Properties txnLogProperties = new Properties();
         URLClassLoader urlClassLoader = new URLClassLoader(new URL[] { sourceJar1.toURI().toURL() });
-        InputStream in = urlClassLoader.getResourceAsStream(txnLogPropertyFile);
+        InputStream in = urlClassLoader.getResourceAsStream(TXN_LOG_CONFIGURATION_FILE);
         if (in != null) {
             txnLogProperties.load(in);
         }
 
-        writeAsterixLogConfigurationFile(asterixInstance.getName(), asterixInstance.getCluster(), txnLogProperties);
+        writeAsterixLogConfigurationFile(asterixInstance, txnLogProperties);
 
         File sourceJar2 = new File(asterixInstanceDir + File.separator + "lib" + File.separator + "asterix-app-"
                 + asterixInstance.getAsterixVersion() + ".jar");
         File replacementFile = new File(asterixInstanceDir + File.separator + "log.properties");
-        replaceInJar(sourceJar2, txnLogPropertyFile, replacementFile);
+        replaceInJar(sourceJar2, TXN_LOG_CONFIGURATION_FILE, replacementFile);
 
         new File(asterixInstanceDir + File.separator + "log.properties").delete();
         String asterixZipName = InstallerDriver.getAsterixZip().substring(
@@ -174,54 +205,74 @@
         return nodeDataStore.toString();
     }
 
-    private static void writeAsterixConfigurationFile(AsterixInstance asterixInstance, boolean newData)
-            throws IOException {
+    private static void writeAsterixConfigurationFile(AsterixInstance asterixInstance) throws IOException,
+            JAXBException {
         String asterixInstanceName = asterixInstance.getName();
         Cluster cluster = asterixInstance.getCluster();
         String metadataNodeId = asterixInstance.getMetadataNodeId();
 
-        StringBuffer conf = new StringBuffer();
-        conf.append("MetadataNode=" + asterixInstanceName + "_" + metadataNodeId + "\n");
-        conf.append("NewUniverse=" + newData + "\n");
+        AsterixConfiguration configuration = asterixInstance.getAsterixConfiguration();
+        configuration.setMetadataNode(asterixInstanceName + "_" + metadataNodeId);
 
         String storeDir = null;
+        List<Store> stores = new ArrayList<Store>();
         for (Node node : cluster.getNode()) {
             storeDir = node.getStore() == null ? cluster.getStore() : node.getStore();
-            conf.append(asterixInstanceName + "_" + node.getId() + ".stores" + "=" + storeDir + "\n");
+            stores.add(new Store(asterixInstanceName + "_" + node.getId(), storeDir));
         }
-
-        Properties asterixConfProp = asterixInstance.getConfiguration();
-        String outputDir = asterixConfProp.getProperty("output_dir");
-        conf.append("OutputDir=" + outputDir);
+        configuration.setStore(stores);
 
         File asterixConfDir = new File(InstallerDriver.getAsterixDir() + File.separator + asterixInstanceName);
         asterixConfDir.mkdirs();
-        dumpToFile(InstallerDriver.getAsterixDir() + File.separator + asterixInstanceName + File.separator
-                + "test.properties", conf.toString());
+
+        JAXBContext ctx = JAXBContext.newInstance(AsterixConfiguration.class);
+        Marshaller marshaller = ctx.createMarshaller();
+        marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
+        marshaller.marshal(configuration, new FileOutputStream(asterixConfDir + File.separator
+                + ASTERIX_CONFIGURATION_FILE));
     }
 
-    private static void writeAsterixLogConfigurationFile(String asterixInstanceName, Cluster cluster,
-            Properties logProperties) throws IOException {
+    private static void writeAsterixLogConfigurationFile(AsterixInstance asterixInstance, Properties logProperties)
+            throws IOException, InstallerException {
+        String asterixInstanceName = asterixInstance.getName();
+        Cluster cluster = asterixInstance.getCluster();
         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 txnLogDir = iodevices.split(",")[0].trim() + File.separator + InstallerUtil.TXN_LOG_DIR;
+            String txnLogDir = node.getTxnLogDir() == null ? cluster.getTxnLogDir() : node.getTxnLogDir();
+            if (txnLogDir == null) {
+                throw new InstallerException("Transaction log directory (txn_log_dir) not configured for node: "
+                        + node.getId());
+            }
             conf.append(asterixInstanceName + "_" + node.getId() + "." + TXN_LOG_DIR_KEY_SUFFIX + "=" + txnLogDir
                     + "\n");
         }
+        List<edu.uci.ics.asterix.common.configuration.Property> properties = asterixInstance.getAsterixConfiguration()
+                .getProperty();
+        for (edu.uci.ics.asterix.common.configuration.Property p : properties) {
+            if (p.getName().trim().toLowerCase().contains("log")) {
+                conf.append(p.getValue() + "=" + p.getValue());
+            }
+        }
         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));
-        return prop;
+    public static AsterixConfiguration getAsterixConfiguration(String asterixConf) throws FileNotFoundException,
+            IOException, JAXBException {
+        if (asterixConf == null) {
+            asterixConf = InstallerDriver.getManagixHome() + File.separator
+                    + InstallerDriver.DEFAULT_ASTERIX_CONFIGURATION_PATH;
+        }
+        File file = new File(asterixConf);
+        JAXBContext ctx = JAXBContext.newInstance(AsterixConfiguration.class);
+        Unmarshaller unmarshaller = ctx.createUnmarshaller();
+        AsterixConfiguration asterixConfiguration = (AsterixConfiguration) unmarshaller.unmarshal(file);
+        return asterixConfiguration;
     }
 
     public static void unzip(String sourceFile, String destDir) throws IOException {
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 0d50bbf..4216978 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
@@ -173,16 +173,18 @@
         String workingDir = cluster.getWorkingDir().getDir();
         String backupId = "" + instance.getBackupInfo().size();
         String iodevices;
+        String txnLogDir;
         String store;
         String pargs;
         List<Pattern> patternList = new ArrayList<Pattern>();
         for (Node node : cluster.getNode()) {
             Nodeid nodeid = new Nodeid(new Value(null, node.getId()));
             iodevices = node.getIodevices() == null ? instance.getCluster().getIodevices() : node.getIodevices();
+            txnLogDir = node.getTxnLogDir() == null ? instance.getCluster().getTxnLogDir() : node.getTxnLogDir();
             store = node.getStore() == null ? cluster.getStore() : node.getStore();
             pargs = workingDir + " " + instance.getName() + " " + iodevices + " " + store + " "
-                    + BackupCommand.ASTERIX_ROOT_METADATA_DIR + " " + InstallerUtil.TXN_LOG_DIR + " " + backupId + " "
-                    + backupDir + " " + "local" + " " + node.getId();
+                    + BackupCommand.ASTERIX_ROOT_METADATA_DIR + " " + txnLogDir + " " + backupId + " " + backupDir
+                    + " " + "local" + " " + node.getId();
             Event event = new Event("backup", nodeid, pargs);
             patternList.add(new Pattern(null, 1, null, event));
         }
@@ -407,7 +409,7 @@
     private Patterns createRemoveAsterixLogDirPattern(AsterixInstance instance) throws Exception {
         List<Pattern> patternList = new ArrayList<Pattern>();
         Cluster cluster = instance.getCluster();
-        String pargs = instance.getCluster().getLogdir();
+        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));
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 9a2d43d..1eba89f 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
@@ -18,8 +18,9 @@
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
-import java.util.Properties;
 
+import edu.uci.ics.asterix.common.configuration.AsterixConfiguration;
+import edu.uci.ics.asterix.common.configuration.Property;
 import edu.uci.ics.asterix.event.schema.cluster.Cluster;
 import edu.uci.ics.asterix.event.schema.cluster.Node;
 
@@ -27,6 +28,9 @@
 
     private static final long serialVersionUID = 2874439550187520449L;
 
+    public static final String CC_JAVA_OPTS = "cc_java_opts";
+    public static final String NC_JAVA_OPTS = "nc_java_opts";
+
     public enum State {
         ACTIVE,
         INACTIVE,
@@ -38,7 +42,7 @@
     private final Date createdTimestamp;
     private Date stateChangeTimestamp;
     private Date modifiedTimestamp;
-    private Properties configuration;
+    private AsterixConfiguration asterixConfiguration;
     private State state;
     private final String metadataNodeId;
     private final String asterixVersion;
@@ -47,11 +51,11 @@
     private AsterixRuntimeState runtimeState;
     private State previousState;
 
-    public AsterixInstance(String name, Cluster cluster, Properties configuration, String metadataNodeId,
-            String asterixVersion) {
+    public AsterixInstance(String name, Cluster cluster, AsterixConfiguration asterixConfiguration,
+            String metadataNodeId, String asterixVersion) {
         this.name = name;
         this.cluster = cluster;
-        this.configuration = configuration;
+        this.asterixConfiguration = asterixConfiguration;
         this.metadataNodeId = metadataNodeId;
         this.state = State.ACTIVE;
         this.previousState = State.UNUSABLE;
@@ -65,14 +69,6 @@
         return stateChangeTimestamp;
     }
 
-    public Properties getConfiguration() {
-        return configuration;
-    }
-
-    public void setConfiguration(Properties properties) {
-        this.configuration = properties;
-    }
-
     public State getState() {
         return state;
     }
@@ -174,9 +170,23 @@
             buffer.append(pInfo + "\n");
         }
 
+        buffer.append("\n");
+        buffer.append("Asterix Configuration\n");
+        for (Property property : asterixConfiguration.getProperty()) {
+            buffer.append(property.getName() + ":" + property.getValue() + "\n");
+        }
+
     }
 
     public State getPreviousState() {
         return previousState;
     }
+
+    public AsterixConfiguration getAsterixConfiguration() {
+        return asterixConfiguration;
+    }
+
+    public void setAsterixConfiguration(AsterixConfiguration asterixConfiguration) {
+        this.asterixConfiguration = asterixConfiguration;
+    }
 }
diff --git a/asterix-installer/src/main/resources/clusters/local/conf/asterix.conf b/asterix-installer/src/main/resources/clusters/local/conf/asterix.conf
deleted file mode 100644
index 659b48e..0000000
--- a/asterix-installer/src/main/resources/clusters/local/conf/asterix.conf
+++ /dev/null
@@ -1 +0,0 @@
-output_dir=/tmp/asterix_output/
diff --git a/asterix-installer/src/main/resources/clusters/local/local.xml b/asterix-installer/src/main/resources/clusters/local/local.xml
index d397bcd..0af8dfc 100644
--- a/asterix-installer/src/main/resources/clusters/local/local.xml
+++ b/asterix-installer/src/main/resources/clusters/local/local.xml
@@ -1,21 +1,21 @@
 <cluster xmlns="cluster">
   <name>local</name>
-  <workingDir>
+  <working_dir>
     <dir>/tmp/asterix-installer</dir>
     <NFS>true</NFS>
-  </workingDir>
-  <logdir>/tmp/asterix/logs</logdir>
+  </working_dir>
+  <log_dir>/tmp/asterix/logs</log_dir>
+  <txn_log_dir>/tmp/asterix/logs</txn_log_dir>
   <iodevices>/tmp</iodevices>
   <store>asterix/storage</store>
   <java_home></java_home>
-  <java_opts>-Xmx1024m</java_opts>
-  <master-node>
+  <master_node>
     <id>master</id>
-    <client-ip>127.0.0.1</client-ip>
-    <cluster-ip>127.0.0.1</cluster-ip>
-  </master-node>
+    <client_ip>127.0.0.1</client_ip>
+    <cluster_ip>127.0.0.1</cluster_ip>
+  </master_node>
   <node>
     <id>node1</id>
-    <cluster-ip>127.0.0.1</cluster-ip>
+    <cluster_ip>127.0.0.1</cluster_ip>
   </node>
 </cluster>
diff --git a/asterix-installer/src/main/resources/conf/asterix-configuration.xml b/asterix-installer/src/main/resources/conf/asterix-configuration.xml
new file mode 100644
index 0000000..37ddf88
--- /dev/null
+++ b/asterix-installer/src/main/resources/conf/asterix-configuration.xml
@@ -0,0 +1,116 @@
+<asterixConfiguration xmlns="asterixconf">
+
+	<property>
+		<name>nc_java_opts</name>
+		<value>-Xmx1024m</value>
+                <description>JVM parameters for each Node Contoller (NC)</description>
+	</property>
+
+	<property>
+		<name>cc_java_opts</name>
+		<value>-Xmx1024m</value>
+                <description>JVM parameters for each Cluster Contoller (CC)</description>
+	</property>
+
+	<property>
+		<name>size_memory_component</name>
+		<value>512m</value>
+                <description></description>
+	</property>
+
+	<property>
+		<name>total_size_memory_component</name>
+		<value>512m</value>
+                <description></description>
+	</property>
+
+	<property>
+		<name>log_buffer_num_pages</name>
+		<value>8</value>
+                <description></description>
+	</property>
+
+	<property>
+		<name>group_commit_interval</name>
+		<value>200ms</value>
+                <description></description>
+	</property>
+
+	<property>
+		<name>sort_op_memory</name>
+		<value>200m</value>
+                <description></description>
+	</property>
+
+	<property>
+		<name>join_op_memory</name>
+		<value>200m</value>
+                <description></description>
+	</property>
+
+	<property>
+		<name>web_interface_port</name>
+		<value>19001</value>
+                <description></description>
+	</property>
+
+	<property>
+		<name>num_pages_buffer_cache</name>
+		<value>8</value>
+                <description></description>
+	</property>
+
+	<property>
+		<name>log_level</name>
+		<value>INFO</value>
+                <description></description>
+	</property>
+
+	<property>
+		<name>lsn_threshold</name>
+		<value>64m</value>
+                <description></description>
+	</property>
+
+	<property>
+		<name>checkpointTermsInSecs</name>
+		<value>120</value>
+                <description></description>
+	</property>
+
+	<property>
+		<name>escalate_threshold_entity_to_dataset</name>
+		<value>8</value>
+                <description></description>
+	</property>
+
+	<property>
+		<name>num_pages_buffer_cache</name>
+		<value>1000</value>
+                <description></description>
+	</property>
+
+	<property>
+		<name>log_buffer_page_size</name>
+		<value>128k</value>
+                <description></description>
+	</property>
+
+	<property>
+		<name>log_partition_size</name>
+		<value>2147483648</value>
+                <description></description>
+	</property>
+
+	<property>
+		<name>shrink_timer_threshold</name>
+		<value>120000</value>
+                <description></description>
+	</property>
+
+	<property>
+		<name>log_buffer_num_pages</name>
+		<value>8</value>
+                <description></description>
+	</property>
+</asterixConfiguration>
diff --git a/asterix-installer/src/test/java/edu/uci/ics/asterix/installer/test/AsterixInstallerIntegrationUtil.java b/asterix-installer/src/test/java/edu/uci/ics/asterix/installer/test/AsterixInstallerIntegrationUtil.java
new file mode 100644
index 0000000..dc6f643
--- /dev/null
+++ b/asterix-installer/src/test/java/edu/uci/ics/asterix/installer/test/AsterixInstallerIntegrationUtil.java
@@ -0,0 +1,218 @@
+/*
+ * Copyright 2009-2013 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.test;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.math.BigInteger;
+import java.util.Map;
+import java.util.logging.Logger;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
+
+import edu.uci.ics.asterix.installer.command.CommandHandler;
+import edu.uci.ics.asterix.installer.command.ShutdownCommand;
+import edu.uci.ics.asterix.installer.driver.InstallerDriver;
+import edu.uci.ics.asterix.installer.error.VerificationUtil;
+import edu.uci.ics.asterix.installer.model.AsterixInstance;
+import edu.uci.ics.asterix.installer.model.AsterixInstance.State;
+import edu.uci.ics.asterix.installer.model.AsterixRuntimeState;
+import edu.uci.ics.asterix.installer.schema.conf.Configuration;
+import edu.uci.ics.asterix.installer.service.ServiceProvider;
+import edu.uci.ics.hyracks.api.client.HyracksConnection;
+import edu.uci.ics.hyracks.api.client.IHyracksClientConnection;
+
+public class AsterixInstallerIntegrationUtil {
+
+    private static String managixHome;
+    private static String clusterConfigurationPath;
+    private static final CommandHandler cmdHandler = new CommandHandler();
+    public static final String ASTERIX_INSTANCE_NAME = "asterix";
+    private static final String CC_IP_ADDRESS = "127.0.0.1";
+    private static final int DEFAULT_HYRACKS_CC_CLIENT_PORT = 1098;
+    private static final int zookeeperClientPort = 2900;
+    private static final int zookeeperTestClientPort = 3945;
+
+    private static IHyracksClientConnection hcc;
+
+    private static final Logger LOGGER = Logger.getLogger(AsterixInstallerIntegrationUtil.class.getName());
+
+    public static void deinit() throws Exception {
+        deleteInstance();
+        stopZookeeper();
+    }
+
+    public static void init() throws Exception {
+        File asterixProjectDir = new File(System.getProperty("user.dir"));
+        File installerTargetDir = new File(asterixProjectDir, "target");
+        String managixHomeDirName = installerTargetDir.list(new FilenameFilter() {
+            @Override
+            public boolean accept(File dir, String name) {
+                return new File(dir, name).isDirectory() && name.startsWith("asterix-installer")
+                        && name.endsWith("binary-assembly");
+            }
+
+        })[0];
+        managixHome = new File(installerTargetDir, managixHomeDirName).getAbsolutePath();
+        System.setProperty("log4j.configuration", managixHome + File.separator + "conf" + File.separator
+                + "log4j.properties");
+
+        managixHome = AsterixInstallerIntegrationUtil.getManagixHome();
+        clusterConfigurationPath = managixHome + File.separator + "clusters" + File.separator + "local"
+                + File.separator + "local.xml";
+
+        InstallerDriver.setManagixHome(managixHome);
+
+        String command = "configure";
+        cmdHandler.processCommand(command.split(" "));
+        command = "validate -c " + clusterConfigurationPath;
+        cmdHandler.processCommand(command.split(" "));
+
+        startZookeeper();
+        InstallerDriver.initConfig();
+        createInstance();
+        hcc = new HyracksConnection(CC_IP_ADDRESS, DEFAULT_HYRACKS_CC_CLIENT_PORT);
+    }
+
+    public static IHyracksClientConnection getHyracksConnection() {
+        return hcc;
+    }
+
+    private static void startZookeeper() throws Exception {
+        initZookeeperTestConfiguration(zookeeperClientPort);
+        String script = managixHome + File.separator + "bin" + File.separator + "managix";
+
+        // shutdown zookeeper if running
+        String command = "shutdown";
+        cmdHandler.processCommand(command.split(" "));
+
+         Thread.sleep(2000);
+
+        // start zookeeper 
+        initZookeeperTestConfiguration(zookeeperTestClientPort);
+        ProcessBuilder pb2 = new ProcessBuilder(script, "describe");
+        Map<String, String> env2 = pb2.environment();
+        env2.put("MANAGIX_HOME", managixHome);
+        pb2.start();
+
+        Thread.sleep(2000);
+    }
+
+    public static void createInstance() throws Exception {
+
+        String command = null;
+        AsterixInstance instance = ServiceProvider.INSTANCE.getLookupService()
+                .getAsterixInstance(ASTERIX_INSTANCE_NAME);
+        if (instance != null) {
+            transformIntoRequiredState(State.INACTIVE);
+            command = "delete -n " + ASTERIX_INSTANCE_NAME;
+            cmdHandler.processCommand(command.split(" "));
+        }
+
+        command = "create -n " + ASTERIX_INSTANCE_NAME + " " + "-c" + " " + clusterConfigurationPath;
+        cmdHandler.processCommand(command.split(" "));
+
+        instance = ServiceProvider.INSTANCE.getLookupService().getAsterixInstance(ASTERIX_INSTANCE_NAME);
+        AsterixRuntimeState state = VerificationUtil.getAsterixRuntimeState(instance);
+        assert (state.getFailedNCs().isEmpty() && state.isCcRunning());
+    }
+
+    private static void initZookeeperTestConfiguration(int port) throws JAXBException, FileNotFoundException {
+        String installerConfPath = InstallerDriver.getManagixHome() + File.separator + InstallerDriver.MANAGIX_CONF_XML;
+        JAXBContext ctx = JAXBContext.newInstance(Configuration.class);
+        Unmarshaller unmarshaller = ctx.createUnmarshaller();
+        Configuration configuration = (Configuration) unmarshaller.unmarshal(new File(installerConfPath));
+        configuration.getZookeeper().setClientPort(new BigInteger("" + port));
+        Marshaller marshaller = ctx.createMarshaller();
+        marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
+        marshaller.marshal(configuration, new FileOutputStream(installerConfPath));
+    }
+
+    public static void transformIntoRequiredState(AsterixInstance.State state) throws Exception {
+        AsterixInstance instance = ServiceProvider.INSTANCE.getLookupService()
+                .getAsterixInstance(ASTERIX_INSTANCE_NAME);
+        assert (instance != null);
+        if (instance.getState().equals(state)) {
+            return;
+        }
+        if (state.equals(AsterixInstance.State.UNUSABLE)) {
+            throw new IllegalArgumentException("Invalid desired state");
+        }
+
+        String command = null;
+        switch (instance.getState()) {
+            case ACTIVE:
+                command = "stop -n " + ASTERIX_INSTANCE_NAME;
+                break;
+            case INACTIVE:
+                command = "start -n " + ASTERIX_INSTANCE_NAME;
+                break;
+        }
+        cmdHandler.processCommand(command.split(" "));
+    }
+
+    private static void stopZookeeper() throws IOException, JAXBException {
+        String script = managixHome + File.separator + "bin" + File.separator + "managix";
+        // shutdown zookeeper if running
+        ProcessBuilder pb = new ProcessBuilder(script, "shutdown");
+        Map<String, String> env = pb.environment();
+        env.put("MANAGIX_HOME", managixHome);
+        pb.start();
+    }
+
+    private static void deleteInstance() throws Exception {
+        String command = null;
+        AsterixInstance instance = ServiceProvider.INSTANCE.getLookupService()
+                .getAsterixInstance(ASTERIX_INSTANCE_NAME);
+
+        if (instance == null) {
+            return;
+        } else {
+            transformIntoRequiredState(State.INACTIVE);
+            command = "delete -n " + ASTERIX_INSTANCE_NAME;
+            cmdHandler.processCommand(command.split(" "));
+        }
+        instance = ServiceProvider.INSTANCE.getLookupService().getAsterixInstance(ASTERIX_INSTANCE_NAME);
+        assert (instance == null);
+    }
+
+    public static String getManagixHome() {
+        return managixHome;
+    }
+
+    public static void installLibrary(String libraryName, String libraryDataverse, String libraryPath) throws Exception {
+        transformIntoRequiredState(State.INACTIVE);
+        String command = "install -n " + ASTERIX_INSTANCE_NAME + " -d " + libraryDataverse + " -l " + libraryName
+                + " -p " + libraryPath;
+        cmdHandler.processCommand(command.split(" "));
+    }
+
+    public static void uninstallLibrary(String dataverseName, String libraryName) throws Exception {
+        transformIntoRequiredState(State.INACTIVE);
+        String command = "uninstall -n " + ASTERIX_INSTANCE_NAME + " -d " + dataverseName + " -l " + "libraryName";
+        cmdHandler.processCommand(command.split(" "));
+    }
+
+    public static void executeCommand(String command) throws Exception {
+        cmdHandler.processCommand(command.trim().split(" "));
+    }
+
+}
diff --git a/asterix-installer/src/test/java/edu/uci/ics/asterix/installer/test/AsterixLifecycleIT.java b/asterix-installer/src/test/java/edu/uci/ics/asterix/installer/test/AsterixLifecycleIT.java
new file mode 100644
index 0000000..98c6bf0
--- /dev/null
+++ b/asterix-installer/src/test/java/edu/uci/ics/asterix/installer/test/AsterixLifecycleIT.java
@@ -0,0 +1,119 @@
+package edu.uci.ics.asterix.installer.test;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.logging.Logger;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runners.Parameterized.Parameters;
+
+import edu.uci.ics.asterix.installer.command.CommandHandler;
+import edu.uci.ics.asterix.installer.error.VerificationUtil;
+import edu.uci.ics.asterix.installer.model.AsterixInstance;
+import edu.uci.ics.asterix.installer.model.AsterixInstance.State;
+import edu.uci.ics.asterix.installer.model.AsterixRuntimeState;
+import edu.uci.ics.asterix.installer.service.ServiceProvider;
+import edu.uci.ics.asterix.test.aql.TestsUtils;
+import edu.uci.ics.asterix.testframework.context.TestCaseContext;
+
+public class AsterixLifecycleIT {
+
+    private static final int NUM_NC = 1;
+    private static final CommandHandler cmdHandler = new CommandHandler();
+    private static final String PATH_BASE = "src/test/resources/integrationts/lifecycle";
+    private static final String PATH_ACTUAL = "ittest/";
+    private static final Logger LOGGER = Logger.getLogger(AsterixLifecycleIT.class.getName());
+    private static List<TestCaseContext> testCaseCollection;
+
+    @BeforeClass
+    public static void setUp() throws Exception {
+        AsterixInstallerIntegrationUtil.init();
+        TestCaseContext.Builder b = new TestCaseContext.Builder();
+        testCaseCollection = b.build(new File(PATH_BASE));
+    }
+
+    @AfterClass
+    public static void tearDown() throws Exception {
+        AsterixInstallerIntegrationUtil.deinit();
+    }
+
+    @Parameters
+    public static Collection<Object[]> tests() throws Exception {
+        Collection<Object[]> testArgs = new ArrayList<Object[]>();
+        return testArgs;
+    }
+
+    @Test
+    public void testStopActiveInstance() throws Exception {
+        try {
+            AsterixInstallerIntegrationUtil.transformIntoRequiredState(State.ACTIVE);
+            String command = "stop -n " + AsterixInstallerIntegrationUtil.ASTERIX_INSTANCE_NAME;
+            cmdHandler.processCommand(command.split(" "));
+            AsterixInstance instance = ServiceProvider.INSTANCE.getLookupService().getAsterixInstance(
+                    AsterixInstallerIntegrationUtil.ASTERIX_INSTANCE_NAME);
+            AsterixRuntimeState state = VerificationUtil.getAsterixRuntimeState(instance);
+            assert (state.getFailedNCs().size() == NUM_NC && !state.isCcRunning());
+            LOGGER.info("Test stop active instance PASSED");
+        } catch (Exception e) {
+            throw new Exception("Test configure installer " + "\" FAILED!", e);
+        }
+    }
+
+    @Test
+    public void testStartActiveInstance() throws Exception {
+        try {
+            AsterixInstallerIntegrationUtil.transformIntoRequiredState(State.INACTIVE);
+            String command = "start -n " + AsterixInstallerIntegrationUtil.ASTERIX_INSTANCE_NAME;
+            cmdHandler.processCommand(command.split(" "));
+            AsterixInstance instance = ServiceProvider.INSTANCE.getLookupService().getAsterixInstance(
+                    AsterixInstallerIntegrationUtil.ASTERIX_INSTANCE_NAME);
+            AsterixRuntimeState state = VerificationUtil.getAsterixRuntimeState(instance);
+            assert (state.getFailedNCs().size() == 0 && state.isCcRunning());
+            LOGGER.info("Test start active instance PASSED");
+        } catch (Exception e) {
+            throw new Exception("Test configure installer " + "\" FAILED!", e);
+        }
+    }
+
+    @Test
+    public void testDeleteActiveInstance() throws Exception {
+        try {
+            AsterixInstallerIntegrationUtil.transformIntoRequiredState(State.INACTIVE);
+            String command = "delete -n " + AsterixInstallerIntegrationUtil.ASTERIX_INSTANCE_NAME;
+            cmdHandler.processCommand(command.split(" "));
+            AsterixInstance instance = ServiceProvider.INSTANCE.getLookupService().getAsterixInstance(
+                    AsterixInstallerIntegrationUtil.ASTERIX_INSTANCE_NAME);
+            assert (instance == null);
+            LOGGER.info("Test delete active instance PASSED");
+        } catch (Exception e) {
+            throw new Exception("Test delete active instance " + "\" FAILED!", e);
+        } finally {
+            // recreate instance
+            AsterixInstallerIntegrationUtil.createInstance();
+        }
+    }
+
+    @Test
+    public void test() throws Exception {
+        for (TestCaseContext testCaseCtx : testCaseCollection) {
+            TestsUtils.executeTest(PATH_ACTUAL, testCaseCtx);
+        }
+    }
+
+    public static void main(String[] args) throws Exception {
+        try {
+            setUp();
+            new AsterixLifecycleIT().test();
+        } catch (Exception e) {
+            e.printStackTrace();
+            LOGGER.info("TEST CASE(S) FAILED");
+        } finally {
+            tearDown();
+        }
+    }
+
+}
diff --git a/asterix-installer/src/test/resources/integrationts/lifecycle/queries/asterix-lifecycle/backupRestore/backupRestore.1.ddl.aql b/asterix-installer/src/test/resources/integrationts/lifecycle/queries/asterix-lifecycle/backupRestore/backupRestore.1.ddl.aql
new file mode 100644
index 0000000..87b762b
--- /dev/null
+++ b/asterix-installer/src/test/resources/integrationts/lifecycle/queries/asterix-lifecycle/backupRestore/backupRestore.1.ddl.aql
@@ -0,0 +1 @@
+create dataverse backupDataverse;
diff --git a/asterix-installer/src/test/resources/integrationts/lifecycle/queries/asterix-lifecycle/backupRestore/backupRestore.2.mgx.aql b/asterix-installer/src/test/resources/integrationts/lifecycle/queries/asterix-lifecycle/backupRestore/backupRestore.2.mgx.aql
new file mode 100644
index 0000000..2d8a23e
--- /dev/null
+++ b/asterix-installer/src/test/resources/integrationts/lifecycle/queries/asterix-lifecycle/backupRestore/backupRestore.2.mgx.aql
@@ -0,0 +1 @@
+stop -n asterix
diff --git a/asterix-installer/src/test/resources/integrationts/lifecycle/queries/asterix-lifecycle/backupRestore/backupRestore.3.mgx.aql b/asterix-installer/src/test/resources/integrationts/lifecycle/queries/asterix-lifecycle/backupRestore/backupRestore.3.mgx.aql
new file mode 100644
index 0000000..baf9551
--- /dev/null
+++ b/asterix-installer/src/test/resources/integrationts/lifecycle/queries/asterix-lifecycle/backupRestore/backupRestore.3.mgx.aql
@@ -0,0 +1 @@
+backup -n asterix
diff --git a/asterix-installer/src/test/resources/integrationts/lifecycle/queries/asterix-lifecycle/backupRestore/backupRestore.4.mgx.aql b/asterix-installer/src/test/resources/integrationts/lifecycle/queries/asterix-lifecycle/backupRestore/backupRestore.4.mgx.aql
new file mode 100644
index 0000000..4e99f33
--- /dev/null
+++ b/asterix-installer/src/test/resources/integrationts/lifecycle/queries/asterix-lifecycle/backupRestore/backupRestore.4.mgx.aql
@@ -0,0 +1 @@
+start -n asterix
diff --git a/asterix-installer/src/test/resources/integrationts/lifecycle/queries/asterix-lifecycle/backupRestore/backupRestore.5.ddl.aql b/asterix-installer/src/test/resources/integrationts/lifecycle/queries/asterix-lifecycle/backupRestore/backupRestore.5.ddl.aql
new file mode 100644
index 0000000..3b6f51b
--- /dev/null
+++ b/asterix-installer/src/test/resources/integrationts/lifecycle/queries/asterix-lifecycle/backupRestore/backupRestore.5.ddl.aql
@@ -0,0 +1,2 @@
+drop dataverse backupDataverse;
+
diff --git a/asterix-installer/src/test/resources/integrationts/lifecycle/queries/asterix-lifecycle/backupRestore/backupRestore.6.mgx.aql b/asterix-installer/src/test/resources/integrationts/lifecycle/queries/asterix-lifecycle/backupRestore/backupRestore.6.mgx.aql
new file mode 100644
index 0000000..2d8a23e
--- /dev/null
+++ b/asterix-installer/src/test/resources/integrationts/lifecycle/queries/asterix-lifecycle/backupRestore/backupRestore.6.mgx.aql
@@ -0,0 +1 @@
+stop -n asterix
diff --git a/asterix-installer/src/test/resources/integrationts/lifecycle/queries/asterix-lifecycle/backupRestore/backupRestore.7.mgx.aql b/asterix-installer/src/test/resources/integrationts/lifecycle/queries/asterix-lifecycle/backupRestore/backupRestore.7.mgx.aql
new file mode 100644
index 0000000..063616b
--- /dev/null
+++ b/asterix-installer/src/test/resources/integrationts/lifecycle/queries/asterix-lifecycle/backupRestore/backupRestore.7.mgx.aql
@@ -0,0 +1 @@
+restore -n asterix -b 0
diff --git a/asterix-installer/src/test/resources/integrationts/lifecycle/queries/asterix-lifecycle/backupRestore/backupRestore.8.mgx.aql b/asterix-installer/src/test/resources/integrationts/lifecycle/queries/asterix-lifecycle/backupRestore/backupRestore.8.mgx.aql
new file mode 100644
index 0000000..4e99f33
--- /dev/null
+++ b/asterix-installer/src/test/resources/integrationts/lifecycle/queries/asterix-lifecycle/backupRestore/backupRestore.8.mgx.aql
@@ -0,0 +1 @@
+start -n asterix
diff --git a/asterix-installer/src/test/resources/integrationts/lifecycle/queries/asterix-lifecycle/backupRestore/backupRestore.9.query.aql b/asterix-installer/src/test/resources/integrationts/lifecycle/queries/asterix-lifecycle/backupRestore/backupRestore.9.query.aql
new file mode 100644
index 0000000..4833c1b
--- /dev/null
+++ b/asterix-installer/src/test/resources/integrationts/lifecycle/queries/asterix-lifecycle/backupRestore/backupRestore.9.query.aql
@@ -0,0 +1,3 @@
+for $x in dataset Metadata.Dataverse
+where $x.DataverseName='backupDataverse'
+return $x
diff --git a/asterix-installer/src/test/resources/integrationts/lifecycle/results/asterix-lifecycle/backupRestore/backupRestore.1.adm b/asterix-installer/src/test/resources/integrationts/lifecycle/results/asterix-lifecycle/backupRestore/backupRestore.1.adm
new file mode 100644
index 0000000..722abfd
--- /dev/null
+++ b/asterix-installer/src/test/resources/integrationts/lifecycle/results/asterix-lifecycle/backupRestore/backupRestore.1.adm
@@ -0,0 +1 @@
+{ "DataverseName": "backupDataverse", "DataFormat": "edu.uci.ics.asterix.runtime.formats.NonTaggedDataFormat", "Timestamp": "Wed Apr 24 16:13:46 PDT 2013", "PendingOp": 0 }
diff --git a/asterix-installer/src/test/resources/integrationts/lifecycle/testsuite.xml b/asterix-installer/src/test/resources/integrationts/lifecycle/testsuite.xml
new file mode 100644
index 0000000..48f548f
--- /dev/null
+++ b/asterix-installer/src/test/resources/integrationts/lifecycle/testsuite.xml
@@ -0,0 +1,10 @@
+<test-suite xmlns="urn:xml.testframework.asterix.ics.uci.edu" ResultOffsetPath="results" QueryOffsetPath="queries" QueryFileExtension=".aql">
+  <test-group name="lifecycle">
+    <test-case FilePath="asterix-lifecycle">
+      <compilation-unit name="backupRestore">
+        <output-dir compare="Text">backupRestore</output-dir>
+      </compilation-unit>
+    </test-case>
+  </test-group>
+</test-suite>
+
diff --git a/asterix-maven-plugins/lexer-generator-maven-plugin/pom.xml b/asterix-maven-plugins/lexer-generator-maven-plugin/pom.xml
index 624c8d3..6b444e8 100644
--- a/asterix-maven-plugins/lexer-generator-maven-plugin/pom.xml
+++ b/asterix-maven-plugins/lexer-generator-maven-plugin/pom.xml
@@ -5,7 +5,7 @@
 	<parent>
 		<artifactId>asterix-maven-plugins</artifactId>
 		<groupId>edu.uci.ics.asterix</groupId>
-		<version>0.0.5-SNAPSHOT</version>
+		<version>0.0.6-SNAPSHOT</version>
 	</parent>
 
   <packaging>maven-plugin</packaging>
diff --git a/asterix-maven-plugins/pom.xml b/asterix-maven-plugins/pom.xml
index f460970..d71f2e9 100644
--- a/asterix-maven-plugins/pom.xml
+++ b/asterix-maven-plugins/pom.xml
@@ -6,7 +6,7 @@
 	<parent>
 		<artifactId>asterix</artifactId>
 		<groupId>edu.uci.ics.asterix</groupId>
-		<version>0.0.5-SNAPSHOT</version>
+		<version>0.0.6-SNAPSHOT</version>
 	</parent>
 
   <dependencies>
diff --git a/asterix-metadata/pom.xml b/asterix-metadata/pom.xml
index ca3f342..425e8ff 100644
--- a/asterix-metadata/pom.xml
+++ b/asterix-metadata/pom.xml
@@ -3,7 +3,7 @@
 	<parent>
 		<artifactId>asterix</artifactId>
 		<groupId>edu.uci.ics.asterix</groupId>
-		<version>0.0.5-SNAPSHOT</version>
+		<version>0.0.6-SNAPSHOT</version>
 	</parent>
 	<artifactId>asterix-metadata</artifactId>
 
@@ -26,19 +26,19 @@
 		<dependency>
 			<groupId>edu.uci.ics.asterix</groupId>
 			<artifactId>asterix-common</artifactId>
-			<version>0.0.5-SNAPSHOT</version>
+			<version>0.0.6-SNAPSHOT</version>
 			<scope>compile</scope>
 		</dependency>
 		<dependency>
 			<groupId>edu.uci.ics.asterix</groupId>
 			<artifactId>asterix-om</artifactId>
-			<version>0.0.5-SNAPSHOT</version>
+			<version>0.0.6-SNAPSHOT</version>
 			<scope>compile</scope>
 		</dependency>
 		<dependency>
 			<groupId>edu.uci.ics.asterix</groupId>
 			<artifactId>asterix-external-data</artifactId>
-			<version>0.0.5-SNAPSHOT</version>
+			<version>0.0.6-SNAPSHOT</version>
 			<scope>compile</scope>
 		</dependency>
 		<dependency>
diff --git a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/MetadataManager.java b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/MetadataManager.java
index ad106fe..994262d 100644
--- a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/MetadataManager.java
+++ b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/MetadataManager.java
@@ -544,6 +544,15 @@
             throw new MetadataException(e);
         }
     }
+    
+    @Override
+    public int getMostRecentDatasetId() throws MetadataException {
+        try { 
+            return metadataNode.getMostRecentDatasetId();
+        } catch (RemoteException e) {
+            throw new MetadataException(e);
+        }
+    }
 
     @Override
     public List<Function> getDataverseFunctions(MetadataTransactionContext ctx, String dataverseName)
@@ -601,5 +610,4 @@
     public void releaseReadLatch() {
         metadataLatch.readLock().unlock();
     }
-
 }
\ No newline at end of file
diff --git a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/MetadataNode.java b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/MetadataNode.java
index d9c6ed4..5bdf086 100644
--- a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/MetadataNode.java
+++ b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/MetadataNode.java
@@ -1121,4 +1121,9 @@
             throw new MetadataException(e);
         }
     }
+
+    @Override
+    public int getMostRecentDatasetId() throws MetadataException, RemoteException {
+        return DatasetIdFactory.getMostRecentDatasetId();
+    }
 }
diff --git a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/api/IAsterixStateProxy.java b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/api/IAsterixStateProxy.java
index 5f772c7..d67cd27 100644
--- a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/api/IAsterixStateProxy.java
+++ b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/api/IAsterixStateProxy.java
@@ -19,7 +19,7 @@
 import java.rmi.Remote;
 import java.rmi.RemoteException;
 
-import edu.uci.ics.asterix.metadata.bootstrap.AsterixProperties;
+import edu.uci.ics.asterix.common.config.AsterixProperties;
 
 /**
  * Interface for setting/getting distributed state of Asterix.
diff --git a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/api/IMetadataManager.java b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/api/IMetadataManager.java
index fdf2d60..f11144e 100644
--- a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/api/IMetadataManager.java
+++ b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/api/IMetadataManager.java
@@ -441,9 +441,10 @@
     public List<Function> getDataverseFunctions(MetadataTransactionContext ctx, String dataverseName)
             throws MetadataException;
 
-	
     public void initializeDatasetIdFactory(MetadataTransactionContext ctx) throws MetadataException;
     
+    public int getMostRecentDatasetId() throws MetadataException;
+    
     public void acquireWriteLatch();
 
     public void releaseWriteLatch();
diff --git a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/api/IMetadataNode.java b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/api/IMetadataNode.java
index 836d42f..e0b5e96 100644
--- a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/api/IMetadataNode.java
+++ b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/api/IMetadataNode.java
@@ -473,5 +473,7 @@
     public void addAdapter(JobId jobId, DatasourceAdapter adapter) throws MetadataException, RemoteException;
 
     public void initializeDatasetIdFactory(JobId jobId) throws MetadataException, RemoteException;
+    
+    public int getMostRecentDatasetId() throws MetadataException, RemoteException;
 
 }
diff --git a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/bootstrap/AsterixProperties.java b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/bootstrap/AsterixProperties.java
deleted file mode 100644
index 71a7de3..0000000
--- a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/bootstrap/AsterixProperties.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * Copyright 2009-2010 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.metadata.bootstrap;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Serializable;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Properties;
-
-import edu.uci.ics.asterix.common.config.GlobalConfig;
-import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
-
-/**
- * Holder for Asterix properties values typically set as Java Properties.
- * Intended to live in the AsterixStateProxy so it can be accessed remotely.
- */
-public class AsterixProperties implements Serializable {
-
-    private static final long serialVersionUID = 1L;
-    private static String metadataNodeName;
-    private static Boolean isNewUniverse;
-    private static HashSet<String> nodeNames;
-    private static Map<String, String[]> stores;
-    private static String outputDir;
-
-    public static AsterixProperties INSTANCE = new AsterixProperties();
-
-    private AsterixProperties() {
-        try {
-            initializeProperties();
-        } catch (Exception e) {
-            throw new IllegalStateException(e);
-        }
-    }
-
-    @SuppressWarnings("unchecked")
-    private void initializeProperties() throws AlgebricksException {
-        Properties p = new Properties();
-        String fileName = System.getProperty(GlobalConfig.CONFIG_FILE_PROPERTY);
-        if (fileName == null) {
-            fileName = GlobalConfig.DEFAULT_CONFIG_FILE_NAME;
-        }
-
-        InputStream is = this.getClass().getClassLoader().getResourceAsStream(fileName);
-        if (is == null) {
-            try {
-                fileName = GlobalConfig.DEFAULT_CONFIG_FILE_NAME;
-                is = new FileInputStream(fileName);
-            } catch (FileNotFoundException fnf) {
-                throw new AlgebricksException("Could not find the configuration file " + fileName);
-            }
-        }
-        try {
-            p.load(is);
-            is.close();
-        } catch (IOException e) {
-            throw new AlgebricksException(e);
-        }
-        Enumeration<String> pNames = (Enumeration<String>) p.propertyNames();
-        stores = new HashMap<String, String[]>();
-        boolean newUniverseChosen = false;
-        String pn;
-        String val;
-        while (pNames.hasMoreElements()) {
-            pn = pNames.nextElement();
-            if (pn.equals("MetadataNode")) {
-                val = p.getProperty(pn);
-                metadataNodeName = val;
-            } else if (pn.equals("NewUniverse")) {
-                val = p.getProperty(pn);
-                newUniverseChosen = true;
-                isNewUniverse = Boolean.parseBoolean(val);
-            } else if (pn.equals("OutputDir")) {
-                val = p.getProperty(pn);
-                outputDir = val;
-            } else {
-                String ncName = pn.substring(0, pn.indexOf('.'));
-                val = p.getProperty(pn);
-                String[] folderNames = val.split("\\s*,\\s*");
-                int i = 0;
-                for (String store : folderNames) {
-                    boolean needsStartSep = !store.startsWith(File.separator);
-                    boolean needsEndSep = !store.endsWith(File.separator);
-                    if (needsStartSep && needsEndSep) {
-                        folderNames[i] = File.separator + store + File.separator;
-                    } else if (needsStartSep) {
-                        folderNames[i] = File.separator + store;
-                    } else if (needsEndSep) {
-                        folderNames[i] = store + File.separator;
-                    }
-                    i++;
-                }
-                stores.put(ncName, folderNames);
-                nodeNames = new HashSet<String>();
-                nodeNames.addAll(stores.keySet());
-            }
-        }
-        if (metadataNodeName == null)
-            throw new AlgebricksException("You need to specify the metadata node!");
-        if (!newUniverseChosen)
-            throw new AlgebricksException("You need to specify whether or not you want to start a new universe!");
-    }
-
-    public Boolean isNewUniverse() {
-        return isNewUniverse;
-    }
-
-    public String getMetadataNodeName() {
-        return metadataNodeName;
-    }
-
-    public String getMetadataStore() {
-        return stores.get(metadataNodeName)[0];
-    }
-
-    public Map<String, String[]> getStores() {
-        return stores;
-    }
-
-    public HashSet<String> getNodeNames() {
-        return nodeNames;
-    }
-
-    public String getOutputDir() {
-        return outputDir;
-    }
-}
diff --git a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/bootstrap/AsterixStateProxy.java b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/bootstrap/AsterixStateProxy.java
index 3946fa6..55aaf33 100644
--- a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/bootstrap/AsterixStateProxy.java
+++ b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/bootstrap/AsterixStateProxy.java
@@ -19,6 +19,7 @@
 import java.rmi.server.UnicastRemoteObject;
 import java.util.logging.Logger;
 
+import edu.uci.ics.asterix.common.config.AsterixProperties;
 import edu.uci.ics.asterix.metadata.api.IAsterixStateProxy;
 import edu.uci.ics.asterix.metadata.api.IMetadataNode;
 
diff --git a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/bootstrap/MetadataBootstrap.java b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/bootstrap/MetadataBootstrap.java
index 805a550..d978f8a 100644
--- a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/bootstrap/MetadataBootstrap.java
+++ b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/bootstrap/MetadataBootstrap.java
@@ -23,8 +23,10 @@
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
+import java.util.logging.Level;
 import java.util.logging.Logger;
 
+import edu.uci.ics.asterix.common.config.AsterixProperties;
 import edu.uci.ics.asterix.common.config.DatasetConfig.DatasetType;
 import edu.uci.ics.asterix.common.config.DatasetConfig.IndexType;
 import edu.uci.ics.asterix.common.config.GlobalConfig;
@@ -125,8 +127,8 @@
                 MetadataSecondaryIndexes.DATATYPENAME_ON_DATATYPE_INDEX };
     }
 
-    public static void startUniverse(AsterixProperties asterixProperties, INCApplicationContext ncApplicationContext, boolean isNewUniverse)
-            throws Exception {
+    public static void startUniverse(AsterixProperties asterixProperties, INCApplicationContext ncApplicationContext,
+            boolean isNewUniverse) throws Exception {
         runtimeContext = (AsterixAppRuntimeContext) ncApplicationContext.getApplicationObject();
 
         // Initialize static metadata objects, such as record types and metadata
@@ -152,24 +154,19 @@
         nodeNames = asterixProperties.getNodeNames();
         // nodeStores = asterixProperity.getStores();
 
-        outputDir = asterixProperties.getOutputDir();
-        if (outputDir != null) {
-            (new File(outputDir)).mkdirs();
-        }
-
         indexLifecycleManager = runtimeContext.getIndexLifecycleManager();
         localResourceRepository = runtimeContext.getLocalResourceRepository();
         bufferCache = runtimeContext.getBufferCache();
         fileMapProvider = runtimeContext.getFileMapManager();
         ioManager = ncApplicationContext.getRootContext().getIOManager();
 
-        if (isNewUniverse) {
-            MetadataTransactionContext mdTxnCtx = MetadataManager.INSTANCE.beginTransaction();
-            try {
-                // Begin a transaction against the metadata.
-                // Lock the metadata in X mode.
-                MetadataManager.INSTANCE.lock(mdTxnCtx, LockMode.X);
-
+        MetadataTransactionContext mdTxnCtx = MetadataManager.INSTANCE.beginTransaction();
+        try {
+            // Begin a transaction against the metadata.
+            // Lock the metadata in X mode.
+            MetadataManager.INSTANCE.lock(mdTxnCtx, LockMode.X);
+            
+            if (isNewUniverse) {
                 for (int i = 0; i < primaryIndexes.length; i++) {
                     enlistMetadataDataset(primaryIndexes[i], true);
                 }
@@ -184,23 +181,35 @@
                 insertInitialGroups(mdTxnCtx);
                 insertInitialAdapters(mdTxnCtx);
 
-                MetadataManager.INSTANCE.initializeDatasetIdFactory(mdTxnCtx);
-                MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
-            } catch (Exception e) {
-                MetadataManager.INSTANCE.abortTransaction(mdTxnCtx);
-                throw e;
-            }
-            LOGGER.info("FINISHED CREATING METADATA B-TREES.");
-        } else {
-            for (int i = 0; i < primaryIndexes.length; i++) {
-                enlistMetadataDataset(primaryIndexes[i], false);
-            }
-            for (int i = 0; i < secondaryIndexes.length; i++) {
-                enlistMetadataDataset(secondaryIndexes[i], false);
-            }
-            LOGGER.info("FINISHED ENLISTMENT OF METADATA B-TREES.");
-        }
+                if (LOGGER.isLoggable(Level.INFO)) {
+                    LOGGER.info("Finished creating metadata B-trees.");
+                }
+            } else {
+                for (int i = 0; i < primaryIndexes.length; i++) {
+                    enlistMetadataDataset(primaryIndexes[i], false);
+                }
+                for (int i = 0; i < secondaryIndexes.length; i++) {
+                    enlistMetadataDataset(secondaryIndexes[i], false);
+                }
 
+                if (LOGGER.isLoggable(Level.INFO)) {
+                    LOGGER.info("Finished enlistment of metadata B-trees.");
+                }
+            }
+            
+            //#. initialize datasetIdFactory
+            MetadataManager.INSTANCE.initializeDatasetIdFactory(mdTxnCtx);
+            MetadataManager.INSTANCE.commitTransaction(mdTxnCtx);
+        } catch (Exception e) {
+            try {
+                MetadataManager.INSTANCE.abortTransaction(mdTxnCtx);
+            } catch (Exception e2) {
+                e.addSuppressed(e2);
+                //TODO
+                //change the exception type to AbortFailureException
+                throw new MetadataException(e);
+            }
+        }
     }
 
     public static void stopUniverse() throws HyracksDataException {
@@ -233,7 +242,8 @@
                     primaryIndexes[i].getNodeGroupName());
             MetadataManager.INSTANCE.addDataset(mdTxnCtx, new Dataset(primaryIndexes[i].getDataverseName(),
                     primaryIndexes[i].getIndexedDatasetName(), primaryIndexes[i].getPayloadRecordType().getTypeName(),
-                    id, new HashMap<String,String>(), DatasetType.INTERNAL, primaryIndexes[i].getDatasetId().getId(), IMetadataEntity.PENDING_NO_OP));
+                    id, new HashMap<String, String>(), DatasetType.INTERNAL, primaryIndexes[i].getDatasetId().getId(),
+                    IMetadataEntity.PENDING_NO_OP));
         }
     }
 
@@ -318,7 +328,7 @@
     }
 
     public static void enlistMetadataDataset(IMetadataIndex index, boolean create) throws Exception {
-        String filePath = metadataStore + index.getFileNameRelativePath();
+        String filePath = metadataStore + File.separator + index.getFileNameRelativePath();
         FileReference file = new FileReference(new File(filePath));
         IInMemoryBufferCache memBufferCache = new InMemoryBufferCache(new HeapBufferAllocator(), DEFAULT_MEM_PAGE_SIZE,
                 DEFAULT_MEM_NUM_PAGES, new TransientFileMapManager());
@@ -331,8 +341,8 @@
         LSMBTree lsmBtree = null;
         long resourceID = -1;
         if (create) {
-            lsmBtree = LSMBTreeUtils.createLSMTree(memBufferCache, memFreePageManager, ioManager, file,
-                    bufferCache, fileMapProvider, typeTraits, comparatorFactories, bloomFilterKeyFields,
+            lsmBtree = LSMBTreeUtils.createLSMTree(memBufferCache, memFreePageManager, ioManager, file, bufferCache,
+                    fileMapProvider, typeTraits, comparatorFactories, bloomFilterKeyFields,
                     runtimeContext.getLSMMergePolicy(), runtimeContext.getLSMBTreeOperationTrackerFactory(),
                     runtimeContext.getLSMIOScheduler(), AsterixRuntimeComponentsProvider.LSMBTREE_PROVIDER);
             lsmBtree.create();
@@ -358,13 +368,11 @@
                 indexLifecycleManager.register(resourceID, lsmBtree);
             }
         }
-        
+
         index.setResourceID(resourceID);
         index.setFile(file);
         indexLifecycleManager.open(resourceID);
     }
-    
-    
 
     public static String getOutputDir() {
         return outputDir;
@@ -381,9 +389,13 @@
         String datasetName = null;
         String indexName = null;
         MetadataTransactionContext mdTxnCtx = null;
-        
+
         MetadataManager.INSTANCE.acquireWriteLatch();
-        
+
+        if (LOGGER.isLoggable(Level.INFO)) {
+            LOGGER.info("Starting DDL recovery ...");
+        }
+
         try {
             mdTxnCtx = MetadataManager.INSTANCE.beginTransaction();
 
@@ -393,6 +405,9 @@
                 if (dataverse.getPendingOp() != IMetadataEntity.PENDING_NO_OP) {
                     //drop pending dataverse
                     MetadataManager.INSTANCE.dropDataverse(mdTxnCtx, dataverseName);
+                    if (LOGGER.isLoggable(Level.INFO)) {
+                        LOGGER.info("Dropped a pending dataverse: " + dataverseName);
+                    }
                 } else {
                     List<Dataset> datasets = MetadataManager.INSTANCE.getDataverseDatasets(mdTxnCtx, dataverseName);
                     for (Dataset dataset : datasets) {
@@ -400,6 +415,9 @@
                         if (dataset.getPendingOp() != IMetadataEntity.PENDING_NO_OP) {
                             //drop pending dataset
                             MetadataManager.INSTANCE.dropDataset(mdTxnCtx, dataverseName, datasetName);
+                            if (LOGGER.isLoggable(Level.INFO)) {
+                                LOGGER.info("Dropped a pending dataset: " + dataverseName + "." + datasetName);
+                            }
                         } else {
                             List<Index> indexes = MetadataManager.INSTANCE.getDatasetIndexes(mdTxnCtx, dataverseName,
                                     datasetName);
@@ -408,14 +426,25 @@
                                 if (index.getPendingOp() != IMetadataEntity.PENDING_NO_OP) {
                                     //drop pending index
                                     MetadataManager.INSTANCE.dropIndex(mdTxnCtx, dataverseName, datasetName, indexName);
+                                    if (LOGGER.isLoggable(Level.INFO)) {
+                                        LOGGER.info("Dropped a pending index: " + dataverseName + "." + datasetName
+                                                + "." + indexName);
+                                    }
                                 }
                             }
                         }
                     }
                 }
             }
+            if (LOGGER.isLoggable(Level.INFO)) {
+                LOGGER.info("Completed DDL recovery.");
+            }
         } catch (Exception e) {
-            MetadataManager.INSTANCE.abortTransaction(mdTxnCtx);
+            try {
+                MetadataManager.INSTANCE.abortTransaction(mdTxnCtx);
+            } catch (Exception e2) {
+                e.addSuppressed(e2);
+            }
             throw new MetadataException(e);
         } finally {
             MetadataManager.INSTANCE.releaseWriteLatch();
diff --git a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/declared/AqlCompiledMetadataDeclarations.java b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/declared/AqlCompiledMetadataDeclarations.java
index 35a9b83..70383f9 100644
--- a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/declared/AqlCompiledMetadataDeclarations.java
+++ b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/declared/AqlCompiledMetadataDeclarations.java
@@ -22,6 +22,7 @@
 import java.util.logging.Logger;
 
 import edu.uci.ics.asterix.common.annotations.TypeDataGen;
+import edu.uci.ics.asterix.common.config.AsterixProperties;
 import edu.uci.ics.asterix.common.config.DatasetConfig.DatasetType;
 import edu.uci.ics.asterix.common.exceptions.AsterixException;
 import edu.uci.ics.asterix.formats.base.IDataFormat;
@@ -29,7 +30,6 @@
 import edu.uci.ics.asterix.metadata.MetadataManager;
 import edu.uci.ics.asterix.metadata.MetadataTransactionContext;
 import edu.uci.ics.asterix.metadata.api.IMetadataManager;
-import edu.uci.ics.asterix.metadata.bootstrap.AsterixProperties;
 import edu.uci.ics.asterix.metadata.entities.Dataset;
 import edu.uci.ics.asterix.metadata.entities.Datatype;
 import edu.uci.ics.asterix.metadata.entities.Dataverse;
diff --git a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/declared/AqlMetadataProvider.java b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/declared/AqlMetadataProvider.java
index 501a8d7..8bbddec 100644
--- a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/declared/AqlMetadataProvider.java
+++ b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/declared/AqlMetadataProvider.java
@@ -23,6 +23,7 @@
 import java.util.Map;
 import java.util.logging.Logger;
 
+import edu.uci.ics.asterix.common.config.AsterixProperties;
 import edu.uci.ics.asterix.common.config.DatasetConfig.DatasetType;
 import edu.uci.ics.asterix.common.config.DatasetConfig.IndexType;
 import edu.uci.ics.asterix.common.config.GlobalConfig;
@@ -47,7 +48,6 @@
 import edu.uci.ics.asterix.metadata.MetadataException;
 import edu.uci.ics.asterix.metadata.MetadataManager;
 import edu.uci.ics.asterix.metadata.MetadataTransactionContext;
-import edu.uci.ics.asterix.metadata.bootstrap.AsterixProperties;
 import edu.uci.ics.asterix.metadata.bootstrap.MetadataConstants;
 import edu.uci.ics.asterix.metadata.dataset.hints.DatasetHints.DatasetCardinalityHint;
 import edu.uci.ics.asterix.metadata.entities.Dataset;
diff --git a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entities/Dataset.java b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entities/Dataset.java
index 91a18f3..070e6ea 100644
--- a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entities/Dataset.java
+++ b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entities/Dataset.java
@@ -40,7 +40,7 @@
     private final Map<String, String> hints;
     private final int datasetId;
     // Type of pending operations with respect to atomic DDL operation
-    private final int pendingOp;
+    private int pendingOp;
 
     public Dataset(String dataverseName, String datasetName, String itemTypeName, IDatasetDetails datasetDetails,
             Map<String, String> hints, DatasetType datasetType, int datasetId, int pendingOp) {
@@ -86,6 +86,10 @@
         return pendingOp;
     }
 
+    public void setPendingOp(int pendingOp) {
+        this.pendingOp = pendingOp;
+    }
+
     @Override
     public Object addToCache(MetadataCache cache) {
         return cache.addDatasetIfNotExists(this);
diff --git a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entities/Index.java b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entities/Index.java
index 6d65730..aa29e5b 100644
--- a/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entities/Index.java
+++ b/asterix-metadata/src/main/java/edu/uci/ics/asterix/metadata/entities/Index.java
@@ -15,7 +15,6 @@
 
 package edu.uci.ics.asterix.metadata.entities;
 
-import java.io.Serializable;
 import java.util.List;
 
 import edu.uci.ics.asterix.common.config.DatasetConfig.IndexType;
@@ -46,7 +45,7 @@
     // Specific to NGRAM indexes.
     private final int gramLength;
     // Type of pending operations with respect to atomic DDL operation
-    private final int pendingOp;
+    private int pendingOp;
 
     public Index(String dataverseName, String datasetName, String indexName, IndexType indexType,
             List<String> keyFieldNames, int gramLength, boolean isPrimaryIndex, int pendingOp) {
@@ -103,6 +102,10 @@
     public int getPendingOp() {
         return pendingOp;
     }
+    
+    public void setPendingOp(int pendingOp) {
+        this.pendingOp = pendingOp;
+    }
 
     public boolean isSecondaryIndex() {
         return !isPrimaryIndex();
diff --git a/asterix-om/pom.xml b/asterix-om/pom.xml
index 276d848..f7ef8d3 100644
--- a/asterix-om/pom.xml
+++ b/asterix-om/pom.xml
@@ -3,7 +3,7 @@
 	<parent>
 		<artifactId>asterix</artifactId>
 		<groupId>edu.uci.ics.asterix</groupId>
-		<version>0.0.5-SNAPSHOT</version>
+		<version>0.0.6-SNAPSHOT</version>
 	</parent>
 	<artifactId>asterix-om</artifactId>
 
@@ -26,7 +26,7 @@
 		<dependency>
 			<groupId>edu.uci.ics.asterix</groupId>
 			<artifactId>asterix-common</artifactId>
-			<version>0.0.5-SNAPSHOT</version>
+			<version>0.0.6-SNAPSHOT</version>
 			<scope>compile</scope>
 		</dependency>
 		<dependency>
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/ARectanglePrinter.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/ARectanglePrinter.java
index 0618f28..f83118b 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/ARectanglePrinter.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/printers/ARectanglePrinter.java
@@ -17,9 +17,14 @@
 
     @Override
     public void print(byte[] b, int s, int l, PrintStream ps) throws AlgebricksException {
-        ps.print("rectangle(\"" + ADoubleSerializerDeserializer.getDouble(b, s + 1) + ",");
+        ps.print("rectangle(\"");
+        ps.print(ADoubleSerializerDeserializer.getDouble(b, s + 1));
+        ps.print(",");
         ps.print(ADoubleSerializerDeserializer.getDouble(b, s + 9));
-        ps.print(" | " + ADoubleSerializerDeserializer.getDouble(b, s + 17) + ",");
-        ps.print(ADoubleSerializerDeserializer.getDouble(b, s + 25) + "\")");
+        ps.print(" ");
+        ps.print(ADoubleSerializerDeserializer.getDouble(b, s + 17));
+        ps.print(",");
+        ps.print(ADoubleSerializerDeserializer.getDouble(b, s + 25));
+        ps.print("\")");
     }
 }
\ No newline at end of file
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/AObjectSerializerDeserializer.java b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/AObjectSerializerDeserializer.java
index b5b7303..2e4f72c 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/AObjectSerializerDeserializer.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/dataflow/data/nontagged/serde/AObjectSerializerDeserializer.java
@@ -23,6 +23,7 @@
 import edu.uci.ics.asterix.om.base.APoint3D;
 import edu.uci.ics.asterix.om.base.APolygon;
 import edu.uci.ics.asterix.om.base.ARecord;
+import edu.uci.ics.asterix.om.base.ARectangle;
 import edu.uci.ics.asterix.om.base.AString;
 import edu.uci.ics.asterix.om.base.ATime;
 import edu.uci.ics.asterix.om.base.AUnorderedList;
@@ -97,6 +98,9 @@
             case LINE: {
                 return ALineSerializerDeserializer.INSTANCE.deserialize(in);
             }
+            case RECTANGLE: {
+                return ARectangleSerializerDeserializer.INSTANCE.deserialize(in);
+            }
             case POLYGON: {
                 return APolygonSerializerDeserializer.INSTANCE.deserialize(in);
             }
@@ -199,6 +203,10 @@
                 ALineSerializerDeserializer.INSTANCE.serialize((ALine) instance, out);
                 break;
             }
+            case RECTANGLE: {
+                ARectangleSerializerDeserializer.INSTANCE.serialize((ARectangle) instance, out);
+                break;
+            }
             case POLYGON: {
                 APolygonSerializerDeserializer.INSTANCE.serialize((APolygon) instance, out);
                 break;
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/functions/AsterixBuiltinFunctions.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/functions/AsterixBuiltinFunctions.java
index fa3179a..3cad3be 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/functions/AsterixBuiltinFunctions.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/functions/AsterixBuiltinFunctions.java
@@ -414,6 +414,24 @@
             "current-date", 0);
     public final static FunctionIdentifier CURRENT_DATETIME = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
             "current-datetime", 0);
+    public final static FunctionIdentifier DURATION_EQUAL = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
+            "duration-equal", 2);
+    public final static FunctionIdentifier YEAR_MONTH_DURATION_GREATER_THAN = new FunctionIdentifier(
+            FunctionConstants.ASTERIX_NS, "year-month-duration-greater-than", 2);
+    public final static FunctionIdentifier YEAR_MONTH_DURATION_LESS_THAN = new FunctionIdentifier(
+            FunctionConstants.ASTERIX_NS, "year-month-duration-less-than", 2);
+    public final static FunctionIdentifier DAY_TIME_DURATION_GREATER_THAN = new FunctionIdentifier(
+            FunctionConstants.ASTERIX_NS, "day-time-duration-greater-than", 2);
+    public final static FunctionIdentifier DAY_TIME_DURATION_LESS_THAN = new FunctionIdentifier(
+            FunctionConstants.ASTERIX_NS, "day-time-duration-less-than", 2);
+    public final static FunctionIdentifier DURATION_FROM_MONTHS = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
+            "duration-from-months", 1);
+    public final static FunctionIdentifier MONTHS_OF_YEAR_MONTH_DURATION = new FunctionIdentifier(
+            FunctionConstants.ASTERIX_NS, "months-of-year-month-duration", 1);
+    public final static FunctionIdentifier DURATION_FROM_MILLISECONDS = new FunctionIdentifier(
+            FunctionConstants.ASTERIX_NS, "duration-from-ms", 1);
+    public final static FunctionIdentifier MILLISECONDS_OF_DAY_TIME_DURATION = new FunctionIdentifier(
+            FunctionConstants.ASTERIX_NS, "ms-of-day-time-duration", 1);
 
     // spatial
     public final static FunctionIdentifier CREATE_POINT = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
@@ -815,6 +833,15 @@
         add(CURRENT_DATE, ADateTypeComputer.INSTANCE);
         add(CURRENT_TIME, ATimeTypeComputer.INSTANCE);
         add(CURRENT_DATETIME, ADateTimeTypeComputer.INSTANCE);
+        add(DAY_TIME_DURATION_GREATER_THAN, OptionalABooleanTypeComputer.INSTANCE);
+        add(DAY_TIME_DURATION_LESS_THAN, OptionalABooleanTypeComputer.INSTANCE);
+        add(YEAR_MONTH_DURATION_GREATER_THAN, OptionalABooleanTypeComputer.INSTANCE);
+        add(YEAR_MONTH_DURATION_LESS_THAN, OptionalABooleanTypeComputer.INSTANCE);
+        add(DURATION_EQUAL, OptionalABooleanTypeComputer.INSTANCE);
+        add(DURATION_FROM_MONTHS, OptionalADurationTypeComputer.INSTANCE);
+        add(DURATION_FROM_MILLISECONDS, OptionalADurationTypeComputer.INSTANCE);
+        add(MONTHS_OF_YEAR_MONTH_DURATION, OptionalAInt32TypeComputer.INSTANCE);
+        add(MILLISECONDS_OF_DAY_TIME_DURATION, OptionalAInt64TypeComputer.INSTANCE);
 
         // interval constructors
         add(INTERVAL_CONSTRUCTOR_DATE, OptionalAIntervalTypeComputer.INSTANCE);
diff --git a/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/ARecordType.java b/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/ARecordType.java
index dc0afcd..ca7bc24 100644
--- a/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/ARecordType.java
+++ b/asterix-om/src/main/java/edu/uci/ics/asterix/om/types/ARecordType.java
@@ -27,9 +27,11 @@
 import org.json.JSONObject;
 
 import edu.uci.ics.asterix.common.annotations.IRecordTypeAnnotation;
+import edu.uci.ics.asterix.common.config.DatasetConfig.IndexType;
 import edu.uci.ics.asterix.common.exceptions.AsterixException;
 import edu.uci.ics.asterix.om.base.IAObject;
 import edu.uci.ics.asterix.om.visitors.IOMVisitor;
+import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
 import edu.uci.ics.hyracks.api.dataflow.value.IBinaryComparator;
 import edu.uci.ics.hyracks.api.dataflow.value.IBinaryHashFunction;
 import edu.uci.ics.hyracks.data.std.accessors.PointableBinaryComparatorFactory;
@@ -232,12 +234,151 @@
      *            the name of the field to check
      * @return true if fieldName is a closed field, otherwise false
      * @throws IOException
-     *             if an error occurs while serializing fieldName
      */
     public boolean isClosedField(String fieldName) throws IOException {
         return findFieldPosition(fieldName) != -1;
     }
 
+    /**
+     * Validates the partitioning expression that will be used to partition a dataset.
+     * 
+     * @param partitioningExprs
+     *            a list of partitioning expressions that will be validated
+     * @throws AlgebricksException
+     *             (if the validation failed), IOException
+     */
+    public void validatePartitioningExpressions(List<String> partitioningExprs) throws AlgebricksException, IOException {
+        for (String fieldName : partitioningExprs) {
+            IAType fieldType = getFieldType(fieldName);
+            if (fieldType == null) {
+                throw new AlgebricksException("A field with this name  \"" + fieldName + "\" could not be found.");
+            }
+            switch (fieldType.getTypeTag()) {
+                case INT32:
+                case INT64:
+                case FLOAT:
+                case DOUBLE:
+                case STRING:
+                    break;
+                case UNION:
+                    throw new AlgebricksException("The partitioning key \"" + fieldName + "\" cannot be nullable");
+                default:
+                    throw new AlgebricksException("The partitioning key \"" + fieldName + "\" cannot be of type "
+                            + fieldType.getTypeTag() + ".");
+            }
+        }
+    }
+
+    /**
+     * Validates the key fields that will be used as keys of an index.
+     * 
+     * @param keyFieldNames
+     *            a list of key fields that will be validated
+     * @param indexType
+     *            the type of the index that its key fields is being validated
+     * @throws AlgebricksException
+     *             (if the validation failed), IOException
+     */
+    public void validateKeyFields(List<String> keyFieldNames, IndexType indexType) throws AlgebricksException,
+            IOException {
+        for (String fieldName : keyFieldNames) {
+            IAType fieldType = getFieldType(fieldName);
+            if (fieldType == null) {
+                throw new AlgebricksException("A field with this name  \"" + fieldName + "\" could not be found.");
+            }
+            switch (indexType) {
+                case BTREE:
+                    switch (fieldType.getTypeTag()) {
+                        case INT8:
+                        case INT16:
+                        case INT32:
+                        case INT64:
+                        case FLOAT:
+                        case DOUBLE:
+                        case STRING:
+                        case DATE:
+                        case TIME:
+                        case DATETIME:
+                        case UNION:
+                            break;
+                        default:
+                            throw new AlgebricksException("The field \"" + fieldName + "\" which is of type "
+                                    + fieldType.getTypeTag() + " cannot be indexed using the BTree index.");
+                    }
+                    break;
+                case RTREE:
+                    switch (fieldType.getTypeTag()) {
+                        case POINT:
+                        case LINE:
+                        case RECTANGLE:
+                        case CIRCLE:
+                        case POLYGON:
+                        case UNION:
+                            break;
+                        default:
+                            throw new AlgebricksException("The field \"" + fieldName + "\" which is of type "
+                                    + fieldType.getTypeTag() + " cannot be indexed using the RTree index.");
+                    }
+                    break;
+                case FUZZY_NGRAM_INVIX:
+                    switch (fieldType.getTypeTag()) {
+                        case STRING:
+                        case UNION:
+                            break;
+                        default:
+                            throw new AlgebricksException("The field \"" + fieldName + "\" which is of type "
+                                    + fieldType.getTypeTag() + " cannot be indexed using the Fuzzy N-Gram index.");
+                    }
+                    break;
+                case FUZZY_WORD_INVIX:
+                    switch (fieldType.getTypeTag()) {
+                        case STRING:
+                        case UNORDEREDLIST:
+                        case ORDEREDLIST:
+                        case UNION:
+                            break;
+                        default:
+                            throw new AlgebricksException("The field \"" + fieldName + "\" which is of type "
+                                    + fieldType.getTypeTag() + " cannot be indexed using the Fuzzy Keyword index.");
+                    }
+                    break;
+                case NGRAM_INVIX:
+                    switch (fieldType.getTypeTag()) {
+                        case STRING:
+                        case UNION:
+                            break;
+                        default:
+                            throw new AlgebricksException("The field \"" + fieldName + "\" which is of type "
+                                    + fieldType.getTypeTag() + " cannot be indexed using the N-Gram index.");
+                    }
+                    break;
+                case WORD_INVIX:
+                    switch (fieldType.getTypeTag()) {
+                        case STRING:
+                        case UNORDEREDLIST:
+                        case ORDEREDLIST:
+                        case UNION:
+                            break;
+                        default:
+                            throw new AlgebricksException("The field \"" + fieldName + "\" which is of type "
+                                    + fieldType.getTypeTag() + " cannot be indexed using the Keyword index.");
+                    }
+                    break;
+                default:
+                    throw new AlgebricksException("Invalid index type: " + indexType + ".");
+            }
+        }
+    }
+
+    public boolean doesFieldExist(String fieldName) {
+        for (String f : fieldNames) {
+            if (f.compareTo(fieldName) == 0) {
+                return true;
+            }
+        }
+        return false;
+    }
+
     @Override
     public String getDisplayName() {
         return "ARecord";
@@ -274,6 +415,7 @@
         }
         return h;
     }
+
     @Override
     public JSONObject toJSON() throws JSONException {
         JSONObject type = new JSONObject();
diff --git a/asterix-runtime/pom.xml b/asterix-runtime/pom.xml
index 3e03a32..74a1f27 100644
--- a/asterix-runtime/pom.xml
+++ b/asterix-runtime/pom.xml
@@ -3,7 +3,7 @@
 	<parent>
 		<artifactId>asterix</artifactId>
 		<groupId>edu.uci.ics.asterix</groupId>
-		<version>0.0.5-SNAPSHOT</version>
+		<version>0.0.6-SNAPSHOT</version>
 	</parent>
 	<artifactId>asterix-runtime</artifactId>
 
@@ -23,7 +23,7 @@
 	      	<plugin>
 	        	<groupId>edu.uci.ics.asterix</groupId>
 	        	<artifactId>lexer-generator-maven-plugin</artifactId>
-	        	<version>0.0.5-SNAPSHOT</version>
+	        	<version>0.0.6-SNAPSHOT</version>
 	        	<configuration>
 	        	  	<grammarFile>src/main/resources/adm.grammar</grammarFile>
 	        	  	<outputDir>${project.build.directory}/generated-sources/edu/uci/ics/asterix/runtime/operators/file/adm</outputDir>
@@ -119,7 +119,7 @@
 		<dependency>
 			<groupId>edu.uci.ics.asterix</groupId>
 			<artifactId>asterix-om</artifactId>
-			<version>0.0.5-SNAPSHOT</version>
+			<version>0.0.6-SNAPSHOT</version>
 			<scope>compile</scope>
 		</dependency>
 		<dependency>
@@ -135,7 +135,7 @@
 		<dependency>
 			<groupId>edu.uci.ics.asterix</groupId>
 			<artifactId>asterix-transactions</artifactId>
-			<version>0.0.5-SNAPSHOT</version>
+			<version>0.0.6-SNAPSHOT</version>
 			<scope>compile</scope>
 		</dependency>
 		<dependency>
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/DayTimeDurationComparatorDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/DayTimeDurationComparatorDescriptor.java
new file mode 100644
index 0000000..bb83016
--- /dev/null
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/DayTimeDurationComparatorDescriptor.java
@@ -0,0 +1,149 @@
+/*
+ * Copyright 2009-2013 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.runtime.evaluators.functions.temporal;
+
+import java.io.DataOutput;
+
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADurationSerializerDeserializer;
+import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
+import edu.uci.ics.asterix.om.base.ABoolean;
+import edu.uci.ics.asterix.om.base.ANull;
+import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
+import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
+import edu.uci.ics.asterix.om.functions.IFunctionDescriptorFactory;
+import edu.uci.ics.asterix.om.types.ATypeTag;
+import edu.uci.ics.asterix.om.types.BuiltinType;
+import edu.uci.ics.asterix.om.types.EnumDeserializer;
+import edu.uci.ics.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
+import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
+import edu.uci.ics.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import edu.uci.ics.hyracks.algebricks.runtime.base.ICopyEvaluator;
+import edu.uci.ics.hyracks.algebricks.runtime.base.ICopyEvaluatorFactory;
+import edu.uci.ics.hyracks.api.dataflow.value.ISerializerDeserializer;
+import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
+import edu.uci.ics.hyracks.data.std.api.IDataOutputProvider;
+import edu.uci.ics.hyracks.data.std.util.ArrayBackedValueStorage;
+import edu.uci.ics.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
+
+public class DayTimeDurationComparatorDescriptor extends AbstractScalarFunctionDynamicDescriptor {
+
+    private final static long serialVersionUID = 1L;
+    public final static FunctionIdentifier GREATER_THAN_FID = AsterixBuiltinFunctions.DAY_TIME_DURATION_GREATER_THAN;
+    public final static FunctionIdentifier LESS_THAN_FID = AsterixBuiltinFunctions.DAY_TIME_DURATION_LESS_THAN;
+
+    // allowed input types
+    private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
+    private final static byte SER_DURATION_TYPE_TAG = ATypeTag.DURATION.serialize();
+
+    private final boolean isGreaterThan;
+
+    private DayTimeDurationComparatorDescriptor(boolean isGreaterThan) {
+        this.isGreaterThan = isGreaterThan;
+    }
+
+    public final static IFunctionDescriptorFactory GREATER_THAN_FACTORY = new IFunctionDescriptorFactory() {
+
+        @Override
+        public IFunctionDescriptor createFunctionDescriptor() {
+            return new DayTimeDurationComparatorDescriptor(true);
+        }
+    };
+
+    public final static IFunctionDescriptorFactory LESS_THAN_FACTORY = new IFunctionDescriptorFactory() {
+
+        @Override
+        public IFunctionDescriptor createFunctionDescriptor() {
+            return new DayTimeDurationComparatorDescriptor(false);
+        }
+    };
+
+    @Override
+    public ICopyEvaluatorFactory createEvaluatorFactory(final ICopyEvaluatorFactory[] args) throws AlgebricksException {
+        return new ICopyEvaluatorFactory() {
+
+            private static final long serialVersionUID = 1L;
+
+            @Override
+            public ICopyEvaluator createEvaluator(final IDataOutputProvider output) throws AlgebricksException {
+                return new ICopyEvaluator() {
+
+                    private DataOutput out = output.getDataOutput();
+                    private ArrayBackedValueStorage argOut0 = new ArrayBackedValueStorage();
+                    private ArrayBackedValueStorage argOut1 = new ArrayBackedValueStorage();
+                    private ICopyEvaluator eval0 = args[0].createEvaluator(argOut0);
+                    private ICopyEvaluator eval1 = args[1].createEvaluator(argOut1);
+
+                    // possible output types
+                    @SuppressWarnings("unchecked")
+                    private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
+                            .getSerializerDeserializer(BuiltinType.ANULL);
+                    @SuppressWarnings("unchecked")
+                    private ISerializerDeserializer<ABoolean> boolSerde = AqlSerializerDeserializerProvider.INSTANCE
+                            .getSerializerDeserializer(BuiltinType.ABOOLEAN);
+
+                    @Override
+                    public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
+                        argOut0.reset();
+                        eval0.evaluate(tuple);
+                        argOut1.reset();
+                        eval1.evaluate(tuple);
+
+                        try {
+                            if (argOut0.getByteArray()[0] == SER_NULL_TYPE_TAG
+                                    || argOut1.getByteArray()[0] == SER_NULL_TYPE_TAG) {
+                                nullSerde.serialize(ANull.NULL, out);
+                                return;
+                            }
+
+                            if (argOut0.getByteArray()[0] != SER_DURATION_TYPE_TAG
+                                    || argOut1.getByteArray()[0] != SER_DURATION_TYPE_TAG) {
+                                throw new AlgebricksException(getIdentifier().getName()
+                                        + ": expects type NULL/DURATION, NULL/DURATION but got "
+                                        + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut0.getByteArray()[0])
+                                        + " and "
+                                        + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut1.getByteArray()[0]));
+                            }
+
+                            if ((ADurationSerializerDeserializer.getYearMonth(argOut0.getByteArray(), 1) != 0)
+                                    || (ADurationSerializerDeserializer.getYearMonth(argOut1.getByteArray(), 1) != 0)) {
+                                throw new AlgebricksException(getIdentifier().getName()
+                                        + ": only year-month durations are allowed.");
+                            }
+
+                            if (ADurationSerializerDeserializer.getDayTime(argOut0.getByteArray(), 1) > ADurationSerializerDeserializer
+                                    .getDayTime(argOut1.getByteArray(), 1)) {
+                                boolSerde.serialize(isGreaterThan ? ABoolean.TRUE : ABoolean.FALSE, out);
+                            } else {
+                                boolSerde.serialize(isGreaterThan ? ABoolean.FALSE : ABoolean.TRUE, out);
+                            }
+
+                        } catch (HyracksDataException hex) {
+                            throw new AlgebricksException(hex);
+                        }
+                    }
+                };
+            }
+        };
+    }
+
+    /* (non-Javadoc)
+     * @see edu.uci.ics.asterix.om.functions.AbstractFunctionDescriptor#getIdentifier()
+     */
+    @Override
+    public FunctionIdentifier getIdentifier() {
+        return isGreaterThan ? GREATER_THAN_FID : LESS_THAN_FID;
+    }
+
+}
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/DurationEqualDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/DurationEqualDescriptor.java
new file mode 100644
index 0000000..fceb144
--- /dev/null
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/DurationEqualDescriptor.java
@@ -0,0 +1,130 @@
+/*
+ * Copyright 2009-2013 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.runtime.evaluators.functions.temporal;
+
+import java.io.DataOutput;
+
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADurationSerializerDeserializer;
+import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
+import edu.uci.ics.asterix.om.base.ABoolean;
+import edu.uci.ics.asterix.om.base.ANull;
+import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
+import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
+import edu.uci.ics.asterix.om.functions.IFunctionDescriptorFactory;
+import edu.uci.ics.asterix.om.types.ATypeTag;
+import edu.uci.ics.asterix.om.types.BuiltinType;
+import edu.uci.ics.asterix.om.types.EnumDeserializer;
+import edu.uci.ics.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
+import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
+import edu.uci.ics.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import edu.uci.ics.hyracks.algebricks.runtime.base.ICopyEvaluator;
+import edu.uci.ics.hyracks.algebricks.runtime.base.ICopyEvaluatorFactory;
+import edu.uci.ics.hyracks.api.dataflow.value.ISerializerDeserializer;
+import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
+import edu.uci.ics.hyracks.data.std.api.IDataOutputProvider;
+import edu.uci.ics.hyracks.data.std.util.ArrayBackedValueStorage;
+import edu.uci.ics.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
+
+public class DurationEqualDescriptor extends AbstractScalarFunctionDynamicDescriptor {
+
+    private final static long serialVersionUID = 1L;
+    public final static FunctionIdentifier FID = AsterixBuiltinFunctions.DURATION_EQUAL;
+
+    // allowed input types
+    private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
+    private final static byte SER_DURATION_TYPE_TAG = ATypeTag.DURATION.serialize();
+
+    public final static IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+
+        @Override
+        public IFunctionDescriptor createFunctionDescriptor() {
+            return new DurationEqualDescriptor();
+        }
+    };
+
+    @Override
+    public ICopyEvaluatorFactory createEvaluatorFactory(final ICopyEvaluatorFactory[] args) throws AlgebricksException {
+        return new ICopyEvaluatorFactory() {
+
+            private static final long serialVersionUID = 1L;
+
+            @Override
+            public ICopyEvaluator createEvaluator(final IDataOutputProvider output) throws AlgebricksException {
+                return new ICopyEvaluator() {
+
+                    private DataOutput out = output.getDataOutput();
+                    private ArrayBackedValueStorage argOut0 = new ArrayBackedValueStorage();
+                    private ArrayBackedValueStorage argOut1 = new ArrayBackedValueStorage();
+                    private ICopyEvaluator eval0 = args[0].createEvaluator(argOut0);
+                    private ICopyEvaluator eval1 = args[1].createEvaluator(argOut1);
+
+                    // possible output types
+                    @SuppressWarnings("unchecked")
+                    private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
+                            .getSerializerDeserializer(BuiltinType.ANULL);
+                    @SuppressWarnings("unchecked")
+                    private ISerializerDeserializer<ABoolean> boolSerde = AqlSerializerDeserializerProvider.INSTANCE
+                            .getSerializerDeserializer(BuiltinType.ABOOLEAN);
+
+                    @Override
+                    public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
+                        argOut0.reset();
+                        eval0.evaluate(tuple);
+                        argOut1.reset();
+                        eval1.evaluate(tuple);
+
+                        try {
+                            if (argOut0.getByteArray()[0] == SER_NULL_TYPE_TAG
+                                    || argOut1.getByteArray()[0] == SER_NULL_TYPE_TAG) {
+                                nullSerde.serialize(ANull.NULL, out);
+                                return;
+                            }
+
+                            if (argOut0.getByteArray()[0] != SER_DURATION_TYPE_TAG
+                                    || argOut1.getByteArray()[0] != SER_DURATION_TYPE_TAG) {
+                                throw new AlgebricksException(FID.getName()
+                                        + ": expects type NULL/DURATION, NULL/DURATION but got "
+                                        + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut0.getByteArray()[0])
+                                        + " and "
+                                        + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut1.getByteArray()[0]));
+                            }
+
+                            if ((ADurationSerializerDeserializer.getDayTime(argOut0.getByteArray(), 1) == ADurationSerializerDeserializer
+                                    .getDayTime(argOut1.getByteArray(), 1))
+                                    && (ADurationSerializerDeserializer.getYearMonth(argOut0.getByteArray(), 1) == ADurationSerializerDeserializer
+                                            .getYearMonth(argOut1.getByteArray(), 1))) {
+                                boolSerde.serialize(ABoolean.TRUE, out);
+                            } else {
+                                boolSerde.serialize(ABoolean.FALSE, out);
+                            }
+
+                        } catch (HyracksDataException hex) {
+                            throw new AlgebricksException(hex);
+                        }
+                    }
+                };
+            }
+        };
+    }
+
+    /* (non-Javadoc)
+     * @see edu.uci.ics.asterix.om.functions.AbstractFunctionDescriptor#getIdentifier()
+     */
+    @Override
+    public FunctionIdentifier getIdentifier() {
+        return FID;
+    }
+
+}
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/DurationFromMillisecondsDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/DurationFromMillisecondsDescriptor.java
new file mode 100644
index 0000000..267f4a7
--- /dev/null
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/DurationFromMillisecondsDescriptor.java
@@ -0,0 +1,133 @@
+/*
+ * Copyright 2009-2013 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.runtime.evaluators.functions.temporal;
+
+import java.io.DataOutput;
+
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AInt16SerializerDeserializer;
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AInt32SerializerDeserializer;
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AInt64SerializerDeserializer;
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AInt8SerializerDeserializer;
+import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
+import edu.uci.ics.asterix.om.base.ADuration;
+import edu.uci.ics.asterix.om.base.AMutableDuration;
+import edu.uci.ics.asterix.om.base.ANull;
+import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
+import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
+import edu.uci.ics.asterix.om.functions.IFunctionDescriptorFactory;
+import edu.uci.ics.asterix.om.types.ATypeTag;
+import edu.uci.ics.asterix.om.types.BuiltinType;
+import edu.uci.ics.asterix.om.types.EnumDeserializer;
+import edu.uci.ics.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
+import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
+import edu.uci.ics.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import edu.uci.ics.hyracks.algebricks.runtime.base.ICopyEvaluator;
+import edu.uci.ics.hyracks.algebricks.runtime.base.ICopyEvaluatorFactory;
+import edu.uci.ics.hyracks.api.dataflow.value.ISerializerDeserializer;
+import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
+import edu.uci.ics.hyracks.data.std.api.IDataOutputProvider;
+import edu.uci.ics.hyracks.data.std.util.ArrayBackedValueStorage;
+import edu.uci.ics.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
+
+public class DurationFromMillisecondsDescriptor extends AbstractScalarFunctionDynamicDescriptor {
+
+    private final static long serialVersionUID = 1L;
+    public final static FunctionIdentifier FID = AsterixBuiltinFunctions.DURATION_FROM_MILLISECONDS;
+
+    // allowed input types
+    private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
+    private final static byte SER_INT8_TYPE_TAG = ATypeTag.INT8.serialize();
+    private final static byte SER_INT16_TYPE_TAG = ATypeTag.INT16.serialize();
+    private final static byte SER_INT32_TYPE_TAG = ATypeTag.INT32.serialize();
+    private final static byte SER_INT64_TYPE_TAG = ATypeTag.INT64.serialize();
+
+    public final static IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+
+        @Override
+        public IFunctionDescriptor createFunctionDescriptor() {
+            return new DurationFromMillisecondsDescriptor();
+        }
+    };
+
+    @Override
+    public ICopyEvaluatorFactory createEvaluatorFactory(final ICopyEvaluatorFactory[] args) throws AlgebricksException {
+        return new ICopyEvaluatorFactory() {
+
+            private static final long serialVersionUID = 1L;
+
+            @Override
+            public ICopyEvaluator createEvaluator(final IDataOutputProvider output) throws AlgebricksException {
+                return new ICopyEvaluator() {
+
+                    private DataOutput out = output.getDataOutput();
+                    private ArrayBackedValueStorage argOut0 = new ArrayBackedValueStorage();
+                    private ICopyEvaluator eval0 = args[0].createEvaluator(argOut0);
+
+                    // possible output types
+                    @SuppressWarnings("unchecked")
+                    private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
+                            .getSerializerDeserializer(BuiltinType.ANULL);
+                    @SuppressWarnings("unchecked")
+                    private ISerializerDeserializer<ADuration> durationSerde = AqlSerializerDeserializerProvider.INSTANCE
+                            .getSerializerDeserializer(BuiltinType.ADURATION);
+
+                    AMutableDuration aDuration = new AMutableDuration(0, 0);
+
+                    @Override
+                    public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
+                        argOut0.reset();
+                        eval0.evaluate(tuple);
+
+                        try {
+                            if (argOut0.getByteArray()[0] == SER_NULL_TYPE_TAG) {
+                                nullSerde.serialize(ANull.NULL, out);
+                                return;
+                            }
+
+                            if (argOut0.getByteArray()[0] == SER_INT8_TYPE_TAG) {
+                                aDuration.setValue(0, AInt8SerializerDeserializer.getByte(argOut0.getByteArray(), 1));
+                            } else if (argOut0.getByteArray()[0] == SER_INT16_TYPE_TAG) {
+                                aDuration.setValue(0, AInt16SerializerDeserializer.getShort(argOut0.getByteArray(), 1));
+                            } else if (argOut0.getByteArray()[0] == SER_INT32_TYPE_TAG) {
+                                aDuration.setValue(0, AInt32SerializerDeserializer.getInt(argOut0.getByteArray(), 1));
+                            } else if (argOut0.getByteArray()[0] == SER_INT64_TYPE_TAG) {
+                                aDuration.setValue(0, AInt64SerializerDeserializer.getLong(argOut0.getByteArray(), 1));
+                            } else {
+                                throw new AlgebricksException(FID.getName()
+                                        + ": expects NULL/INT8/INT16/INT32/INT64, but got "
+                                        + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut0.getByteArray()[0]));
+                            }
+
+                            durationSerde.serialize(aDuration, out);
+
+                        } catch (HyracksDataException hex) {
+                            throw new AlgebricksException(hex);
+                        }
+                    }
+                };
+            }
+
+        };
+    }
+
+    /* (non-Javadoc)
+     * @see edu.uci.ics.asterix.om.functions.AbstractFunctionDescriptor#getIdentifier()
+     */
+    @Override
+    public FunctionIdentifier getIdentifier() {
+        return FID;
+    }
+
+}
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/DurationFromMonthsDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/DurationFromMonthsDescriptor.java
new file mode 100644
index 0000000..f8b7a3e
--- /dev/null
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/DurationFromMonthsDescriptor.java
@@ -0,0 +1,129 @@
+/*
+ * Copyright 2009-2013 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.runtime.evaluators.functions.temporal;
+
+import java.io.DataOutput;
+
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AInt16SerializerDeserializer;
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AInt32SerializerDeserializer;
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.AInt8SerializerDeserializer;
+import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
+import edu.uci.ics.asterix.om.base.ADuration;
+import edu.uci.ics.asterix.om.base.AMutableDuration;
+import edu.uci.ics.asterix.om.base.ANull;
+import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
+import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
+import edu.uci.ics.asterix.om.functions.IFunctionDescriptorFactory;
+import edu.uci.ics.asterix.om.types.ATypeTag;
+import edu.uci.ics.asterix.om.types.BuiltinType;
+import edu.uci.ics.asterix.om.types.EnumDeserializer;
+import edu.uci.ics.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
+import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
+import edu.uci.ics.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import edu.uci.ics.hyracks.algebricks.runtime.base.ICopyEvaluator;
+import edu.uci.ics.hyracks.algebricks.runtime.base.ICopyEvaluatorFactory;
+import edu.uci.ics.hyracks.api.dataflow.value.ISerializerDeserializer;
+import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
+import edu.uci.ics.hyracks.data.std.api.IDataOutputProvider;
+import edu.uci.ics.hyracks.data.std.util.ArrayBackedValueStorage;
+import edu.uci.ics.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
+
+public class DurationFromMonthsDescriptor extends AbstractScalarFunctionDynamicDescriptor {
+
+    private final static long serialVersionUID = 1L;
+    public final static FunctionIdentifier FID = AsterixBuiltinFunctions.DURATION_FROM_MONTHS;
+
+    // allowed input types
+    private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
+    private final static byte SER_INT8_TYPE_TAG = ATypeTag.INT8.serialize();
+    private final static byte SER_INT16_TYPE_TAG = ATypeTag.INT16.serialize();
+    private final static byte SER_INT32_TYPE_TAG = ATypeTag.INT32.serialize();
+
+    public final static IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+
+        @Override
+        public IFunctionDescriptor createFunctionDescriptor() {
+            return new DurationFromMonthsDescriptor();
+        }
+    };
+
+    @Override
+    public ICopyEvaluatorFactory createEvaluatorFactory(final ICopyEvaluatorFactory[] args) throws AlgebricksException {
+        return new ICopyEvaluatorFactory() {
+
+            private static final long serialVersionUID = 1L;
+
+            @Override
+            public ICopyEvaluator createEvaluator(final IDataOutputProvider output) throws AlgebricksException {
+                return new ICopyEvaluator() {
+
+                    private DataOutput out = output.getDataOutput();
+                    private ArrayBackedValueStorage argOut0 = new ArrayBackedValueStorage();
+                    private ICopyEvaluator eval0 = args[0].createEvaluator(argOut0);
+
+                    // possible output types
+                    @SuppressWarnings("unchecked")
+                    private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
+                            .getSerializerDeserializer(BuiltinType.ANULL);
+                    @SuppressWarnings("unchecked")
+                    private ISerializerDeserializer<ADuration> durationSerde = AqlSerializerDeserializerProvider.INSTANCE
+                            .getSerializerDeserializer(BuiltinType.ADURATION);
+
+                    AMutableDuration aDuration = new AMutableDuration(0, 0);
+
+                    @Override
+                    public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
+                        argOut0.reset();
+                        eval0.evaluate(tuple);
+
+                        try {
+                            if (argOut0.getByteArray()[0] == SER_NULL_TYPE_TAG) {
+                                nullSerde.serialize(ANull.NULL, out);
+                                return;
+                            }
+
+                            if (argOut0.getByteArray()[0] == SER_INT8_TYPE_TAG) {
+                                aDuration.setValue(AInt8SerializerDeserializer.getByte(argOut0.getByteArray(), 1), 0);
+                            } else if (argOut0.getByteArray()[0] == SER_INT16_TYPE_TAG) {
+                                aDuration.setValue(AInt16SerializerDeserializer.getShort(argOut0.getByteArray(), 1), 0);
+                            } else if (argOut0.getByteArray()[0] == SER_INT32_TYPE_TAG) {
+                                aDuration.setValue(AInt32SerializerDeserializer.getInt(argOut0.getByteArray(), 1), 0);
+                            } else {
+                                throw new AlgebricksException(FID.getName()
+                                        + ": expects NULL/INT8/INT16/INT32, but got "
+                                        + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut0.getByteArray()[0]));
+                            }
+
+                            durationSerde.serialize(aDuration, out);
+
+                        } catch (HyracksDataException hex) {
+                            throw new AlgebricksException(hex);
+                        }
+                    }
+                };
+            }
+
+        };
+    }
+
+    /* (non-Javadoc)
+     * @see edu.uci.ics.asterix.om.functions.AbstractFunctionDescriptor#getIdentifier()
+     */
+    @Override
+    public FunctionIdentifier getIdentifier() {
+        return FID;
+    }
+
+}
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/MillisecondsOfDayTimeDurationDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/MillisecondsOfDayTimeDurationDescriptor.java
new file mode 100644
index 0000000..97fa94a
--- /dev/null
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/MillisecondsOfDayTimeDurationDescriptor.java
@@ -0,0 +1,120 @@
+/*
+ * Copyright 2009-2013 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.runtime.evaluators.functions.temporal;
+
+import java.io.DataOutput;
+
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADurationSerializerDeserializer;
+import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
+import edu.uci.ics.asterix.om.base.AInt64;
+import edu.uci.ics.asterix.om.base.AMutableInt64;
+import edu.uci.ics.asterix.om.base.ANull;
+import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
+import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
+import edu.uci.ics.asterix.om.functions.IFunctionDescriptorFactory;
+import edu.uci.ics.asterix.om.types.ATypeTag;
+import edu.uci.ics.asterix.om.types.BuiltinType;
+import edu.uci.ics.asterix.om.types.EnumDeserializer;
+import edu.uci.ics.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
+import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
+import edu.uci.ics.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import edu.uci.ics.hyracks.algebricks.runtime.base.ICopyEvaluator;
+import edu.uci.ics.hyracks.algebricks.runtime.base.ICopyEvaluatorFactory;
+import edu.uci.ics.hyracks.api.dataflow.value.ISerializerDeserializer;
+import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
+import edu.uci.ics.hyracks.data.std.api.IDataOutputProvider;
+import edu.uci.ics.hyracks.data.std.util.ArrayBackedValueStorage;
+import edu.uci.ics.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
+
+public class MillisecondsOfDayTimeDurationDescriptor extends AbstractScalarFunctionDynamicDescriptor {
+
+    private final static long serialVersionUID = 1L;
+    public final static FunctionIdentifier FID = AsterixBuiltinFunctions.MILLISECONDS_OF_DAY_TIME_DURATION;
+
+    // allowed input types
+    private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
+    private final static byte SER_DURATION_TYPE_TAG = ATypeTag.DURATION.serialize();
+
+    public final static IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+
+        @Override
+        public IFunctionDescriptor createFunctionDescriptor() {
+            return new MillisecondsOfDayTimeDurationDescriptor();
+        }
+    };
+
+    @Override
+    public ICopyEvaluatorFactory createEvaluatorFactory(final ICopyEvaluatorFactory[] args) throws AlgebricksException {
+        return new ICopyEvaluatorFactory() {
+
+            private static final long serialVersionUID = 1L;
+
+            @Override
+            public ICopyEvaluator createEvaluator(final IDataOutputProvider output) throws AlgebricksException {
+                return new ICopyEvaluator() {
+
+                    private DataOutput out = output.getDataOutput();
+                    private ArrayBackedValueStorage argOut0 = new ArrayBackedValueStorage();
+                    private ICopyEvaluator eval0 = args[0].createEvaluator(argOut0);
+
+                    // possible output types
+                    @SuppressWarnings("unchecked")
+                    private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
+                            .getSerializerDeserializer(BuiltinType.ANULL);
+                    @SuppressWarnings("unchecked")
+                    private ISerializerDeserializer<AInt64> int64Serde = AqlSerializerDeserializerProvider.INSTANCE
+                            .getSerializerDeserializer(BuiltinType.AINT64);
+
+                    AMutableInt64 aInt64 = new AMutableInt64(0);
+
+                    @Override
+                    public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
+                        argOut0.reset();
+                        eval0.evaluate(tuple);
+
+                        try {
+                            if (argOut0.getByteArray()[0] == SER_NULL_TYPE_TAG) {
+                                nullSerde.serialize(ANull.NULL, out);
+                                return;
+                            }
+
+                            if (argOut0.getByteArray()[0] != SER_DURATION_TYPE_TAG) {
+                                throw new AlgebricksException(FID.getName() + ": expects NULL/DURATION, but got "
+                                        + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut0.getByteArray()[0]));
+                            }
+
+                            aInt64.setValue(ADurationSerializerDeserializer.getDayTime(argOut0.getByteArray(), 1));
+
+                            int64Serde.serialize(aInt64, out);
+
+                        } catch (HyracksDataException hex) {
+                            throw new AlgebricksException(hex);
+                        }
+                    }
+                };
+            }
+
+        };
+    }
+
+    /* (non-Javadoc)
+     * @see edu.uci.ics.asterix.om.functions.AbstractFunctionDescriptor#getIdentifier()
+     */
+    @Override
+    public FunctionIdentifier getIdentifier() {
+        return FID;
+    }
+
+}
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/MonthsOfYearMonthDurationDescriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/MonthsOfYearMonthDurationDescriptor.java
new file mode 100644
index 0000000..55173a5
--- /dev/null
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/MonthsOfYearMonthDurationDescriptor.java
@@ -0,0 +1,120 @@
+/*
+ * Copyright 2009-2013 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.runtime.evaluators.functions.temporal;
+
+import java.io.DataOutput;
+
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADurationSerializerDeserializer;
+import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
+import edu.uci.ics.asterix.om.base.AInt32;
+import edu.uci.ics.asterix.om.base.AMutableInt32;
+import edu.uci.ics.asterix.om.base.ANull;
+import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
+import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
+import edu.uci.ics.asterix.om.functions.IFunctionDescriptorFactory;
+import edu.uci.ics.asterix.om.types.ATypeTag;
+import edu.uci.ics.asterix.om.types.BuiltinType;
+import edu.uci.ics.asterix.om.types.EnumDeserializer;
+import edu.uci.ics.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
+import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
+import edu.uci.ics.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import edu.uci.ics.hyracks.algebricks.runtime.base.ICopyEvaluator;
+import edu.uci.ics.hyracks.algebricks.runtime.base.ICopyEvaluatorFactory;
+import edu.uci.ics.hyracks.api.dataflow.value.ISerializerDeserializer;
+import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
+import edu.uci.ics.hyracks.data.std.api.IDataOutputProvider;
+import edu.uci.ics.hyracks.data.std.util.ArrayBackedValueStorage;
+import edu.uci.ics.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
+
+public class MonthsOfYearMonthDurationDescriptor extends AbstractScalarFunctionDynamicDescriptor {
+
+    private final static long serialVersionUID = 1L;
+    public final static FunctionIdentifier FID = AsterixBuiltinFunctions.MONTHS_OF_YEAR_MONTH_DURATION;
+
+    // allowed input types
+    private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
+    private final static byte SER_DURATION_TYPE_TAG = ATypeTag.DURATION.serialize();
+
+    public final static IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+
+        @Override
+        public IFunctionDescriptor createFunctionDescriptor() {
+            return new MonthsOfYearMonthDurationDescriptor();
+        }
+    };
+
+    @Override
+    public ICopyEvaluatorFactory createEvaluatorFactory(final ICopyEvaluatorFactory[] args) throws AlgebricksException {
+        return new ICopyEvaluatorFactory() {
+
+            private static final long serialVersionUID = 1L;
+
+            @Override
+            public ICopyEvaluator createEvaluator(final IDataOutputProvider output) throws AlgebricksException {
+                return new ICopyEvaluator() {
+
+                    private DataOutput out = output.getDataOutput();
+                    private ArrayBackedValueStorage argOut0 = new ArrayBackedValueStorage();
+                    private ICopyEvaluator eval0 = args[0].createEvaluator(argOut0);
+
+                    // possible output types
+                    @SuppressWarnings("unchecked")
+                    private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
+                            .getSerializerDeserializer(BuiltinType.ANULL);
+                    @SuppressWarnings("unchecked")
+                    private ISerializerDeserializer<AInt32> int32Serde = AqlSerializerDeserializerProvider.INSTANCE
+                            .getSerializerDeserializer(BuiltinType.AINT32);
+
+                    AMutableInt32 aInt32 = new AMutableInt32(0);
+
+                    @Override
+                    public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
+                        argOut0.reset();
+                        eval0.evaluate(tuple);
+
+                        try {
+                            if (argOut0.getByteArray()[0] == SER_NULL_TYPE_TAG) {
+                                nullSerde.serialize(ANull.NULL, out);
+                                return;
+                            }
+
+                            if (argOut0.getByteArray()[0] != SER_DURATION_TYPE_TAG) {
+                                throw new AlgebricksException(FID.getName() + ": expects NULL/DURATION, but got "
+                                        + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut0.getByteArray()[0]));
+                            }
+
+                            aInt32.setValue(ADurationSerializerDeserializer.getYearMonth(argOut0.getByteArray(), 1));
+
+                            int32Serde.serialize(aInt32, out);
+
+                        } catch (HyracksDataException hex) {
+                            throw new AlgebricksException(hex);
+                        }
+                    }
+                };
+            }
+
+        };
+    }
+
+    /* (non-Javadoc)
+     * @see edu.uci.ics.asterix.om.functions.AbstractFunctionDescriptor#getIdentifier()
+     */
+    @Override
+    public FunctionIdentifier getIdentifier() {
+        return FID;
+    }
+
+}
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/YearMonthDurationComparatorDecriptor.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/YearMonthDurationComparatorDecriptor.java
new file mode 100644
index 0000000..22ab96c
--- /dev/null
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/evaluators/functions/temporal/YearMonthDurationComparatorDecriptor.java
@@ -0,0 +1,149 @@
+/*
+ * Copyright 2009-2013 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.runtime.evaluators.functions.temporal;
+
+import java.io.DataOutput;
+
+import edu.uci.ics.asterix.dataflow.data.nontagged.serde.ADurationSerializerDeserializer;
+import edu.uci.ics.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
+import edu.uci.ics.asterix.om.base.ABoolean;
+import edu.uci.ics.asterix.om.base.ANull;
+import edu.uci.ics.asterix.om.functions.AsterixBuiltinFunctions;
+import edu.uci.ics.asterix.om.functions.IFunctionDescriptor;
+import edu.uci.ics.asterix.om.functions.IFunctionDescriptorFactory;
+import edu.uci.ics.asterix.om.types.ATypeTag;
+import edu.uci.ics.asterix.om.types.BuiltinType;
+import edu.uci.ics.asterix.om.types.EnumDeserializer;
+import edu.uci.ics.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
+import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException;
+import edu.uci.ics.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
+import edu.uci.ics.hyracks.algebricks.runtime.base.ICopyEvaluator;
+import edu.uci.ics.hyracks.algebricks.runtime.base.ICopyEvaluatorFactory;
+import edu.uci.ics.hyracks.api.dataflow.value.ISerializerDeserializer;
+import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
+import edu.uci.ics.hyracks.data.std.api.IDataOutputProvider;
+import edu.uci.ics.hyracks.data.std.util.ArrayBackedValueStorage;
+import edu.uci.ics.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
+
+public class YearMonthDurationComparatorDecriptor extends AbstractScalarFunctionDynamicDescriptor {
+
+    private final static long serialVersionUID = 1L;
+    public final static FunctionIdentifier GREATER_THAN_FID = AsterixBuiltinFunctions.YEAR_MONTH_DURATION_GREATER_THAN;
+    public final static FunctionIdentifier LESS_THAN_FID = AsterixBuiltinFunctions.YEAR_MONTH_DURATION_LESS_THAN;
+
+    // allowed input types
+    private final static byte SER_NULL_TYPE_TAG = ATypeTag.NULL.serialize();
+    private final static byte SER_DURATION_TYPE_TAG = ATypeTag.DURATION.serialize();
+    
+    private final boolean isGreaterThan;
+
+    private YearMonthDurationComparatorDecriptor(boolean isGreaterThan) {
+        this.isGreaterThan = isGreaterThan;
+    }
+
+    public final static IFunctionDescriptorFactory GREATER_THAN_FACTORY = new IFunctionDescriptorFactory() {
+
+        @Override
+        public IFunctionDescriptor createFunctionDescriptor() {
+            return new YearMonthDurationComparatorDecriptor(true);
+        }
+    };
+
+    public final static IFunctionDescriptorFactory LESS_THAN_FACTORY = new IFunctionDescriptorFactory() {
+
+        @Override
+        public IFunctionDescriptor createFunctionDescriptor() {
+            return new YearMonthDurationComparatorDecriptor(false);
+        }
+    };
+
+    @Override
+    public ICopyEvaluatorFactory createEvaluatorFactory(final ICopyEvaluatorFactory[] args) throws AlgebricksException {
+        return new ICopyEvaluatorFactory() {
+
+            private static final long serialVersionUID = 1L;
+
+            @Override
+            public ICopyEvaluator createEvaluator(final IDataOutputProvider output) throws AlgebricksException {
+                return new ICopyEvaluator() {
+
+                    private DataOutput out = output.getDataOutput();
+                    private ArrayBackedValueStorage argOut0 = new ArrayBackedValueStorage();
+                    private ArrayBackedValueStorage argOut1 = new ArrayBackedValueStorage();
+                    private ICopyEvaluator eval0 = args[0].createEvaluator(argOut0);
+                    private ICopyEvaluator eval1 = args[1].createEvaluator(argOut1);
+
+                    // possible output types
+                    @SuppressWarnings("unchecked")
+                    private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
+                            .getSerializerDeserializer(BuiltinType.ANULL);
+                    @SuppressWarnings("unchecked")
+                    private ISerializerDeserializer<ABoolean> boolSerde = AqlSerializerDeserializerProvider.INSTANCE
+                            .getSerializerDeserializer(BuiltinType.ABOOLEAN);
+
+                    @Override
+                    public void evaluate(IFrameTupleReference tuple) throws AlgebricksException {
+                        argOut0.reset();
+                        eval0.evaluate(tuple);
+                        argOut1.reset();
+                        eval1.evaluate(tuple);
+
+                        try {
+                            if (argOut0.getByteArray()[0] == SER_NULL_TYPE_TAG
+                                    || argOut1.getByteArray()[0] == SER_NULL_TYPE_TAG) {
+                                nullSerde.serialize(ANull.NULL, out);
+                                return;
+                            }
+
+                            if (argOut0.getByteArray()[0] != SER_DURATION_TYPE_TAG
+                                    || argOut1.getByteArray()[0] != SER_DURATION_TYPE_TAG) {
+                                throw new AlgebricksException(getIdentifier().getName()
+                                        + ": expects type NULL/DURATION, NULL/DURATION but got "
+                                        + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut0.getByteArray()[0])
+                                        + " and "
+                                        + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argOut1.getByteArray()[0]));
+                            }
+
+                            if ((ADurationSerializerDeserializer.getDayTime(argOut0.getByteArray(), 1) != 0)
+                                    || (ADurationSerializerDeserializer.getDayTime(argOut1.getByteArray(), 1) != 0)) {
+                                throw new AlgebricksException(getIdentifier().getName()
+                                        + ": only year-month durations are allowed.");
+                            }
+
+                            if (ADurationSerializerDeserializer.getYearMonth(argOut0.getByteArray(), 1) > ADurationSerializerDeserializer
+                                    .getYearMonth(argOut1.getByteArray(), 1)) {
+                                boolSerde.serialize(isGreaterThan ? ABoolean.TRUE : ABoolean.FALSE, out);
+                            } else {
+                                boolSerde.serialize(isGreaterThan ? ABoolean.FALSE : ABoolean.TRUE, out);
+                            }
+
+                        } catch (HyracksDataException hex) {
+                            throw new AlgebricksException(hex);
+                        }
+                    }
+                };
+            }
+        };
+    }
+
+    /* (non-Javadoc)
+     * @see edu.uci.ics.asterix.om.functions.AbstractFunctionDescriptor#getIdentifier()
+     */
+    @Override
+    public FunctionIdentifier getIdentifier() {
+        return isGreaterThan ? GREATER_THAN_FID : LESS_THAN_FID;
+    }
+
+}
diff --git a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/formats/NonTaggedDataFormat.java b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/formats/NonTaggedDataFormat.java
index a61208d..84142be 100644
--- a/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/formats/NonTaggedDataFormat.java
+++ b/asterix-runtime/src/main/java/edu/uci/ics/asterix/runtime/formats/NonTaggedDataFormat.java
@@ -203,6 +203,10 @@
 import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.DateFromUnixTimeInDaysDescriptor;
 import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.DatetimeFromDateAndTimeDescriptor;
 import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.DatetimeFromUnixTimeInMsDescriptor;
+import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.DayTimeDurationComparatorDescriptor;
+import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.DurationEqualDescriptor;
+import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.DurationFromMillisecondsDescriptor;
+import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.DurationFromMonthsDescriptor;
 import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.IntervalAfterDescriptor;
 import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.IntervalBeforeDescriptor;
 import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.IntervalCoveredByDescriptor;
@@ -211,6 +215,8 @@
 import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.IntervalEndsDecriptor;
 import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.IntervalMeetsDescriptor;
 import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.IntervalMetByDescriptor;
+import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.MillisecondsOfDayTimeDurationDescriptor;
+import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.MonthsOfYearMonthDurationDescriptor;
 import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.OverlapDescriptor;
 import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.IntervalOverlappedByDescriptor;
 import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.IntervalOverlapsDescriptor;
@@ -221,6 +227,7 @@
 import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.SubtractTimeDescriptor;
 import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.TimeFromDatetimeDescriptor;
 import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.TimeFromUnixTimeInMsDescriptor;
+import edu.uci.ics.asterix.runtime.evaluators.functions.temporal.YearMonthDurationComparatorDecriptor;
 import edu.uci.ics.asterix.runtime.operators.file.AdmSchemafullRecordParserFactory;
 import edu.uci.ics.asterix.runtime.operators.file.NtDelimitedDataTupleParserFactory;
 import edu.uci.ics.asterix.runtime.runningaggregates.std.TidRunningAggregateDescriptor;
@@ -502,6 +509,15 @@
         temp.add(CurrentDateDescriptor.FACTORY);
         temp.add(CurrentTimeDescriptor.FACTORY);
         temp.add(CurrentDateTimeDescriptor.FACTORY);
+        temp.add(DurationFromMillisecondsDescriptor.FACTORY);
+        temp.add(DurationFromMonthsDescriptor.FACTORY);
+        temp.add(YearMonthDurationComparatorDecriptor.GREATER_THAN_FACTORY);
+        temp.add(YearMonthDurationComparatorDecriptor.LESS_THAN_FACTORY);
+        temp.add(DayTimeDurationComparatorDescriptor.GREATER_THAN_FACTORY);
+        temp.add(DayTimeDurationComparatorDescriptor.LESS_THAN_FACTORY);
+        temp.add(MonthsOfYearMonthDurationDescriptor.FACTORY);
+        temp.add(MillisecondsOfDayTimeDurationDescriptor.FACTORY);
+        temp.add(DurationEqualDescriptor.FACTORY);
 
         // Interval constructor
         temp.add(AIntervalFromDateConstructorDescriptor.FACTORY);
diff --git a/asterix-server/pom.xml b/asterix-server/pom.xml
index 3c52104..d1d6acb 100644
--- a/asterix-server/pom.xml
+++ b/asterix-server/pom.xml
@@ -5,7 +5,7 @@
   <parent>
     <groupId>edu.uci.ics.asterix</groupId>
     <artifactId>asterix</artifactId>
-    <version>0.0.5-SNAPSHOT</version>
+    <version>0.0.6-SNAPSHOT</version>
   </parent>
 
   <build>
@@ -80,7 +80,7 @@
   	<dependency>
   		<groupId>edu.uci.ics.asterix</groupId>
   		<artifactId>asterix-app</artifactId>
-  		<version>0.0.5-SNAPSHOT</version>
+  		<version>0.0.6-SNAPSHOT</version>
   	</dependency>
   </dependencies>
 </project>
\ No newline at end of file
diff --git a/asterix-test-framework/pom.xml b/asterix-test-framework/pom.xml
index a9c3292..791bf26 100755
--- a/asterix-test-framework/pom.xml
+++ b/asterix-test-framework/pom.xml
@@ -3,7 +3,7 @@
 	<parent>
 		<artifactId>asterix</artifactId>
 		<groupId>edu.uci.ics.asterix</groupId>
-		<version>0.0.5-SNAPSHOT</version>
+		<version>0.0.6-SNAPSHOT</version>
 	</parent>
 	<artifactId>asterix-test-framework</artifactId>
 	<build>
diff --git a/asterix-tools/pom.xml b/asterix-tools/pom.xml
index bc2a7ca..248cdb5 100644
--- a/asterix-tools/pom.xml
+++ b/asterix-tools/pom.xml
@@ -3,7 +3,7 @@
 	<parent>
 		<artifactId>asterix</artifactId>
 		<groupId>edu.uci.ics.asterix</groupId>
-		<version>0.0.5-SNAPSHOT</version>
+		<version>0.0.6-SNAPSHOT</version>
 	</parent>
 	<artifactId>asterix-tools</artifactId>
 
@@ -124,13 +124,13 @@
 		<dependency>
 			<groupId>edu.uci.ics.asterix</groupId>
 			<artifactId>asterix-aql</artifactId>
-			<version>0.0.5-SNAPSHOT</version>
+			<version>0.0.6-SNAPSHOT</version>
 			<scope>compile</scope>
 		</dependency>
 		<dependency>
 			<groupId>edu.uci.ics.asterix</groupId>
 			<artifactId>asterix-algebra</artifactId>
-			<version>0.0.5-SNAPSHOT</version>
+			<version>0.0.6-SNAPSHOT</version>
 			<scope>compile</scope>
 		</dependency>
 		<dependency>
diff --git a/asterix-transactions/pom.xml b/asterix-transactions/pom.xml
index 9777d1f..7d951ce 100644
--- a/asterix-transactions/pom.xml
+++ b/asterix-transactions/pom.xml
@@ -3,7 +3,7 @@
 	<parent>
 		<artifactId>asterix</artifactId>
 		<groupId>edu.uci.ics.asterix</groupId>
-		<version>0.0.5-SNAPSHOT</version>
+		<version>0.0.6-SNAPSHOT</version>
 	</parent>
 	<artifactId>asterix-transactions</artifactId>
 
diff --git a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/opcallbacks/PrimaryIndexInstantSearchOperationCallback.java b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/opcallbacks/PrimaryIndexInstantSearchOperationCallback.java
index 718ea3f..a78f2ff 100644
--- a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/opcallbacks/PrimaryIndexInstantSearchOperationCallback.java
+++ b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/opcallbacks/PrimaryIndexInstantSearchOperationCallback.java
@@ -48,7 +48,7 @@
     public void reconcile(ITupleReference tuple) throws HyracksDataException {
         int pkHash = computePrimaryKeyHashValue(tuple, primaryKeyFields);
         try {
-            lockManager.instantLock(datasetId, pkHash, LockMode.S, txnCtx);
+            lockManager.lock(datasetId, pkHash, LockMode.S, txnCtx);
         } catch (ACIDException e) {
             throw new HyracksDataException(e);
         }
@@ -58,4 +58,14 @@
     public void cancel(ITupleReference tuple) throws HyracksDataException {
         //no op
     }
+
+    @Override
+    public void complete(ITupleReference tuple) throws HyracksDataException {
+        int pkHash = computePrimaryKeyHashValue(tuple, primaryKeyFields);
+        try {
+            lockManager.unlock(datasetId, pkHash, txnCtx);
+        } catch (ACIDException e) {
+            throw new HyracksDataException(e);
+        }
+    }
 }
diff --git a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/opcallbacks/PrimaryIndexSearchOperationCallback.java b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/opcallbacks/PrimaryIndexSearchOperationCallback.java
index 4760307..62ec3c9 100644
--- a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/opcallbacks/PrimaryIndexSearchOperationCallback.java
+++ b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/opcallbacks/PrimaryIndexSearchOperationCallback.java
@@ -28,8 +28,8 @@
  */
 public class PrimaryIndexSearchOperationCallback extends AbstractOperationCallback implements ISearchOperationCallback {
 
-    public PrimaryIndexSearchOperationCallback(int datasetId, int[] entityIdFields,
-            ILockManager lockManager, TransactionContext txnCtx) {
+    public PrimaryIndexSearchOperationCallback(int datasetId, int[] entityIdFields, ILockManager lockManager,
+            TransactionContext txnCtx) {
         super(datasetId, entityIdFields, txnCtx, lockManager);
     }
 
@@ -62,4 +62,9 @@
             throw new HyracksDataException(e);
         }
     }
+
+    @Override
+    public void complete(ITupleReference tuple) throws HyracksDataException {
+        //no op
+    }
 }
diff --git a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/opcallbacks/SecondaryIndexSearchOperationCallback.java b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/opcallbacks/SecondaryIndexSearchOperationCallback.java
index c53b651..4c8a583 100644
--- a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/opcallbacks/SecondaryIndexSearchOperationCallback.java
+++ b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/opcallbacks/SecondaryIndexSearchOperationCallback.java
@@ -44,4 +44,9 @@
         // Do nothing.
     }
 
+    @Override
+    public void complete(ITupleReference tuple) throws HyracksDataException {
+        // Do nothing.
+    }
+
 }
diff --git a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/resource/PersistentLocalResourceRepository.java b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/resource/PersistentLocalResourceRepository.java
index 0a12ba1..01dce6c 100644
--- a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/resource/PersistentLocalResourceRepository.java
+++ b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/resource/PersistentLocalResourceRepository.java
@@ -25,7 +25,10 @@
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 
+import edu.uci.ics.asterix.transaction.management.service.logging.LogManager;
 import edu.uci.ics.hyracks.api.exceptions.HyracksDataException;
 import edu.uci.ics.hyracks.storage.common.file.ILocalResourceRepository;
 import edu.uci.ics.hyracks.storage.common.file.LocalResource;
@@ -33,6 +36,7 @@
 
 public class PersistentLocalResourceRepository implements ILocalResourceRepository {
 
+    private static final Logger LOGGER = Logger.getLogger(PersistentLocalResourceRepository.class.getName());
     private final String mountPoint;
     private static final String ROOT_METADATA_DIRECTORY = "asterix_root_metadata/";
     private static final String ROOT_METADATA_FILE_NAME_PREFIX = ".asterix_root_metadata_";
@@ -57,6 +61,9 @@
 
     public void initialize(String nodeId, String rootDir, boolean isNewUniverse, ResourceIdFactory resourceIdFactory)
             throws HyracksDataException {
+        if (LOGGER.isLoggable(Level.INFO)) {
+            LOGGER.info("Initializing local resource repository ... ");
+        }
         LocalResource rootLocalResource = null;
 
         //#. if the rootMetadataFile doesn't exist, create it and return.
@@ -67,6 +74,9 @@
             File rootMetadataDir = new File(mountPoint + ROOT_METADATA_DIRECTORY);
             if (!rootMetadataDir.exists()) {
                 rootMetadataDir.mkdir();
+                if (LOGGER.isLoggable(Level.INFO)) {
+                    LOGGER.info("created the root-metadata-file's directory: " + rootMetadataDir.getAbsolutePath());
+                }
             }
 
             rootMetadataFile.delete();
@@ -77,17 +87,31 @@
             }
             rootLocalResource = new LocalResource(ROOT_LOCAL_RESOURCE_ID, rootMetadataFileName, 0, 0, this.rootDir);
             insert(rootLocalResource);
+            if (LOGGER.isLoggable(Level.INFO)) {
+                LOGGER.info("created the root-metadata-file: " + rootMetadataFileName);
+            }
+            
+            if (LOGGER.isLoggable(Level.INFO)) {
+                LOGGER.info("Completed the initialization of the local resource repository");
+            }
             return;
         }
 
         //#. if the rootMetadataFile exists, read it and set this.rootDir.
         rootLocalResource = readLocalResource(rootMetadataFile);
         this.rootDir = (String) rootLocalResource.getResourceObject();
+        if (LOGGER.isLoggable(Level.INFO)) {
+            LOGGER.info("The root directory of the local resource repository is " + this.rootDir);
+        }
 
         //#. load all local resources. 
         File rootDirFile = new File(this.rootDir);
         if (!rootDirFile.exists()) {
             //rootDir may not exist if this node is not the metadata node and doesn't have any user data.
+            if (LOGGER.isLoggable(Level.INFO)) {
+                LOGGER.info("The root directory of the local resource repository doesn't exist: there is no local resource.");
+                LOGGER.info("Completed the initialization of the local resource repository");
+            }
             return;
         }
 
@@ -119,6 +143,10 @@
                                     id2ResourceMap.put(localResource.getResourceId(), localResource);
                                     name2ResourceMap.put(localResource.getResourceName(), localResource);
                                     maxResourceId = Math.max(localResource.getResourceId(), maxResourceId);
+                                    if (LOGGER.isLoggable(Level.INFO)) {
+                                        LOGGER.info("loaded local resource - [id: " + localResource.getResourceId()
+                                                + ", name: " + localResource.getResourceName() + "]");
+                                    }
                                 }
                             }
                         }
@@ -127,6 +155,10 @@
             }
         }
         resourceIdFactory.initId(maxResourceId + 1);
+        if (LOGGER.isLoggable(Level.INFO)) {
+            LOGGER.info("The resource id factory is intialized with the value: " + (maxResourceId + 1));
+            LOGGER.info("Completed the initialization of the local resource repository");
+        }
     }
 
     @Override
diff --git a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/locking/EntityInfoManager.java b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/locking/EntityInfoManager.java
index b8820c4..5d81e8a 100644
--- a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/locking/EntityInfoManager.java
+++ b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/locking/EntityInfoManager.java
@@ -164,6 +164,7 @@
                 allocChild = pArray.size() - 1;
             }
         }
+
         occupiedSlots++;
         return pArray.get(allocChild).allocate() + allocChild * ChildEntityInfoArrayManager.NUM_OF_SLOTS;
     }
@@ -230,45 +231,35 @@
      */
     private void shrink() {
         int i;
-        boolean bContiguous = true;
-        int decreaseCount = 0;
+        int removeCount = 0;
         int size = pArray.size();
         int maxDecreaseCount = size / 2;
         ChildEntityInfoArrayManager child;
-        for (i = size - 1; i >= 0; i--) {
-            child = pArray.get(i);
-            if (child.isEmpty() || child.isDeinitialized()) {
-                if (bContiguous) {
-                    pArray.remove(i);
-                    if (++decreaseCount == maxDecreaseCount) {
-                        break;
-                    }
-                } else {
-                    bContiguous = false;
-                    if (child.isEmpty()) {
-                        child.deinitialize();
-                        if (++decreaseCount == maxDecreaseCount) {
-                            break;
-                        }
-                    }
-                }
-            } else {
-                bContiguous = false;
+
+        //The first buffer never be deinitialized.
+        for (i = 1; i < size; i++) {
+            if (pArray.get(i).isEmpty()) {
+                pArray.get(i).deinitialize();
             }
         }
 
-        //reset allocChild when the child is removed or deinitialized.
-        size = pArray.size();
-        if (allocChild >= size || pArray.get(allocChild).isDeinitialized()) {
-            //set allocChild to any initialized one.
-            //It is guaranteed that there is at least one initialized child.
-            for (i = 0; i < size; i++) {
-                if (!pArray.get(i).isDeinitialized()) {
-                    allocChild = i;
+        //remove the empty buffers from the end
+        for (i = size - 1; i >= 1; i--) {
+            child = pArray.get(i);
+            if (child.isDeinitialized()) {
+                pArray.remove(i);
+                if (++removeCount == maxDecreaseCount) {
                     break;
                 }
+            } else {
+                break;
             }
         }
+        
+        //reset allocChild to the first buffer
+        allocChild = 0;
+
+        isShrinkTimerOn = false;
     }
 
     public String prettyPrint() {
@@ -538,7 +529,7 @@
         freeSlotNum = getNextFreeSlot(currentSlot);
         occupiedSlots++;
         if (LockManager.IS_DEBUG_MODE) {
-            System.out.println(Thread.currentThread().getName()+" entity allocate: "+currentSlot);
+            System.out.println(Thread.currentThread().getName() + " entity allocate: " + currentSlot);
         }
         return currentSlot;
     }
@@ -548,7 +539,7 @@
         freeSlotNum = slotNum;
         occupiedSlots--;
         if (LockManager.IS_DEBUG_MODE) {
-            System.out.println(Thread.currentThread().getName()+" entity deallocate: "+slotNum);
+            System.out.println(Thread.currentThread().getName() + " entity deallocate: " + slotNum);
         }
     }
 
diff --git a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/locking/EntityLockInfoManager.java b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/locking/EntityLockInfoManager.java
index 59c20f2..ca00aa2 100644
--- a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/locking/EntityLockInfoManager.java
+++ b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/locking/EntityLockInfoManager.java
@@ -230,45 +230,35 @@
      */
     private void shrink() {
         int i;
-        boolean bContiguous = true;
-        int decreaseCount = 0;
+        int removeCount = 0;
         int size = pArray.size();
         int maxDecreaseCount = size / 2;
         ChildEntityLockInfoArrayManager child;
-        for (i = size - 1; i >= 0; i--) {
-            child = pArray.get(i);
-            if (child.isEmpty() || child.isDeinitialized()) {
-                if (bContiguous) {
-                    pArray.remove(i);
-                    if (++decreaseCount == maxDecreaseCount) {
-                        break;
-                    }
-                } else {
-                    bContiguous = false;
-                    if (child.isEmpty()) {
-                        child.deinitialize();
-                        if (++decreaseCount == maxDecreaseCount) {
-                            break;
-                        }
-                    }
-                }
-            } else {
-                bContiguous = false;
+
+        //The first buffer never be deinitialized.
+        for (i = 1; i < size; i++) {
+            if (pArray.get(i).isEmpty()) {
+                pArray.get(i).deinitialize();
             }
         }
 
-        //reset allocChild when the child is removed or deinitialized.
-        size = pArray.size();
-        if (allocChild >= size || pArray.get(allocChild).isDeinitialized()) {
-            //set allocChild to any initialized one.
-            //It is guaranteed that there is at least one initialized child.
-            for (i = 0; i < size; i++) {
-                if (!pArray.get(i).isDeinitialized()) {
-                    allocChild = i;
+        //remove the empty buffers from the end
+        for (i = size - 1; i >= 1; i--) {
+            child = pArray.get(i);
+            if (child.isDeinitialized()) {
+                pArray.remove(i);
+                if (++removeCount == maxDecreaseCount) {
                     break;
                 }
+            } else {
+                break;
             }
         }
+        
+        //reset allocChild to the first buffer
+        allocChild = 0;
+
+        isShrinkTimerOn = false;
     }
 
     public String prettyPrint() {
diff --git a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/locking/LockManager.java b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/locking/LockManager.java
index 4e980d4..a354d2a 100644
--- a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/locking/LockManager.java
+++ b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/locking/LockManager.java
@@ -124,73 +124,111 @@
         JobInfo jobInfo;
         byte datasetLockMode = entityHashValue == -1 ? lockMode : lockMode == LockMode.S ? LockMode.IS : LockMode.IX;
         boolean doEscalate = false;
+        boolean caughtLockMgrLatchException = false;
 
         latchLockTable();
-        validateJob(txnContext);
+        try {
+            validateJob(txnContext);
 
-        if (IS_DEBUG_MODE) {
-            trackLockRequest("Requested", RequestType.LOCK, datasetId, entityHashValue, lockMode, txnContext,
-                    dLockInfo, eLockInfo);
-        }
-
-        dLockInfo = datasetResourceHT.get(datasetId);
-        jobInfo = jobHT.get(jobId);
-
-        if (ALLOW_ESCALATE_FROM_ENTITY_TO_DATASET) {
-            if (!isInstant && datasetLockMode == LockMode.IS && jobInfo != null && dLockInfo != null) {
-                int escalateStatus = needEscalateFromEntityToDataset(jobInfo, dId, lockMode);
-                switch (escalateStatus) {
-                    case DO_ESCALATE:
-                        entityHashValue = -1;
-                        doEscalate = true;
-                        break;
-
-                    case ESCALATED:
-                        unlatchLockTable();
-                        return;
-
-                    default:
-                        break;
-                }
-            }
-        }
-
-        //#. if the datasetLockInfo doesn't exist in datasetResourceHT 
-        if (dLockInfo == null || dLockInfo.isNoHolder()) {
-            if (dLockInfo == null) {
-                dLockInfo = new DatasetLockInfo(entityLockInfoManager, entityInfoManager, lockWaiterManager);
-                datasetResourceHT.put(new DatasetId(dId), dLockInfo); //datsetId obj should be created
-            }
-            entityInfo = entityInfoManager.allocate(jId, dId, entityHashValue, lockMode);
-
-            //if dataset-granule lock
-            if (entityHashValue == -1) { //-1 stands for dataset-granule
-                entityInfoManager.increaseDatasetLockCount(entityInfo);
-                dLockInfo.increaseLockCount(datasetLockMode);
-                dLockInfo.addHolder(entityInfo);
-            } else {
-                entityInfoManager.increaseDatasetLockCount(entityInfo);
-                dLockInfo.increaseLockCount(datasetLockMode);
-                //add entityLockInfo
-                eLockInfo = entityLockInfoManager.allocate();
-                dLockInfo.getEntityResourceHT().put(entityHashValue, eLockInfo);
-                entityInfoManager.increaseEntityLockCount(entityInfo);
-                entityLockInfoManager.increaseLockCount(eLockInfo, lockMode);
-                entityLockInfoManager.addHolder(eLockInfo, entityInfo);
+            if (IS_DEBUG_MODE) {
+                trackLockRequest("Requested", RequestType.LOCK, datasetId, entityHashValue, lockMode, txnContext,
+                        dLockInfo, eLockInfo);
             }
 
-            if (jobInfo == null) {
-                jobInfo = new JobInfo(entityInfoManager, lockWaiterManager, txnContext);
-                jobHT.put(jobId, jobInfo); //jobId obj doesn't have to be created
-            }
-            jobInfo.addHoldingResource(entityInfo);
+            dLockInfo = datasetResourceHT.get(datasetId);
+            jobInfo = jobHT.get(jobId);
 
             if (ALLOW_ESCALATE_FROM_ENTITY_TO_DATASET) {
-                if (!isInstant && datasetLockMode == LockMode.IS) {
-                    jobInfo.increaseDatasetISLockCount(dId);
+                if (!isInstant && datasetLockMode == LockMode.IS && jobInfo != null && dLockInfo != null) {
+                    int escalateStatus = needEscalateFromEntityToDataset(jobInfo, dId, lockMode);
+                    switch (escalateStatus) {
+                        case DO_ESCALATE:
+                            entityHashValue = -1;
+                            doEscalate = true;
+                            break;
+
+                        case ESCALATED:
+                            return;
+
+                        default:
+                            break;
+                    }
+                }
+            }
+
+            //#. if the datasetLockInfo doesn't exist in datasetResourceHT 
+            if (dLockInfo == null || dLockInfo.isNoHolder()) {
+                if (dLockInfo == null) {
+                    dLockInfo = new DatasetLockInfo(entityLockInfoManager, entityInfoManager, lockWaiterManager);
+                    datasetResourceHT.put(new DatasetId(dId), dLockInfo); //datsetId obj should be created
+                }
+                entityInfo = entityInfoManager.allocate(jId, dId, entityHashValue, lockMode);
+
+                //if dataset-granule lock
+                if (entityHashValue == -1) { //-1 stands for dataset-granule
+                    entityInfoManager.increaseDatasetLockCount(entityInfo);
+                    dLockInfo.increaseLockCount(datasetLockMode);
+                    dLockInfo.addHolder(entityInfo);
+                } else {
+                    entityInfoManager.increaseDatasetLockCount(entityInfo);
+                    dLockInfo.increaseLockCount(datasetLockMode);
+                    //add entityLockInfo
+                    eLockInfo = entityLockInfoManager.allocate();
+                    dLockInfo.getEntityResourceHT().put(entityHashValue, eLockInfo);
+                    entityInfoManager.increaseEntityLockCount(entityInfo);
+                    entityLockInfoManager.increaseLockCount(eLockInfo, lockMode);
+                    entityLockInfoManager.addHolder(eLockInfo, entityInfo);
+                }
+
+                if (jobInfo == null) {
+                    jobInfo = new JobInfo(entityInfoManager, lockWaiterManager, txnContext);
+                    jobHT.put(jobId, jobInfo); //jobId obj doesn't have to be created
+                }
+                jobInfo.addHoldingResource(entityInfo);
+
+                if (ALLOW_ESCALATE_FROM_ENTITY_TO_DATASET) {
+                    if (!isInstant && datasetLockMode == LockMode.IS) {
+                        jobInfo.increaseDatasetISLockCount(dId);
+                        if (doEscalate) {
+                            throw new IllegalStateException(
+                                    "ESCALATE_TRHESHOLD_ENTITY_TO_DATASET should not be set to "
+                                            + ESCALATE_TRHESHOLD_ENTITY_TO_DATASET);
+                        }
+                    }
+                }
+
+                if (IS_DEBUG_MODE) {
+                    trackLockRequest("Granted", RequestType.LOCK, datasetId, entityHashValue, lockMode, txnContext,
+                            dLockInfo, eLockInfo);
+                }
+
+                return;
+            }
+
+            //#. the datasetLockInfo exists in datasetResourceHT.
+            //1. handle dataset-granule lock
+            entityInfo = lockDatasetGranule(datasetId, entityHashValue, lockMode, txnContext);
+
+            //2. handle entity-granule lock
+            if (entityHashValue != -1) {
+                lockEntityGranule(datasetId, entityHashValue, lockMode, entityInfo, txnContext);
+            }
+
+            if (ALLOW_ESCALATE_FROM_ENTITY_TO_DATASET) {
+                if (!isInstant) {
                     if (doEscalate) {
-                        throw new IllegalStateException("ESCALATE_TRHESHOLD_ENTITY_TO_DATASET should not be set to "
-                                + ESCALATE_TRHESHOLD_ENTITY_TO_DATASET);
+                        //jobInfo must not be null.
+                        assert jobInfo != null;
+                        jobInfo.increaseDatasetISLockCount(dId);
+                        //release pre-acquired locks
+                        releaseDatasetISLocks(jobInfo, jobId, datasetId, txnContext);
+                    } else if (datasetLockMode == LockMode.IS) {
+                        if (jobInfo == null) {
+                            jobInfo = jobHT.get(jobId);
+                            //jobInfo must not be null;
+                            assert jobInfo != null;
+                        }
+                        jobInfo.increaseDatasetISLockCount(dId);
                     }
                 }
             }
@@ -199,44 +237,18 @@
                 trackLockRequest("Granted", RequestType.LOCK, datasetId, entityHashValue, lockMode, txnContext,
                         dLockInfo, eLockInfo);
             }
-
-            unlatchLockTable();
-            return;
-        }
-
-        //#. the datasetLockInfo exists in datasetResourceHT.
-        //1. handle dataset-granule lock
-        entityInfo = lockDatasetGranule(datasetId, entityHashValue, lockMode, txnContext);
-
-        //2. handle entity-granule lock
-        if (entityHashValue != -1) {
-            lockEntityGranule(datasetId, entityHashValue, lockMode, entityInfo, txnContext);
-        }
-
-        if (ALLOW_ESCALATE_FROM_ENTITY_TO_DATASET) {
-            if (!isInstant) {
-                if (doEscalate) {
-                    //jobInfo must not be null.
-                    assert jobInfo != null;
-                    jobInfo.increaseDatasetISLockCount(dId);
-                    //release pre-acquired locks
-                    releaseDatasetISLocks(jobInfo, jobId, datasetId, txnContext);
-                } else if (datasetLockMode == LockMode.IS) {
-                    if (jobInfo == null) {
-                        jobInfo = jobHT.get(jobId);
-                        //jobInfo must not be null;
-                        assert jobInfo != null;
-                    }
-                    jobInfo.increaseDatasetISLockCount(dId);
-                }
+        } catch (Exception e) {
+            if (e instanceof LockMgrLatchHandlerException) {
+                // don't unlatch
+                caughtLockMgrLatchException = true;
+                throw new ACIDException(((LockMgrLatchHandlerException) e).getInternalException());
+            }
+        } finally {
+            if (!caughtLockMgrLatchException) {
+                unlatchLockTable();
             }
         }
 
-        if (IS_DEBUG_MODE) {
-            trackLockRequest("Granted", RequestType.LOCK, datasetId, entityHashValue, lockMode, txnContext, dLockInfo,
-                    eLockInfo);
-        }
-        unlatchLockTable();
         return;
     }
 
@@ -285,14 +297,9 @@
 
     private void validateJob(TransactionContext txnContext) throws ACIDException {
         if (txnContext.getTxnState() == TransactionState.ABORTED) {
-            unlatchLockTable();
             throw new ACIDException("" + txnContext.getJobId() + " is in ABORTED state.");
         } else if (txnContext.getStatus() == TransactionContext.TIMED_OUT_STATUS) {
-            try {
-                requestAbort(txnContext);
-            } finally {
-                unlatchLockTable();
-            }
+            requestAbort(txnContext);
         }
     }
 
@@ -657,127 +664,124 @@
         }
 
         latchLockTable();
-        validateJob(txnContext);
+        try {
+            validateJob(txnContext);
 
-        if (IS_DEBUG_MODE) {
-            trackLockRequest("Requested", RequestType.UNLOCK, datasetId, entityHashValue, (byte) 0, txnContext,
-                    dLockInfo, eLockInfo);
-        }
+            if (IS_DEBUG_MODE) {
+                trackLockRequest("Requested", RequestType.UNLOCK, datasetId, entityHashValue, (byte) 0, txnContext,
+                        dLockInfo, eLockInfo);
+            }
 
-        //find the resource to be unlocked
-        dLockInfo = datasetResourceHT.get(datasetId);
-        jobInfo = jobHT.get(jobId);
-        if (dLockInfo == null || jobInfo == null) {
-            unlatchLockTable();
-            throw new IllegalStateException("Invalid unlock request: Corresponding lock info doesn't exist.");
-        }
+            //find the resource to be unlocked
+            dLockInfo = datasetResourceHT.get(datasetId);
+            jobInfo = jobHT.get(jobId);
+            if (dLockInfo == null || jobInfo == null) {
+                throw new IllegalStateException("Invalid unlock request: Corresponding lock info doesn't exist.");
+            }
 
-        eLockInfo = dLockInfo.getEntityResourceHT().get(entityHashValue);
+            eLockInfo = dLockInfo.getEntityResourceHT().get(entityHashValue);
 
-        if (eLockInfo == -1) {
-            unlatchLockTable();
-            throw new IllegalStateException("Invalid unlock request: Corresponding lock info doesn't exist.");
-        }
+            if (eLockInfo == -1) {
+                throw new IllegalStateException("Invalid unlock request: Corresponding lock info doesn't exist.");
+            }
 
-        //find the corresponding entityInfo
-        entityInfo = entityLockInfoManager.findEntityInfoFromHolderList(eLockInfo, jobId.getId(), entityHashValue);
-        if (entityInfo == -1) {
-            unlatchLockTable();
-            throw new IllegalStateException("Invalid unlock request[" + jobId.getId() + "," + datasetId.getId() + ","
-                    + entityHashValue + "]: Corresponding lock info doesn't exist.");
-        }
+            //find the corresponding entityInfo
+            entityInfo = entityLockInfoManager.findEntityInfoFromHolderList(eLockInfo, jobId.getId(), entityHashValue);
+            if (entityInfo == -1) {
+                throw new IllegalStateException("Invalid unlock request[" + jobId.getId() + "," + datasetId.getId()
+                        + "," + entityHashValue + "]: Corresponding lock info doesn't exist.");
+            }
 
-        datasetLockMode = entityInfoManager.getDatasetLockMode(entityInfo) == LockMode.S ? LockMode.IS : LockMode.IX;
+            datasetLockMode = entityInfoManager.getDatasetLockMode(entityInfo) == LockMode.S ? LockMode.IS
+                    : LockMode.IX;
 
-        //decrease the corresponding count of dLockInfo/eLockInfo/entityInfo
-        dLockInfo.decreaseLockCount(datasetLockMode);
-        entityLockInfoManager.decreaseLockCount(eLockInfo, entityInfoManager.getEntityLockMode(entityInfo));
-        entityInfoManager.decreaseDatasetLockCount(entityInfo);
-        entityInfoManager.decreaseEntityLockCount(entityInfo);
+            //decrease the corresponding count of dLockInfo/eLockInfo/entityInfo
+            dLockInfo.decreaseLockCount(datasetLockMode);
+            entityLockInfoManager.decreaseLockCount(eLockInfo, entityInfoManager.getEntityLockMode(entityInfo));
+            entityInfoManager.decreaseDatasetLockCount(entityInfo);
+            entityInfoManager.decreaseEntityLockCount(entityInfo);
 
-        if (entityInfoManager.getEntityLockCount(entityInfo) == 0
-                && entityInfoManager.getDatasetLockCount(entityInfo) == 0) {
-            int threadCount = 0; //number of threads(in the same job) waiting on the same resource 
-            int waiterObjId = jobInfo.getFirstWaitingResource();
-            int waitingEntityInfo;
-            LockWaiter waiterObj;
+            if (entityInfoManager.getEntityLockCount(entityInfo) == 0
+                    && entityInfoManager.getDatasetLockCount(entityInfo) == 0) {
+                int threadCount = 0; //number of threads(in the same job) waiting on the same resource 
+                int waiterObjId = jobInfo.getFirstWaitingResource();
+                int waitingEntityInfo;
+                LockWaiter waiterObj;
 
-            //TODO
-            //This code should be taken care properly when there is a way to avoid doubling memory space for txnIds.
-            //This commit log is written here in order to avoid increasing the memory space for managing transactionIds
-            if (commitFlag) {
-                if (txnContext.getTransactionType().equals(TransactionContext.TransactionType.READ_WRITE)) {
-                    try {
-                        txnSubsystem.getLogManager().log(LogType.ENTITY_COMMIT, txnContext, datasetId.getId(),
-                                entityHashValue, -1, (byte) 0, 0, null, null, logicalLogLocator);
-                    } catch (ACIDException e) {
+                //TODO
+                //This code should be taken care properly when there is a way to avoid doubling memory space for txnIds.
+                //This commit log is written here in order to avoid increasing the memory space for managing transactionIds
+                if (commitFlag) {
+                    if (txnContext.getTransactionType().equals(TransactionContext.TransactionType.READ_WRITE)) {
                         try {
+                            txnSubsystem.getLogManager().log(LogType.ENTITY_COMMIT, txnContext, datasetId.getId(),
+                                    entityHashValue, -1, (byte) 0, 0, null, null, logicalLogLocator);
+                        } catch (ACIDException e) {
                             requestAbort(txnContext);
-                        } finally {
-                            unlatchLockTable();
                         }
                     }
+
+                    txnContext.updateLastLSNForIndexes(logicalLogLocator.getLsn());
                 }
 
-                txnContext.updateLastLSNForIndexes(logicalLogLocator.getLsn());
-            }
+                //1) wake up waiters and remove holder
+                //wake up waiters of dataset-granule lock
+                wakeUpDatasetLockWaiters(dLockInfo);
+                //wake up waiters of entity-granule lock
+                wakeUpEntityLockWaiters(eLockInfo);
+                //remove the holder from eLockInfo's holder list and remove the holding resource from jobInfo's holding resource list
+                //this can be done in the following single function call.
+                entityLockInfoManager.removeHolder(eLockInfo, entityInfo, jobInfo);
 
-            //1) wake up waiters and remove holder
-            //wake up waiters of dataset-granule lock
-            wakeUpDatasetLockWaiters(dLockInfo);
-            //wake up waiters of entity-granule lock
-            wakeUpEntityLockWaiters(eLockInfo);
-            //remove the holder from eLockInfo's holder list and remove the holding resource from jobInfo's holding resource list
-            //this can be done in the following single function call.
-            entityLockInfoManager.removeHolder(eLockInfo, entityInfo, jobInfo);
-
-            //2) if 
-            //      there is no waiting thread on the same resource (this can be checked through jobInfo)
-            //   then 
-            //      a) delete the corresponding entityInfo
-            //      b) write commit log for the unlocked resource(which is a committed txn).
-            while (waiterObjId != -1) {
-                waiterObj = lockWaiterManager.getLockWaiter(waiterObjId);
-                waitingEntityInfo = waiterObj.getEntityInfoSlot();
-                if (entityInfoManager.getDatasetId(waitingEntityInfo) == datasetId.getId()
-                        && entityInfoManager.getPKHashVal(waitingEntityInfo) == entityHashValue) {
-                    threadCount++;
-                    break;
+                //2) if 
+                //      there is no waiting thread on the same resource (this can be checked through jobInfo)
+                //   then 
+                //      a) delete the corresponding entityInfo
+                //      b) write commit log for the unlocked resource(which is a committed txn).
+                while (waiterObjId != -1) {
+                    waiterObj = lockWaiterManager.getLockWaiter(waiterObjId);
+                    waitingEntityInfo = waiterObj.getEntityInfoSlot();
+                    if (entityInfoManager.getDatasetId(waitingEntityInfo) == datasetId.getId()
+                            && entityInfoManager.getPKHashVal(waitingEntityInfo) == entityHashValue) {
+                        threadCount++;
+                        break;
+                    }
+                    waiterObjId = waiterObj.getNextWaiterObjId();
                 }
-                waiterObjId = waiterObj.getNextWaiterObjId();
-            }
-            if (threadCount == 0) {
-                if (entityInfoManager.getEntityLockMode(entityInfo) == LockMode.X) {
-                    //TODO
-                    //write a commit log for the unlocked resource
-                    //need to figure out that instantLock() also needs to write a commit log. 
+                if (threadCount == 0) {
+                    if (entityInfoManager.getEntityLockMode(entityInfo) == LockMode.X) {
+                        //TODO
+                        //write a commit log for the unlocked resource
+                        //need to figure out that instantLock() also needs to write a commit log. 
+                    }
+                    entityInfoManager.deallocate(entityInfo);
                 }
-                entityInfoManager.deallocate(entityInfo);
             }
-        }
 
-        //deallocate entityLockInfo's slot if there is no txn referring to the entityLockInfo.
-        if (entityLockInfoManager.getFirstWaiter(eLockInfo) == -1
-                && entityLockInfoManager.getLastHolder(eLockInfo) == -1
-                && entityLockInfoManager.getUpgrader(eLockInfo) == -1) {
-            dLockInfo.getEntityResourceHT().remove(entityHashValue);
-            entityLockInfoManager.deallocate(eLockInfo);
-        }
-
-        //we don't deallocate datasetLockInfo even if there is no txn referring to the datasetLockInfo
-        //since the datasetLockInfo is likely to be referred to again.
-
-        if (ALLOW_ESCALATE_FROM_ENTITY_TO_DATASET) {
-            if (!isInstant && datasetLockMode == LockMode.IS) {
-                jobInfo.decreaseDatasetISLockCount(datasetId.getId());
+            //deallocate entityLockInfo's slot if there is no txn referring to the entityLockInfo.
+            if (entityLockInfoManager.getFirstWaiter(eLockInfo) == -1
+                    && entityLockInfoManager.getLastHolder(eLockInfo) == -1
+                    && entityLockInfoManager.getUpgrader(eLockInfo) == -1) {
+                dLockInfo.getEntityResourceHT().remove(entityHashValue);
+                entityLockInfoManager.deallocate(eLockInfo);
             }
-        }
 
-        if (IS_DEBUG_MODE) {
-            trackLockRequest("Granted", RequestType.UNLOCK, datasetId, entityHashValue, (byte) 0, txnContext,
-                    dLockInfo, eLockInfo);
+            //we don't deallocate datasetLockInfo even if there is no txn referring to the datasetLockInfo
+            //since the datasetLockInfo is likely to be referred to again.
+
+            if (ALLOW_ESCALATE_FROM_ENTITY_TO_DATASET) {
+                if (!isInstant && datasetLockMode == LockMode.IS) {
+                    jobInfo.decreaseDatasetISLockCount(datasetId.getId());
+                }
+            }
+
+            if (IS_DEBUG_MODE) {
+                trackLockRequest("Granted", RequestType.UNLOCK, datasetId, entityHashValue, (byte) 0, txnContext,
+                        dLockInfo, eLockInfo);
+            }
+        } finally {
+            unlatchLockTable();
         }
-        unlatchLockTable();
     }
 
     @Override
@@ -797,183 +801,178 @@
         JobId jobId = txnContext.getJobId();
 
         latchLockTable();
-
-        if (IS_DEBUG_MODE) {
-            trackLockRequest("Requested", RequestType.RELEASE_LOCKS, new DatasetId(0), 0, (byte) 0, txnContext,
-                    dLockInfo, eLockInfo);
-        }
-
-        JobInfo jobInfo = jobHT.get(jobId);
-        if (jobInfo == null) {
-            unlatchLockTable();
-            return;
-        }
-
-        //remove waiterObj of JobInfo 
-        //[Notice]
-        //waiterObjs may exist if aborted thread is the caller of this function.
-        //Even if there are the waiterObjs, there is no waiting thread on the objects. 
-        //If the caller of this function is an aborted thread, it is guaranteed that there is no waiting threads
-        //on the waiterObjs since when the aborted caller thread is waken up, all other waiting threads are
-        //also waken up at the same time through 'notifyAll()' call.
-        //In contrast, if the caller of this function is not an aborted thread, then there is no waiting object.
-        int waiterObjId = jobInfo.getFirstWaitingResource();
-        int nextWaiterObjId;
-        while (waiterObjId != -1) {
-            existWaiter = true;
-            waiterObj = lockWaiterManager.getLockWaiter(waiterObjId);
-            nextWaiterObjId = waiterObj.getNextWaitingResourceObjId();
-            entityInfo = waiterObj.getEntityInfoSlot();
+        try {
             if (IS_DEBUG_MODE) {
-                if (jobId.getId() != entityInfoManager.getJobId(entityInfo)) {
-                    throw new IllegalStateException("JobInfo(" + jobId + ") has diffrent Job(JID:"
-                            + entityInfoManager.getJobId(entityInfo) + "'s lock request!!!");
-                }
+                trackLockRequest("Requested", RequestType.RELEASE_LOCKS, new DatasetId(0), 0, (byte) 0, txnContext,
+                        dLockInfo, eLockInfo);
             }
 
-            //1. remove from waiter(or upgrader)'s list of dLockInfo or eLockInfo.
-            did = entityInfoManager.getDatasetId(entityInfo);
-            tempDatasetIdObj.setId(did);
-            dLockInfo = datasetResourceHT.get(tempDatasetIdObj);
-
-            if (waiterObj.isWaitingOnEntityLock()) {
-                entityHashValue = entityInfoManager.getPKHashVal(entityInfo);
-                eLockInfo = dLockInfo.getEntityResourceHT().get(entityHashValue);
-                if (waiterObj.isWaiter()) {
-                    entityLockInfoManager.removeWaiter(eLockInfo, waiterObjId);
-                } else {
-                    entityLockInfoManager.removeUpgrader(eLockInfo, waiterObjId);
-                }
-            } else {
-                if (waiterObj.isWaiter()) {
-                    dLockInfo.removeWaiter(waiterObjId);
-                } else {
-                    dLockInfo.removeUpgrader(waiterObjId);
-                }
+            JobInfo jobInfo = jobHT.get(jobId);
+            if (jobInfo == null) {
+                return;
             }
 
-            //2. wake-up waiters
-            latchWaitNotify();
-            synchronized (waiterObj) {
-                unlatchWaitNotify();
-                waiterObj.setWait(false);
+            //remove waiterObj of JobInfo 
+            //[Notice]
+            //waiterObjs may exist if aborted thread is the caller of this function.
+            //Even if there are the waiterObjs, there is no waiting thread on the objects. 
+            //If the caller of this function is an aborted thread, it is guaranteed that there is no waiting threads
+            //on the waiterObjs since when the aborted caller thread is waken up, all other waiting threads are
+            //also waken up at the same time through 'notifyAll()' call.
+            //In contrast, if the caller of this function is not an aborted thread, then there is no waiting object.
+            int waiterObjId = jobInfo.getFirstWaitingResource();
+            int nextWaiterObjId;
+            while (waiterObjId != -1) {
+                existWaiter = true;
+                waiterObj = lockWaiterManager.getLockWaiter(waiterObjId);
+                nextWaiterObjId = waiterObj.getNextWaitingResourceObjId();
+                entityInfo = waiterObj.getEntityInfoSlot();
                 if (IS_DEBUG_MODE) {
-                    System.out.println("" + Thread.currentThread().getName() + "\twake-up(D): WID(" + waiterObjId
-                            + "),EID(" + waiterObj.getEntityInfoSlot() + ")");
-                }
-                waiterObj.notifyAll();
-            }
-
-            //3. deallocate waiterObj
-            lockWaiterManager.deallocate(waiterObjId);
-
-            //4. deallocate entityInfo only if this waiter is not an upgrader
-            if (entityInfoManager.getDatasetLockCount(entityInfo) == 0
-                    && entityInfoManager.getEntityLockCount(entityInfo) == 0) {
-                entityInfoManager.deallocate(entityInfo);
-            }
-            waiterObjId = nextWaiterObjId;
-        }
-
-        //release holding resources
-        entityInfo = jobInfo.getLastHoldingResource();
-        while (entityInfo != -1) {
-            prevEntityInfo = entityInfoManager.getPrevJobResource(entityInfo);
-
-            //decrease lock count of datasetLock and entityLock
-            did = entityInfoManager.getDatasetId(entityInfo);
-            tempDatasetIdObj.setId(did);
-            dLockInfo = datasetResourceHT.get(tempDatasetIdObj);
-            entityHashValue = entityInfoManager.getPKHashVal(entityInfo);
-
-            if (entityHashValue == -1) {
-                //decrease datasetLockCount
-                lockMode = entityInfoManager.getDatasetLockMode(entityInfo);
-                datasetLockCount = entityInfoManager.getDatasetLockCount(entityInfo);
-                if (datasetLockCount != 0) {
-                    dLockInfo.decreaseLockCount(lockMode, datasetLockCount);
-
-                    //wakeup waiters of datasetLock and remove holder from datasetLockInfo
-                    wakeUpDatasetLockWaiters(dLockInfo);
-
-                    //remove the holder from datasetLockInfo only if the lock is dataset-granule lock.
-                    //--> this also removes the holding resource from jobInfo               
-                    //(Because the IX and IS lock's holders are handled implicitly, 
-                    //those are not in the holder list of datasetLockInfo.)
-                    dLockInfo.removeHolder(entityInfo, jobInfo);
-                }
-            } else {
-                //decrease datasetLockCount
-                lockMode = entityInfoManager.getDatasetLockMode(entityInfo);
-                lockMode = lockMode == LockMode.S ? LockMode.IS : LockMode.IX;
-                datasetLockCount = entityInfoManager.getDatasetLockCount(entityInfo);
-
-                if (datasetLockCount != 0) {
-                    dLockInfo.decreaseLockCount(lockMode, datasetLockCount);
-                }
-
-                //decrease entityLockCount
-                lockMode = entityInfoManager.getEntityLockMode(entityInfo);
-                entityLockCount = entityInfoManager.getEntityLockCount(entityInfo);
-                eLockInfo = dLockInfo.getEntityResourceHT().get(entityHashValue);
-                if (IS_DEBUG_MODE) {
-                    if (eLockInfo < 0) {
-                        System.out.println("eLockInfo:" + eLockInfo);
+                    if (jobId.getId() != entityInfoManager.getJobId(entityInfo)) {
+                        throw new IllegalStateException("JobInfo(" + jobId + ") has diffrent Job(JID:"
+                                + entityInfoManager.getJobId(entityInfo) + "'s lock request!!!");
                     }
                 }
 
-                if (entityLockCount != 0) {
-                    entityLockInfoManager.decreaseLockCount(eLockInfo, lockMode, (short) entityLockCount);
+                //1. remove from waiter(or upgrader)'s list of dLockInfo or eLockInfo.
+                did = entityInfoManager.getDatasetId(entityInfo);
+                tempDatasetIdObj.setId(did);
+                dLockInfo = datasetResourceHT.get(tempDatasetIdObj);
+
+                if (waiterObj.isWaitingOnEntityLock()) {
+                    entityHashValue = entityInfoManager.getPKHashVal(entityInfo);
+                    eLockInfo = dLockInfo.getEntityResourceHT().get(entityHashValue);
+                    if (waiterObj.isWaiter()) {
+                        entityLockInfoManager.removeWaiter(eLockInfo, waiterObjId);
+                    } else {
+                        entityLockInfoManager.removeUpgrader(eLockInfo, waiterObjId);
+                    }
+                } else {
+                    if (waiterObj.isWaiter()) {
+                        dLockInfo.removeWaiter(waiterObjId);
+                    } else {
+                        dLockInfo.removeUpgrader(waiterObjId);
+                    }
                 }
 
-                if (datasetLockCount != 0) {
-                    //wakeup waiters of datasetLock and don't remove holder from datasetLockInfo
-                    wakeUpDatasetLockWaiters(dLockInfo);
+                //2. wake-up waiters
+                latchWaitNotify();
+                synchronized (waiterObj) {
+                    unlatchWaitNotify();
+                    waiterObj.setWait(false);
+                    if (IS_DEBUG_MODE) {
+                        System.out.println("" + Thread.currentThread().getName() + "\twake-up(D): WID(" + waiterObjId
+                                + "),EID(" + waiterObj.getEntityInfoSlot() + ")");
+                    }
+                    waiterObj.notifyAll();
                 }
 
-                if (entityLockCount != 0) {
-                    //wakeup waiters of entityLock
-                    wakeUpEntityLockWaiters(eLockInfo);
+                //3. deallocate waiterObj
+                lockWaiterManager.deallocate(waiterObjId);
 
-                    //remove the holder from entityLockInfo 
-                    //--> this also removes the holding resource from jobInfo
-                    entityLockInfoManager.removeHolder(eLockInfo, entityInfo, jobInfo);
+                //4. deallocate entityInfo only if this waiter is not an upgrader
+                if (entityInfoManager.getDatasetLockCount(entityInfo) == 0
+                        && entityInfoManager.getEntityLockCount(entityInfo) == 0) {
+                    entityInfoManager.deallocate(entityInfo);
                 }
-
-                //deallocate entityLockInfo if there is no holder and waiter.
-                if (entityLockInfoManager.getLastHolder(eLockInfo) == -1
-                        && entityLockInfoManager.getFirstWaiter(eLockInfo) == -1
-                        && entityLockInfoManager.getUpgrader(eLockInfo) == -1) {
-                    dLockInfo.getEntityResourceHT().remove(entityHashValue);
-                    entityLockInfoManager.deallocate(eLockInfo);
-                    //                    if (IS_DEBUG_MODE) {
-                    //                        System.out.println("removed PK["+entityHashValue+"]");
-                    //                    }
-                }
+                waiterObjId = nextWaiterObjId;
             }
 
-            //deallocate entityInfo
-            entityInfoManager.deallocate(entityInfo);
-            //            if (IS_DEBUG_MODE) {
-            //                System.out.println("dellocate EntityInfo["+entityInfo+"]");
-            //            }
+            //release holding resources
+            entityInfo = jobInfo.getLastHoldingResource();
+            while (entityInfo != -1) {
+                prevEntityInfo = entityInfoManager.getPrevJobResource(entityInfo);
 
-            entityInfo = prevEntityInfo;
+                //decrease lock count of datasetLock and entityLock
+                did = entityInfoManager.getDatasetId(entityInfo);
+                tempDatasetIdObj.setId(did);
+                dLockInfo = datasetResourceHT.get(tempDatasetIdObj);
+                entityHashValue = entityInfoManager.getPKHashVal(entityInfo);
+
+                if (entityHashValue == -1) {
+                    //decrease datasetLockCount
+                    lockMode = entityInfoManager.getDatasetLockMode(entityInfo);
+                    datasetLockCount = entityInfoManager.getDatasetLockCount(entityInfo);
+                    if (datasetLockCount != 0) {
+                        dLockInfo.decreaseLockCount(lockMode, datasetLockCount);
+
+                        //wakeup waiters of datasetLock and remove holder from datasetLockInfo
+                        wakeUpDatasetLockWaiters(dLockInfo);
+
+                        //remove the holder from datasetLockInfo only if the lock is dataset-granule lock.
+                        //--> this also removes the holding resource from jobInfo               
+                        //(Because the IX and IS lock's holders are handled implicitly, 
+                        //those are not in the holder list of datasetLockInfo.)
+                        dLockInfo.removeHolder(entityInfo, jobInfo);
+                    }
+                } else {
+                    //decrease datasetLockCount
+                    lockMode = entityInfoManager.getDatasetLockMode(entityInfo);
+                    lockMode = lockMode == LockMode.S ? LockMode.IS : LockMode.IX;
+                    datasetLockCount = entityInfoManager.getDatasetLockCount(entityInfo);
+
+                    if (datasetLockCount != 0) {
+                        dLockInfo.decreaseLockCount(lockMode, datasetLockCount);
+                    }
+
+                    //decrease entityLockCount
+                    lockMode = entityInfoManager.getEntityLockMode(entityInfo);
+                    entityLockCount = entityInfoManager.getEntityLockCount(entityInfo);
+                    eLockInfo = dLockInfo.getEntityResourceHT().get(entityHashValue);
+                    if (IS_DEBUG_MODE) {
+                        if (eLockInfo < 0) {
+                            System.out.println("eLockInfo:" + eLockInfo);
+                        }
+                    }
+
+                    if (entityLockCount != 0) {
+                        entityLockInfoManager.decreaseLockCount(eLockInfo, lockMode, (short) entityLockCount);
+                    }
+
+                    if (datasetLockCount != 0) {
+                        //wakeup waiters of datasetLock and don't remove holder from datasetLockInfo
+                        wakeUpDatasetLockWaiters(dLockInfo);
+                    }
+
+                    if (entityLockCount != 0) {
+                        //wakeup waiters of entityLock
+                        wakeUpEntityLockWaiters(eLockInfo);
+
+                        //remove the holder from entityLockInfo 
+                        //--> this also removes the holding resource from jobInfo
+                        entityLockInfoManager.removeHolder(eLockInfo, entityInfo, jobInfo);
+                    }
+
+                    //deallocate entityLockInfo if there is no holder and waiter.
+                    if (entityLockInfoManager.getLastHolder(eLockInfo) == -1
+                            && entityLockInfoManager.getFirstWaiter(eLockInfo) == -1
+                            && entityLockInfoManager.getUpgrader(eLockInfo) == -1) {
+                        dLockInfo.getEntityResourceHT().remove(entityHashValue);
+                        entityLockInfoManager.deallocate(eLockInfo);
+                    }
+                }
+
+                //deallocate entityInfo
+                entityInfoManager.deallocate(entityInfo);
+
+                entityInfo = prevEntityInfo;
+            }
+
+            //remove JobInfo
+            jobHT.remove(jobId);
+
+            if (existWaiter) {
+                txnContext.setStatus(TransactionContext.TIMED_OUT_STATUS);
+                txnContext.setTxnState(TransactionState.ABORTED);
+            }
+
+            if (IS_DEBUG_MODE) {
+                trackLockRequest("Granted", RequestType.RELEASE_LOCKS, new DatasetId(0), 0, (byte) 0, txnContext,
+                        dLockInfo, eLockInfo);
+            }
+        } finally {
+            unlatchLockTable();
         }
-
-        //remove JobInfo
-        jobHT.remove(jobId);
-
-        if (existWaiter) {
-            txnContext.setStatus(TransactionContext.TIMED_OUT_STATUS);
-            txnContext.setTxnState(TransactionState.ABORTED);
-        }
-
-        if (IS_DEBUG_MODE) {
-            trackLockRequest("Granted", RequestType.RELEASE_LOCKS, new DatasetId(0), 0, (byte) 0, txnContext,
-                    dLockInfo, eLockInfo);
-        }
-        unlatchLockTable();
     }
 
     @Override
@@ -1008,57 +1007,59 @@
         boolean isSuccess = true;
 
         latchLockTable();
-        validateJob(txnContext);
+        try {
+            validateJob(txnContext);
 
-        if (IS_DEBUG_MODE) {
-            trackLockRequest("Requested", RequestType.INSTANT_TRY_LOCK, datasetId, entityHashValue, lockMode,
-                    txnContext, dLockInfo, -1);
-        }
-
-        dLockInfo = datasetResourceHT.get(datasetId);
-
-        //#. if the datasetLockInfo doesn't exist in datasetResourceHT 
-        if (dLockInfo == null || dLockInfo.isNoHolder()) {
             if (IS_DEBUG_MODE) {
-                trackLockRequest("Granted", RequestType.INSTANT_TRY_LOCK, datasetId, entityHashValue, lockMode,
+                trackLockRequest("Requested", RequestType.INSTANT_TRY_LOCK, datasetId, entityHashValue, lockMode,
                         txnContext, dLockInfo, -1);
             }
 
-            unlatchLockTable();
-            return true;
-        }
+            dLockInfo = datasetResourceHT.get(datasetId);
 
-        //#. the datasetLockInfo exists in datasetResourceHT.
-        //1. handle dataset-granule lock
-        byte datasetLockMode = entityHashValue == -1 ? lockMode : lockMode == LockMode.S ? LockMode.IS : LockMode.IX;
-        if (datasetLockMode == LockMode.IS) {
-            //[Notice]
-            //Skip checking the dataset level lock compatibility if the requested LockMode is IS lock.
-            //We know that this internalInstantTryLock() call with IS lock mode will be always granted 
-            //because we don't allow X lock on dataset-level except DDL operation. 
-            //During DDL operation, all other operations will be pending, so there is no conflict. 
-            isSuccess = true;
-        } else {
-            isSuccess = instantTryLockDatasetGranule(datasetId, entityHashValue, lockMode, txnContext, dLockInfo,
-                    datasetLockMode);
-        }
+            //#. if the datasetLockInfo doesn't exist in datasetResourceHT 
+            if (dLockInfo == null || dLockInfo.isNoHolder()) {
+                if (IS_DEBUG_MODE) {
+                    trackLockRequest("Granted", RequestType.INSTANT_TRY_LOCK, datasetId, entityHashValue, lockMode,
+                            txnContext, dLockInfo, -1);
+                }
+                return true;
+            }
 
-        if (isSuccess && entityHashValue != -1) {
-            //2. handle entity-granule lock
-            isSuccess = instantTryLockEntityGranule(datasetId, entityHashValue, lockMode, txnContext, dLockInfo);
-        }
-
-        if (IS_DEBUG_MODE) {
-            if (isSuccess) {
-                trackLockRequest("Granted", RequestType.INSTANT_TRY_LOCK, datasetId, entityHashValue, lockMode,
-                        txnContext, dLockInfo, -1);
+            //#. the datasetLockInfo exists in datasetResourceHT.
+            //1. handle dataset-granule lock
+            byte datasetLockMode = entityHashValue == -1 ? lockMode : lockMode == LockMode.S ? LockMode.IS
+                    : LockMode.IX;
+            if (datasetLockMode == LockMode.IS) {
+                //[Notice]
+                //Skip checking the dataset level lock compatibility if the requested LockMode is IS lock.
+                //We know that this internalInstantTryLock() call with IS lock mode will be always granted 
+                //because we don't allow X lock on dataset-level except DDL operation. 
+                //During DDL operation, all other operations will be pending, so there is no conflict. 
+                isSuccess = true;
             } else {
-                trackLockRequest("Failed", RequestType.INSTANT_TRY_LOCK, datasetId, entityHashValue, lockMode,
-                        txnContext, dLockInfo, -1);
+                isSuccess = instantTryLockDatasetGranule(datasetId, entityHashValue, lockMode, txnContext, dLockInfo,
+                        datasetLockMode);
             }
-        }
 
-        unlatchLockTable();
+            if (isSuccess && entityHashValue != -1) {
+                //2. handle entity-granule lock
+                isSuccess = instantTryLockEntityGranule(datasetId, entityHashValue, lockMode, txnContext, dLockInfo);
+            }
+
+            if (IS_DEBUG_MODE) {
+                if (isSuccess) {
+                    trackLockRequest("Granted", RequestType.INSTANT_TRY_LOCK, datasetId, entityHashValue, lockMode,
+                            txnContext, dLockInfo, -1);
+                } else {
+                    trackLockRequest("Failed", RequestType.INSTANT_TRY_LOCK, datasetId, entityHashValue, lockMode,
+                            txnContext, dLockInfo, -1);
+                }
+            }
+
+        } finally {
+            unlatchLockTable();
+        }
 
         return isSuccess;
     }
@@ -1217,133 +1218,136 @@
         boolean doEscalate = false;
 
         latchLockTable();
-        validateJob(txnContext);
+        try {
+            validateJob(txnContext);
 
-        if (IS_DEBUG_MODE) {
-            trackLockRequest("Requested", RequestType.TRY_LOCK, datasetId, entityHashValue, lockMode, txnContext,
-                    dLockInfo, eLockInfo);
-        }
-
-        dLockInfo = datasetResourceHT.get(datasetId);
-        jobInfo = jobHT.get(jobId);
-
-        if (ALLOW_ESCALATE_FROM_ENTITY_TO_DATASET) {
-            if (!isInstant && datasetLockMode == LockMode.IS && jobInfo != null && dLockInfo != null) {
-                int upgradeStatus = needEscalateFromEntityToDataset(jobInfo, dId, lockMode);
-                switch (upgradeStatus) {
-                    case DO_ESCALATE:
-                        entityHashValue = -1;
-                        doEscalate = true;
-                        break;
-
-                    case ESCALATED:
-                        unlatchLockTable();
-                        return true;
-
-                    default:
-                        break;
-                }
-            }
-        }
-
-        //#. if the datasetLockInfo doesn't exist in datasetResourceHT 
-        if (dLockInfo == null || dLockInfo.isNoHolder()) {
-            if (dLockInfo == null) {
-                dLockInfo = new DatasetLockInfo(entityLockInfoManager, entityInfoManager, lockWaiterManager);
-                datasetResourceHT.put(new DatasetId(dId), dLockInfo); //datsetId obj should be created
-            }
-            entityInfo = entityInfoManager.allocate(jId, dId, entityHashValue, lockMode);
-
-            //if dataset-granule lock
-            if (entityHashValue == -1) { //-1 stands for dataset-granule
-                entityInfoManager.increaseDatasetLockCount(entityInfo);
-                dLockInfo.increaseLockCount(datasetLockMode);
-                dLockInfo.addHolder(entityInfo);
-            } else {
-                entityInfoManager.increaseDatasetLockCount(entityInfo);
-                dLockInfo.increaseLockCount(datasetLockMode);
-                //add entityLockInfo
-                eLockInfo = entityLockInfoManager.allocate();
-                dLockInfo.getEntityResourceHT().put(entityHashValue, eLockInfo);
-                entityInfoManager.increaseEntityLockCount(entityInfo);
-                entityLockInfoManager.increaseLockCount(eLockInfo, lockMode);
-                entityLockInfoManager.addHolder(eLockInfo, entityInfo);
+            if (IS_DEBUG_MODE) {
+                trackLockRequest("Requested", RequestType.TRY_LOCK, datasetId, entityHashValue, lockMode, txnContext,
+                        dLockInfo, eLockInfo);
             }
 
-            if (jobInfo == null) {
-                jobInfo = new JobInfo(entityInfoManager, lockWaiterManager, txnContext);
-                jobHT.put(jobId, jobInfo); //jobId obj doesn't have to be created
-            }
-            jobInfo.addHoldingResource(entityInfo);
+            dLockInfo = datasetResourceHT.get(datasetId);
+            jobInfo = jobHT.get(jobId);
 
             if (ALLOW_ESCALATE_FROM_ENTITY_TO_DATASET) {
-                if (!isInstant && datasetLockMode == LockMode.IS) {
-                    jobInfo.increaseDatasetISLockCount(dId);
+                if (!isInstant && datasetLockMode == LockMode.IS && jobInfo != null && dLockInfo != null) {
+                    int upgradeStatus = needEscalateFromEntityToDataset(jobInfo, dId, lockMode);
+                    switch (upgradeStatus) {
+                        case DO_ESCALATE:
+                            entityHashValue = -1;
+                            doEscalate = true;
+                            break;
+
+                        case ESCALATED:
+                            return true;
+
+                        default:
+                            break;
+                    }
+                }
+            }
+
+            //#. if the datasetLockInfo doesn't exist in datasetResourceHT 
+            if (dLockInfo == null || dLockInfo.isNoHolder()) {
+                if (dLockInfo == null) {
+                    dLockInfo = new DatasetLockInfo(entityLockInfoManager, entityInfoManager, lockWaiterManager);
+                    datasetResourceHT.put(new DatasetId(dId), dLockInfo); //datsetId obj should be created
+                }
+                entityInfo = entityInfoManager.allocate(jId, dId, entityHashValue, lockMode);
+
+                //if dataset-granule lock
+                if (entityHashValue == -1) { //-1 stands for dataset-granule
+                    entityInfoManager.increaseDatasetLockCount(entityInfo);
+                    dLockInfo.increaseLockCount(datasetLockMode);
+                    dLockInfo.addHolder(entityInfo);
+                } else {
+                    entityInfoManager.increaseDatasetLockCount(entityInfo);
+                    dLockInfo.increaseLockCount(datasetLockMode);
+                    //add entityLockInfo
+                    eLockInfo = entityLockInfoManager.allocate();
+                    dLockInfo.getEntityResourceHT().put(entityHashValue, eLockInfo);
+                    entityInfoManager.increaseEntityLockCount(entityInfo);
+                    entityLockInfoManager.increaseLockCount(eLockInfo, lockMode);
+                    entityLockInfoManager.addHolder(eLockInfo, entityInfo);
+                }
+
+                if (jobInfo == null) {
+                    jobInfo = new JobInfo(entityInfoManager, lockWaiterManager, txnContext);
+                    jobHT.put(jobId, jobInfo); //jobId obj doesn't have to be created
+                }
+                jobInfo.addHoldingResource(entityInfo);
+
+                if (ALLOW_ESCALATE_FROM_ENTITY_TO_DATASET) {
+                    if (!isInstant && datasetLockMode == LockMode.IS) {
+                        jobInfo.increaseDatasetISLockCount(dId);
+                        if (doEscalate) {
+                            //This exception is thrown when the threshold value is set to 1.
+                            //We don't want to allow the lock escalation when there is a first lock request on a dataset. 
+                            throw new IllegalStateException(
+                                    "ESCALATE_TRHESHOLD_ENTITY_TO_DATASET should not be set to "
+                                            + ESCALATE_TRHESHOLD_ENTITY_TO_DATASET);
+                        }
+                    }
+                }
+
+                if (IS_DEBUG_MODE) {
+                    trackLockRequest("Granted", RequestType.TRY_LOCK, datasetId, entityHashValue, lockMode, txnContext,
+                            dLockInfo, eLockInfo);
+                }
+
+                return true;
+            }
+
+            //#. the datasetLockInfo exists in datasetResourceHT.
+            //1. handle dataset-granule lock
+            tryLockDatasetGranuleRevertOperation = 0;
+            entityInfo = tryLockDatasetGranule(datasetId, entityHashValue, lockMode, txnContext);
+            if (entityInfo == -2) {//-2 represents fail
+                isSuccess = false;
+            } else {
+                //2. handle entity-granule lock
+                if (entityHashValue != -1) {
+                    isSuccess = tryLockEntityGranule(datasetId, entityHashValue, lockMode, entityInfo, txnContext);
+                    if (!isSuccess) {
+                        revertTryLockDatasetGranuleOperation(datasetId, entityHashValue, lockMode, entityInfo,
+                                txnContext);
+                    }
+                }
+            }
+
+            if (ALLOW_ESCALATE_FROM_ENTITY_TO_DATASET) {
+                if (!isInstant) {
                     if (doEscalate) {
-                        //This exception is thrown when the threshold value is set to 1.
-                        //We don't want to allow the lock escalation when there is a first lock request on a dataset. 
-                        throw new IllegalStateException("ESCALATE_TRHESHOLD_ENTITY_TO_DATASET should not be set to "
-                                + ESCALATE_TRHESHOLD_ENTITY_TO_DATASET);
+                        //jobInfo must not be null.
+                        assert jobInfo != null;
+                        jobInfo.increaseDatasetISLockCount(dId);
+                        //release pre-acquired locks
+                        releaseDatasetISLocks(jobInfo, jobId, datasetId, txnContext);
+                    } else if (datasetLockMode == LockMode.IS) {
+                        if (jobInfo == null) {
+                            jobInfo = jobHT.get(jobId);
+                            //jobInfo must not be null;
+                            assert jobInfo != null;
+                        }
+                        jobInfo.increaseDatasetISLockCount(dId);
                     }
                 }
             }
 
             if (IS_DEBUG_MODE) {
-                trackLockRequest("Granted", RequestType.TRY_LOCK, datasetId, entityHashValue, lockMode, txnContext,
-                        dLockInfo, eLockInfo);
+                if (isSuccess) {
+                    trackLockRequest("Granted", RequestType.TRY_LOCK, datasetId, entityHashValue, lockMode, txnContext,
+                            dLockInfo, eLockInfo);
+                } else {
+                    trackLockRequest("Failed", RequestType.TRY_LOCK, datasetId, entityHashValue, lockMode, txnContext,
+                            dLockInfo, eLockInfo);
+                }
             }
 
+        } finally {
             unlatchLockTable();
-            return true;
         }
 
-        //#. the datasetLockInfo exists in datasetResourceHT.
-        //1. handle dataset-granule lock
-        tryLockDatasetGranuleRevertOperation = 0;
-        entityInfo = tryLockDatasetGranule(datasetId, entityHashValue, lockMode, txnContext);
-        if (entityInfo == -2) {//-2 represents fail
-            isSuccess = false;
-        } else {
-            //2. handle entity-granule lock
-            if (entityHashValue != -1) {
-                isSuccess = tryLockEntityGranule(datasetId, entityHashValue, lockMode, entityInfo, txnContext);
-                if (!isSuccess) {
-                    revertTryLockDatasetGranuleOperation(datasetId, entityHashValue, lockMode, entityInfo, txnContext);
-                }
-            }
-        }
-
-        if (ALLOW_ESCALATE_FROM_ENTITY_TO_DATASET) {
-            if (!isInstant) {
-                if (doEscalate) {
-                    //jobInfo must not be null.
-                    assert jobInfo != null;
-                    jobInfo.increaseDatasetISLockCount(dId);
-                    //release pre-acquired locks
-                    releaseDatasetISLocks(jobInfo, jobId, datasetId, txnContext);
-                } else if (datasetLockMode == LockMode.IS) {
-                    if (jobInfo == null) {
-                        jobInfo = jobHT.get(jobId);
-                        //jobInfo must not be null;
-                        assert jobInfo != null;
-                    }
-                    jobInfo.increaseDatasetISLockCount(dId);
-                }
-            }
-        }
-
-        if (IS_DEBUG_MODE) {
-            if (isSuccess) {
-                trackLockRequest("Granted", RequestType.TRY_LOCK, datasetId, entityHashValue, lockMode, txnContext,
-                        dLockInfo, eLockInfo);
-            } else {
-                trackLockRequest("Failed", RequestType.TRY_LOCK, datasetId, entityHashValue, lockMode, txnContext,
-                        dLockInfo, eLockInfo);
-            }
-        }
-
-        unlatchLockTable();
-
         return isSuccess;
     }
 
@@ -1778,38 +1782,38 @@
 
             latchWaitNotify();
             unlatchLockTable();
-            synchronized (waiter) {
-                unlatchWaitNotify();
-                while (waiter.needWait()) {
-                    try {
-                        if (IS_DEBUG_MODE) {
-                            System.out.println("" + Thread.currentThread().getName() + "\twaits("
-                                    + waiter.getWaiterCount() + "): WID(" + waiterId + "),EID("
-                                    + waiter.getEntityInfoSlot() + ")");
+            try {
+                synchronized (waiter) {
+                    unlatchWaitNotify();
+                    while (waiter.needWait()) {
+                        try {
+                            if (IS_DEBUG_MODE) {
+                                System.out.println("" + Thread.currentThread().getName() + "\twaits("
+                                        + waiter.getWaiterCount() + "): WID(" + waiterId + "),EID("
+                                        + waiter.getEntityInfoSlot() + ")");
+                            }
+                            waiter.wait();
+                        } catch (InterruptedException e) {
+                            //TODO figure-out what is the appropriate way to handle this exception
+                            e.printStackTrace();
+                            isInterruptedExceptionOccurred = true;
+                            waiter.setWait(false);
                         }
-                        waiter.wait();
-                    } catch (InterruptedException e) {
-                        //TODO figure-out what is the appropriate way to handle this exception
-                        e.printStackTrace();
-                        isInterruptedExceptionOccurred = true;
-                        waiter.setWait(false);
                     }
                 }
-            }
 
-            if (isInterruptedExceptionOccurred) {
-                throw new ACIDException("InterruptedException is caught");
+                if (isInterruptedExceptionOccurred) {
+                    throw new ACIDException("InterruptedException is caught");
+                }
+            } catch (Exception e) {
+                throw new LockMgrLatchHandlerException(e);
             }
 
             //waiter woke up -> remove/deallocate waiter object and abort if timeout
             latchLockTable();
 
             if (txnContext.getStatus() == TransactionContext.TIMED_OUT_STATUS || waiter.isVictim()) {
-                try {
-                    requestAbort(txnContext);
-                } finally {
-                    unlatchLockTable();
-                }
+                requestAbort(txnContext);
             }
 
             if (waiter.isFirstGetUp()) {
@@ -1853,11 +1857,7 @@
                 //deallocate the entityInfo
                 entityInfoManager.deallocate(entityInfo);
             }
-            try {
-                requestAbort(txnContext);
-            } finally {
-                unlatchLockTable();
-            }
+            requestAbort(txnContext);
         }
 
         return waiterCount;
@@ -2028,20 +2028,22 @@
         LockWaiter waiterObj;
 
         latchLockTable();
+        try {
 
-        Iterator<Entry<JobId, JobInfo>> iter = jobHT.entrySet().iterator();
-        while (iter.hasNext()) {
-            Map.Entry<JobId, JobInfo> pair = (Map.Entry<JobId, JobInfo>) iter.next();
-            jobInfo = pair.getValue();
-            waiterObjId = jobInfo.getFirstWaitingResource();
-            while (waiterObjId != -1) {
-                waiterObj = lockWaiterManager.getLockWaiter(waiterObjId);
-                toutDetector.checkAndSetVictim(waiterObj);
-                waiterObjId = waiterObj.getNextWaiterObjId();
+            Iterator<Entry<JobId, JobInfo>> iter = jobHT.entrySet().iterator();
+            while (iter.hasNext()) {
+                Map.Entry<JobId, JobInfo> pair = (Map.Entry<JobId, JobInfo>) iter.next();
+                jobInfo = pair.getValue();
+                waiterObjId = jobInfo.getFirstWaitingResource();
+                while (waiterObjId != -1) {
+                    waiterObj = lockWaiterManager.getLockWaiter(waiterObjId);
+                    toutDetector.checkAndSetVictim(waiterObj);
+                    waiterObjId = waiterObj.getNextWaiterObjId();
+                }
             }
+        } finally {
+            unlatchLockTable();
         }
-
-        unlatchLockTable();
     }
 }
 
diff --git a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/locking/LockMgrLatchHandlerException.java b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/locking/LockMgrLatchHandlerException.java
new file mode 100644
index 0000000..05a582c
--- /dev/null
+++ b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/locking/LockMgrLatchHandlerException.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2012-2014 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.transaction.management.service.locking;
+
+import edu.uci.ics.asterix.transaction.management.exception.ACIDException;
+
+public class LockMgrLatchHandlerException extends ACIDException {
+
+    private static final long serialVersionUID = 1203182080428864199L;
+    private final Exception internalException;
+
+    public LockMgrLatchHandlerException(Exception e) {
+        super(e);
+        this.internalException = e;
+    }
+
+    public Exception getInternalException() {
+        return internalException;
+    }
+}
\ No newline at end of file
diff --git a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/logging/LogUtil.java b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/logging/LogUtil.java
index feaca86..77a99bc 100644
--- a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/logging/LogUtil.java
+++ b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/logging/LogUtil.java
@@ -47,6 +47,9 @@
                 List<String> logFiles = getLogFiles(logManagerProperties);
                 if (logFiles == null || logFiles.size() == 0) {
                     FileUtil.createFileIfNotExists(getLogFilePath(logManagerProperties, 0));
+                    if (LOGGER.isLoggable(Level.INFO)) {
+                        LOGGER.info("created a log file: " + getLogFilePath(logManagerProperties, 0));
+                    }
                 } else {
                     File logFile = new File(LogUtil.getLogFilePath(logManagerProperties,
                             Long.parseLong(logFiles.get(logFiles.size() - 1))));
@@ -55,7 +58,13 @@
                 }
             } else {
                 FileUtil.createNewDirectory(logManagerProperties.getLogDir());
+                if (LOGGER.isLoggable(Level.INFO)) {
+                    LOGGER.info("created the log directory: " + logManagerProperties.getLogDir());
+                }
                 FileUtil.createFileIfNotExists(getLogFilePath(logManagerProperties, 0));
+                if (LOGGER.isLoggable(Level.INFO)) {
+                    LOGGER.info("created a log file: " + getLogFilePath(logManagerProperties, 0));
+                }
             }
         } catch (IOException ioe) {
             throw new ACIDException("Unable to initialize log anchor", ioe);
diff --git a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/recovery/RecoveryManager.java b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/recovery/RecoveryManager.java
index c27ae20..47c5dcb 100644
--- a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/recovery/RecoveryManager.java
+++ b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/recovery/RecoveryManager.java
@@ -116,6 +116,9 @@
             //This is initial bootstrap. 
             //Otherwise, the checkpoint file is deleted unfortunately. What we can do in this case?
             state = SystemState.NEW_UNIVERSE;
+            if (LOGGER.isLoggable(Level.INFO)) {
+                LOGGER.info("The checkpoint file doesn't exist: systemState = NEW_UNIVERSE");
+            }
             return state;
         }
 
@@ -392,7 +395,7 @@
         }
 
         if (LOGGER.isLoggable(Level.INFO)) {
-            LOGGER.info("[RecoveryMgr] recovery is over");
+            LOGGER.info("[RecoveryMgr] recovery is completed.");
         }
         if (IS_DEBUG_MODE) {
             System.out.println("[RecoveryMgr] Count: Update/Commit/Redo = " + updateLogCount + "/" + commitLogCount
@@ -422,6 +425,10 @@
     @Override
     public synchronized void checkpoint(boolean isSharpCheckpoint) throws ACIDException {
 
+        if (isSharpCheckpoint && LOGGER.isLoggable(Level.INFO)) {
+            LOGGER.info("Starting sharp checkpoint ... ");
+        }
+        
         LogManager logMgr = (LogManager) txnSubsystem.getLogManager();
         TransactionManager txnMgr = (TransactionManager) txnSubsystem.getTransactionManager();
         String logDir = logMgr.getLogManagerProperties().getLogDir();
@@ -513,6 +520,10 @@
         if (isSharpCheckpoint) {
             logMgr.renewLogFiles();
         }
+        
+        if (isSharpCheckpoint && LOGGER.isLoggable(Level.INFO)) {
+            LOGGER.info("Completed sharp checkpoint.");
+        }
     }
 
     private CheckpointObject readCheckpoint() throws ACIDException, FileNotFoundException {
diff --git a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/transaction/DatasetIdFactory.java b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/transaction/DatasetIdFactory.java
index 65512ec..17eaf38 100644
--- a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/transaction/DatasetIdFactory.java
+++ b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/transaction/DatasetIdFactory.java
@@ -4,12 +4,22 @@
 
 public class DatasetIdFactory {
     private static AtomicInteger id = new AtomicInteger();
+    private static boolean isInitialized = false; 
+    
+    public static boolean isInitialized() {
+        return isInitialized;
+    }
     
     public static void initialize(int initialId) {
     	id.set(initialId);
+    	isInitialized = true;
     }
 
     public static int generateDatasetId() {
         return id.incrementAndGet();
     }
+    
+    public static int getMostRecentDatasetId() {
+        return id.get();
+    }
 }
\ No newline at end of file
diff --git a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/transaction/TransactionManagementConstants.java b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/transaction/TransactionManagementConstants.java
index 3d25e54..7d04f61 100644
--- a/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/transaction/TransactionManagementConstants.java
+++ b/asterix-transactions/src/main/java/edu/uci/ics/asterix/transaction/management/service/transaction/TransactionManagementConstants.java
@@ -29,7 +29,6 @@
         public static final String LOG_CONF_DIR = "log_conf";
         public static final String LOG_CONF_FILE = "log.properties";
         public static final String ASTERIX_CONF_DIR = "src/main/resources";
-        public static final String ASTERIX_CONF_FILE = "test.properties";
         public static final String DEFAULT_LOG_DIR = "asterix_logs";
         public static final int TERMINAL_LSN = -1;
     }
diff --git a/pom.xml b/pom.xml
index b424195..20efdb3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,12 +3,12 @@
 	<modelVersion>4.0.0</modelVersion>
 	<groupId>edu.uci.ics.asterix</groupId>
 	<artifactId>asterix</artifactId>
-	<version>0.0.5-SNAPSHOT</version>
+	<version>0.0.6-SNAPSHOT</version>
 	<packaging>pom</packaging>
 
     <properties>
-    	<algebricks.version>0.2.5-SNAPSHOT</algebricks.version>
-    	<hyracks.version>0.2.5-SNAPSHOT</hyracks.version>
+    	<algebricks.version>0.2.6-SNAPSHOT</algebricks.version>
+    	<hyracks.version>0.2.6-SNAPSHOT</hyracks.version>
     </properties>
 
 	<build>
@@ -25,8 +25,8 @@
 	</build>
 
 	<scm>
-		<connection>scm:svn:https://asterixdb.googlecode.com/svn/trunk/asterix</connection>
-		<developerConnection>scm:svn:https://asterixdb.googlecode.com/svn/trunk/asterix</developerConnection>
+		<connection>scm:git:https://code.google.com/p/asterixdb/</connection>
+		<developerConnection>scm:git:https://code.google.com/p/asterixdb/</developerConnection>
 	</scm>
 
 	<distributionManagement>