Added debugging logging messages.
diff --git a/asterix-common/src/main/java/edu/uci/ics/asterix/common/context/DatasetLifecycleManager.java b/asterix-common/src/main/java/edu/uci/ics/asterix/common/context/DatasetLifecycleManager.java
index 90fcf87..7e55534 100644
--- a/asterix-common/src/main/java/edu/uci/ics/asterix/common/context/DatasetLifecycleManager.java
+++ b/asterix-common/src/main/java/edu/uci/ics/asterix/common/context/DatasetLifecycleManager.java
@@ -23,6 +23,8 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 
 import edu.uci.ics.asterix.common.api.ILocalResourceMetadata;
 import edu.uci.ics.asterix.common.config.AsterixStorageProperties;
@@ -50,6 +52,7 @@
     private final ILocalResourceRepository resourceRepository;
     private final long capacity;
     private long used;
+    private static final Logger LOGGER = Logger.getLogger(DatasetLifecycleManager.class.getName());
 
     public DatasetLifecycleManager(AsterixStorageProperties storageProperties,
             ILocalResourceRepository resourceRepository) {
@@ -108,7 +111,8 @@
 
         PrimaryIndexOperationTracker opTracker = (PrimaryIndexOperationTracker) datasetOpTrackers.get(dsInfo.datasetID);
         if (iInfo.referenceCount != 0 || (opTracker != null && opTracker.getNumActiveOperations() != 0)) {
-            throw new HyracksDataException("Cannot remove index while it is open.");
+            throw new HyracksDataException("Cannot remove index while it is open. Reference Count: "
+                    + iInfo.referenceCount + " Number of Active Operations: " + opTracker.getNumActiveOperations());
         }
 
         // TODO: use fine-grained counters, one for each index instead of a single counter per dataset.
@@ -445,6 +449,9 @@
 
     @Override
     public void stop(boolean dumpState, OutputStream outputStream) throws IOException {
+        if (LOGGER.isLoggable(Level.INFO)) {
+            LOGGER.info("Stopping DatasetLifecycleManager ...");
+        }
         if (dumpState) {
             dumpState(outputStream);
         }
diff --git a/asterix-common/src/main/java/edu/uci/ics/asterix/common/context/PrimaryIndexOperationTracker.java b/asterix-common/src/main/java/edu/uci/ics/asterix/common/context/PrimaryIndexOperationTracker.java
index 6a80c5c..62f2dec 100644
--- a/asterix-common/src/main/java/edu/uci/ics/asterix/common/context/PrimaryIndexOperationTracker.java
+++ b/asterix-common/src/main/java/edu/uci/ics/asterix/common/context/PrimaryIndexOperationTracker.java
@@ -63,6 +63,10 @@
             IModificationOperationCallback modificationCallback) throws HyracksDataException {
         if (opType == LSMOperationType.MODIFICATION || opType == LSMOperationType.FORCE_MODIFICATION) {
             numActiveOperations.decrementAndGet();
+            if (numActiveOperations.get() < 0) {
+                throw new HyracksDataException("Somethingis wrong, numActiveOperations cannot be negative: "
+                        + numActiveOperations.get());
+            }
         } else if (opType == LSMOperationType.FLUSH || opType == LSMOperationType.MERGE) {
             datasetLifecycleManager.undeclareActiveIOOperation(datasetID);
         }
@@ -77,7 +81,7 @@
         // If we need a flush, and this is the last completing operation, then schedule the flush. 
         boolean needsFlush = false;
         for (ILSMIndex lsmIndex : indexes) {
-            if (((ILSMIndexInternal)lsmIndex).hasFlushRequestForCurrentMutableComponent()) {
+            if (((ILSMIndexInternal) lsmIndex).hasFlushRequestForCurrentMutableComponent()) {
                 needsFlush = true;
                 break;
             }