Index: kernel/include/IMP/Key.h
===================================================================
--- kernel/include/IMP/Key.h	(revision 681)
+++ kernel/include/IMP/Key.h	(working copy)
@@ -83,14 +83,21 @@
   KeyData();
   void assert_is_initialized() const;
   unsigned int add_key(std::string str) {
+    assert_is_initialized();
     unsigned int i= map_.size();
     map_[str]=i;
     rmap_.push_back(str);
     return i;
   }
 
-  const Map &get_map() const {return map_;}
-  const RMap &get_rmap() const {return rmap_;}
+  const Map &get_map() const {
+    assert_is_initialized();
+    return map_;
+  }
+  const RMap &get_rmap() const {
+    assert_is_initialized();
+    return rmap_;
+  }
 
 private:
   double heuristic_;
@@ -239,7 +246,7 @@
 
 template <int ID>
 inline void KeyBase<ID>::show_all(std::ostream &out)
-{
+{  
   internal::key_data[ID].show(out);
 }
 
Index: kernel/src/Key.cpp
===================================================================
--- kernel/src/Key.cpp	(revision 681)
+++ kernel/src/Key.cpp	(working copy)
@@ -22,6 +22,9 @@
 {
   IMP_assert(heuristic_== heuristic_value,
              "Uninitialized KeyData. Do not initialize Keys statically.");
+  IMP_assert(key_data.size() > 0 && key_data.size() < 50,
+             "Something wrong with the key_data table. Size is " << 
+             key_data.size());
 }
 
 void KeyData::show(std::ostream &out) const