diff --git a/planetstack/hpc_wizard/bigquery_analytics.py b/planetstack/hpc_wizard/bigquery_analytics.py
index 29b8c28..f50a9ac 100644
--- a/planetstack/hpc_wizard/bigquery_analytics.py
+++ b/planetstack/hpc_wizard/bigquery_analytics.py
@@ -36,12 +36,22 @@
 MINUTE_MS = 60*1000
 HOUR_MS = 60*60*1000
 
+# global to hold cached mappings
+mappings = {}
+reverse_mappings = {}
+
+class MappingException(Exception):
+    pass
+
 class BigQueryAnalytics:
     def __init__(self, table = "demoevents"):
         self.projectName = "vicci"
         self.tableName = table
-        self.mapping = json.loads(self.fetch_mapping(table=self.tableName))
-        self.reverse_mapping = {v:k for k, v in self.mapping.items()}
+
+    def reload_mapping(self):
+        global mappings, reverse_mappings
+        mappings[self.tableName] = json.loads(self.fetch_mapping(table=self.tableName))
+        reverse_mappings[self.tableName] = {v:k for k, v in mappings[self.tableName].items()}
 
     def fetch_mapping(self, m=0, table="events"):
 	req = 'http://cloud-scrutiny.appspot.com/command?action=get_allocations&multiplexer=%d&table=%s'% (m,table)
@@ -53,7 +63,12 @@
 
     def run_query_raw(self, query):
         p = re.compile('%[a-zA-z_]*')
-        query = p.sub(self.remap, query)
+
+        try:
+            query = p.sub(self.remap, query)
+        except MappingException:
+            self.reload_mapping()
+            query = p.sub(self.remap, query)
 
 	storage = Storage('/opt/planetstack/hpc_wizard/bigquery_credentials.dat')
  	credentials = storage.get()
@@ -74,7 +89,7 @@
 
     def translate_schema(self, response):
         for field in response["schema"]["fields"]:
-            field["name"] = self.reverse_mapping.get(field["name"], field["name"])
+            field["name"] = reverse_mappings[self.tableName].get(field["name"], field["name"])
 
     def run_query(self, query):
         response = self.run_query_raw(query)
@@ -88,17 +103,22 @@
             for row in response["rows"]:
                 this_result = {}
                 for (i,column) in enumerate(row["f"]):
-                    this_result[self.reverse_mapping.get(fieldNames[i],fieldNames[i])] = column["v"]
+                    this_result[reverse_mappings[self.tableName].get(fieldNames[i],fieldNames[i])] = column["v"]
                 result.append(this_result)
 
         return result
 
     def remap(self, match):
+        if not self.tableName in mappings:
+            raise MappingException("no mapping for table %s" % self.tableName)
+
+        mapping = mappings[self.tableName]
+
         token = match.group()[1:]
-        if token in self.mapping:
-            return self.mapping[token]
+        if token in mapping:
+            return mapping[token]
         else:
-            raise Exception('unknown token %s' % token)
+            raise MappingException('unknown token %s' % token)
 
     def dump_table(self, rows, keys=None):
         if not keys:
@@ -122,6 +142,22 @@
                 print "%*s" % (lens[key], str(row.get(key,""))),
             print
 
+    def schema_to_cols(self, schema):
+        fields = schema["fields"]
+
+        colTypes = {"STRING": "string", "INTEGER": "number", "FLOAT": "number", "TIMESTAMP": "date"}
+
+        cols = []
+        i=0
+        for field in fields:
+            col = {"type": colTypes[field["type"]],
+                   "id": "Col%d" % i,
+                   "label": reverse_mappings[self.tableName].get(field["name"],field["name"])}
+            cols.append(col)
+            i=i+1
+
+        return cols
+
 def main():
     bq = BigQueryAnalytics()
 
