diff --git a/asterix-examples/src/main/resources/black-cherry/static/js/cherry.js b/asterix-examples/src/main/resources/black-cherry/static/js/cherry.js
index aa7a3d1..b187d38 100755
--- a/asterix-examples/src/main/resources/black-cherry/static/js/cherry.js
+++ b/asterix-examples/src/main/resources/black-cherry/static/js/cherry.js
@@ -530,29 +530,39 @@
     var minWeight = Number.MAX_VALUE;
 
     // Parse resulting JSON objects. Here is an example record:
-    // { "cell": { rectangle: [{ point: [22.5, 64.5]}, { point: [24.5, 66.5]}]}, "count": { int64: 5 }}
+    // { "cell": rectangle("21.5,-98.5 24.5,-95.5"), "count": 78i64 }
     $.each(res.results, function(i, data) {
-        
-        // First, parse a JSON object from a cleaned up string.
-        var record = $.parseJSON(cleanJSON(data));
-        
-        // Parse Coordinates and Weights into a record
-        var sw = record.cell.rectangle[0].point;
-        var ne = record.cell.rectangle[1].point;
-                
+
+        // We need to clean the JSON a bit to parse it properly in javascript
+        var cleanRecord = $.parseJSON(data
+                            .replace('rectangle(', '')
+                            .replace(')', '')
+                            .replace('i64', ''));
+
+        var recordCount = cleanRecord["count"];
+        var rectangle = cleanRecord["cell"]
+                            .replace(' ', ',')
+                            .split(',')
+                            .map( parseFloat );
+
+        // Now, using the record count and coordinates, we can create a 
+        // coordinate system for this spatial cell.
         var coordinate = {
-            "latSW"     : sw[0],
-            "lngSW"     : sw[1],
-            "latNE"     : ne[0],
-            "lngNE"     : ne[1],
-            "weight"    : record.count.int64
-        }
+            "latSW"     : rectangle[0],
+            "lngSW"     : rectangle[1],
+            "latNE"     : rectangle[2],
+            "lngNE"     : rectangle[3],
+            "weight"    : recordCount
+        };
         
+        // We track the minimum and maximum weight to support our legend.
         maxWeight = Math.max(coordinate["weight"], maxWeight);
         minWeight = Math.min(coordinate["weight"], minWeight);
+
+        // Save completed coordinate and move to next one.
         coordinates.push(coordinate);
     });
-    
+
     triggerUIUpdate(coordinates, maxWeight, minWeight);
 }
 
@@ -877,8 +887,8 @@
         .ReturnClause({
             "tweetId" : "$m.tweetid",
             "tweetText" : "$t.message-text",
-            "tweetLoc" : "$t.sender-location",
-            "tweetCom" : "$m.comment-text"
+            "tweetCom" : "$m.comment-text",
+            "tweetLoc" : "$t.sender-location"
         });
           
     APIqueryTracker = {
@@ -894,44 +904,46 @@
 
     // Parse out tweet Ids, texts, and locations
     var tweets = [];
-    al = 1;
+    var al = 1;
+
     $.each(res.results, function(i, data) {
 
-        var json = $.parseJSON(cleanJSON(data));
+        // First, clean up the data
+        //{ "tweetId": "100293", "tweetText": " like at&t the touch-screen is amazing", "tweetLoc": point("31.59,-84.23") }
+        // We need to turn the point object at the end into a string
+        var json = $.parseJSON(data
+                                .replace(': point(',': ')
+                                .replace(') }', ' }'));
 
+        // Now, we construct a tweet object
         var tweetData = {
-            "tweetEntryId" : json["tweetId"],
-            "tweetText" : json["tweetText"],
-            "tweetLat" : json["tweetLoc"]["point"][0],
-            "tweetLng" : json["tweetLoc"]["point"][1]
+            "tweetEntryId" : parseInt(json.tweetId),
+            "tweetText" : json.tweetText,
+            "tweetLat" : json.tweetLoc.split(",")[0],
+            "tweetLng" : json.tweetLoc.split(",")[1]
         };
 
         // If we are parsing out tweetbook data with comments, we need to check
         // for those here as well.
         if (json.hasOwnProperty("tweetCom")) {
-            tweetData["tweetComment"] = json["tweetCom"];
+            tweetData["tweetComment"] = json.tweetCom;
         }
 
         tweets.push(tweetData)
     });
 
-    // Prepare to map the tweets
-    var micon = APIqueryTracker["marker_path"];
-    APIqueryTracker["markers_data"] = [];
-
     // Create a marker for each tweet
     $.each(tweets, function(i, t) {
         // Create a phone marker at tweet's position
         var map_tweet_m = new google.maps.Marker({
             position: new google.maps.LatLng(tweets[i]["tweetLat"], tweets[i]["tweetLng"]),
             map: map,
-            icon: micon,
+            icon: APIqueryTracker["marker_path"],
             clickable: true,
         });
         map_tweet_m["test"] = t;
 
         // Open Tweet exploration window on click
-        APIqueryTracker["markers_data"].push(tweets[i]);
         google.maps.event.addListener(map_tweet_m, 'click', function (event) {
             onClickTweetbookMapMarker(map_tweet_markers[i]["test"]);
         });
