public static void readTruthMaintenanceSystem(
      MarshallerReaderContext context,
      SessionEntryPoint wmep,
      ProtobufMessages.EntryPoint _ep,
      List<PropagationContextImpl> pctxs)
      throws IOException, ClassNotFoundException {
    TruthMaintenanceSystem tms = ((NamedEntryPoint) wmep).getTruthMaintenanceSystem();

    ProtobufMessages.TruthMaintenanceSystem _tms = _ep.getTms();

    for (ProtobufMessages.EqualityKey _key : _tms.getKeyList()) {
      InternalFactHandle handle = (InternalFactHandle) context.handles.get(_key.getHandleId());

      // ObjectTypeConf state is not marshalled, so it needs to be re-determined
      ObjectTypeConf typeConf =
          context
              .wm
              .getObjectTypeConfigurationRegistry()
              .getObjectTypeConf(
                  ((NamedEntryPoint) handle.getEntryPoint()).getEntryPoint(), handle.getObject());
      if (!typeConf.isTMSEnabled()) {
        typeConf.enableTMS();
      }

      EqualityKey key = new EqualityKey(handle, _key.getStatus());
      handle.setEqualityKey(key);

      if (key.getStatus() == EqualityKey.JUSTIFIED) {
        // not yet added to the object stores
        ((NamedEntryPoint) handle.getEntryPoint())
            .getObjectStore()
            .addHandle(handle, handle.getObject());
        // add handle to object type node
        assertHandleIntoOTN(context, context.wm, handle, pctxs);
      }

      for (Integer factHandleId : _key.getOtherHandleList()) {
        handle = (InternalFactHandle) context.handles.get(factHandleId.intValue());
        key.addFactHandle(handle);
        handle.setEqualityKey(key);
      }
      tms.put(key);

      readBeliefSet(context, tms, key, _key.getBeliefSet());
    }
  }