	boolean found = false;
							ListTerm annots = null;
							Literal toBeRemoved = null;
							if (it!= null){
								while (!found && it.hasNext()){
									toBeRemoved = it.next();
									annots = toBeRemoved.getAnnots("obs_prop_id");
									if (! annots.isEmpty()){
										for (Term annot: annots){
											StringTerm st = (StringTerm)((((Structure)annot).getTerm(0)));
											if (st.getString().equals(propId)){
												found = true;
												break;
											}
										}
									}
								}
							}
							if (found){
								try {
									boolean removed = true;
									if (annots.size() == 1){ 
										// it was the only one
										removed = a.getBB().remove(toBeRemoved);
									} else {
										ArtifactId source = ev.getArtifactId();
										Iterator<Term> it2 = toBeRemoved.getAnnots().iterator();
										while (it2.hasNext()){
											Term t = it2.next();
											if (t.isStructure()){
												Structure st = (Structure)t;
												if (st.getFunctor().equals("obs_prop_id")){
													/*
													Object artId = lib.termToObject(st.getTerm(0),lib);
													if (artId!= null && artId.equals(source)){
														it2.remove();
													}*/
													StringTerm sst = (StringTerm)((((Structure)st).getTerm(0)));
													if (sst.getString().equals(propId)){
														it2.remove();
													}
												} else if (st.getArity() > 0){
													Object artId = lib.termToObject(((Structure)st).getTerm(0));
													if (artId!= null && artId.equals(source)){
														it2.remove();
													}
												}  
											}
										}
									}
									if (removed){
										Literal l1 = toBeRemoved.copy();
										Trigger te = new Trigger(TEOperator.del, TEType.belief, l1);
										getTS().updateEvents(new Event(te, Intention.EmptyInt));
										logger.info("AGENT: "+getTS().getUserAgArch().getAgName()+" REMOVED BELIEF FOR OBS PROP: "+l1);
									} else {
										logger.warning("AGENT: "+getTS().getUserAgArch().getAgName()+" OBS PROP NOT FOUND when removing: "+propName);
									}
								} catch (Exception ex){
									logger.warning("EXCEPTION - processing remove obs prop "+ev+" for agent "+getTS().getUserAgArch().getAgName());
								}
							}
						}
					}


				}
			}		
		} catch (Exception ex){
			ex.printStackTrace();
			logger.severe("Exception in fetching events from the context.");
		}
		/*
		 * THE METHOD MUST RETURN NULL:
		 * since the percept semantics is different (event vs. state),
		 * all the the percepts from the env must be managed here, not by the BUF
		 */
		return null;
	}

	/*
	private String getPropUniqueId(ArtifactId source, ArtifactObsProperty prop){
		return "obs_id_"+source.getId()+"_"+prop.getId();		
	}*/
			
	private void addObsPropertiesBel(ArtifactId source, List<ArtifactObsProperty> props){
		Literal l = null;
		Agent a = getTS().getAg();
		for (ArtifactObsProperty p: props){
			String propName = p.getName();
			String propId = p.getFullId();
			try {
				Iterator<Literal> it = a.getBB().getCandidateBeliefs(new PredicateIndicator(propName,p.getValues().length));
				boolean found = false;
				if (it!= null){
					Literal lold = null;
					while (!found && it.hasNext()){
						lold = it.next();
						ListTerm annots = lold.getAnnots("obs_prop_id");
						if (! annots.isEmpty()){
							for (Term annot: annots){
								StringTerm st = (StringTerm)((((Structure)annot).getTerm(0)));
								if (st.getString().equals(propId)){
									found = true;
									break;
								}
								/*
								Object artId = lib.termToObject(((Structure)annot).getTerm(0),lib);
								if (artId!= null && artId.equals(source)){
									found = true;
									break;
								}
								*/
							}
						}
					}
				}
				if (!found){
					l = obsPropToLiteral(propId, source, p.getName(), p.getValues(), lib);
					if (a.getBB().add(l)){
						Literal l1 = l.copy();
						Trigger te = new Trigger(TEOperator.add, TEType.belief, l1);
						getTS().updateEvents(new Event(te, Intention.EmptyInt));
						logger.info("AGENT: "+getTS().getUserAgArch().getAgName()+" NEW BELIEF FOR OBS PROP: "+l1);
					}
				}
			} catch (Exception ex){
				//ex.printStackTrace();
				logger.warning("EXCEPTION - processing new obs prop "+p+" artifact "+source+" for agent "+getTS().getUserAgArch().getAgName());
			}
		}
	}

	private void removeObsPropertiesBel(ArtifactId source, List<ArtifactObsProperty> props){
		logger.info("REMOVING PROPS "+props.size());
		Agent a = getTS().getAg();
		for (ArtifactObsProperty p: props){
			String propName = p.getName();
			String propId = p.getFullId();
			logger.info("REMOVING "+propName+" "+propId);
			try {
				Iterator<Literal> it = a.getBB().getCandidateBeliefs(new PredicateIndicator(propName,p.getValues().length));
				Literal toBeRemoved = null;
				ListTerm annots = null;
				if (it!= null){
		 			Literal lold = null;
					while (toBeRemoved == null && it.hasNext()){
						lold = it.next();
						annots = lold.getAnnots("obs_prop_id");
						if (! annots.isEmpty()){
							for (Term annot: annots){
								StringTerm st = (StringTerm)((((Structure)annot).getTerm(0)));
								if (st.getString().equals(propId)){
									toBeRemoved = lold;
									break;
								}
							}
						}
					}
				}
				if (toBeRemoved!=null){
					Literal removedLit = toBeRemoved.copy().forceFullLiteralImpl();
					if (annots.size() == 1){ 
						// it was the only one
						a.getBB().remove(toBeRemoved);
					} else {
						Iterator<Term> it2 = toBeRemoved.getAnnots().iterator();
						removedLit.clearAnnots();
						while (it2.hasNext()){
							Term t = it2.next();
							if (t.isStructure()){
								Structure st = (Structure)t;
								if (st.getFunctor().equals("obs_prop_id")){
									StringTerm sst = (StringTerm)((((Structure)st).getTerm(0)));
									if (sst.getString().equals(propId)){
										it2.remove();
										removedLit.addAnnot(t);
									}
								} else if (st.getArity() > 0){
									Object artId = lib.termToObject(((Structure)st).getTerm(0));
									if (artId!= null && artId.equals(source)){
										it2.remove();
										removedLit.addAnnot(t);
									}
								} 
							}
						}
					}
					Trigger te = new Trigger(TEOperator.del, TEType.belief, removedLit);
					getTS().updateEvents(new Event(te, Intention.EmptyInt));
					logger.info("AGENT: "+getTS().getUserAgArch().getAgName()+" REMOVED BELIEF FOR OBS PROP: "+removedLit+" "+rem