void addDeviceObservers(TSDevice tsDevice,
			Vector<TsapiCallMonitor> _terminalObservers,
			Vector<TsapiCallMonitor> _addressObservers,
			Vector<TsapiCallMonitor> _cvdObservers, boolean sendSnapshotEvents) {
		TsapiCallMonitor callback = null;

		boolean found = false;

		CSTAConnectionID snapConnID = null;
		synchronized (this.connections) {
			if (this.connections.size() > 0) {
				try {
					snapConnID = ((TSConnection) this.connections.elementAt(0))
							.getConnID();
				} catch (TsapiPlatformException e) {
					log.error("Ignoring exception: " + e);
					if (this.callID != 0) {
						snapConnID = new CSTAConnectionID(this.callID, "",
								(short) 0);
					}
				}
			} else if (this.callID != 0) {
				snapConnID = new CSTAConnectionID(this.callID, "", (short) 0);
			}
		}

		if (_cvdObservers != null) {
			Vector<TsapiCallMonitor> cvdObservers = new Vector<TsapiCallMonitor>(_cvdObservers);
			for (int i = 0; i < cvdObservers.size(); i++) {
				found = false;
				callback = (TsapiCallMonitor) cvdObservers.elementAt(i);
				synchronized (this.monitorThreads) {
					if (this.monitorThreads.contains(callback)) {
						found = true;
					}

					if (!found) {
						synchronized (this.staleObsVector) {
							for (int j = 0; j < this.staleObsVector.size(); j++) {
								if (this.staleObsVector.elementAt(j) == callback) {
									this.monitorThreads.addElement(callback);
									this.staleObsVector.removeElementAt(j);

									found = true;
									break;
								}
							}
						}
						if (!found) {
							synchronized (this.deviceObsVector) {
								for (int j = 0; j < this.deviceObsVector.size(); j++) {
									if (((DeviceObs) this.deviceObsVector
											.elementAt(j)).callback == callback) {
										this.monitorThreads
												.addElement(callback);
										this.deviceObsVector.removeElementAt(j);

										found = true;
										break;
									}
								}
							}
						}
					}

					if ((!found)
							&& ((snapConnID == null) || (!sendSnapshotEvents))) {
						this.monitorThreads.addElement(callback);
						callback.addReference();
						if (sendSnapshotEvents)
							sendSnapshot(callback, null, false);
					}
				}
				if ((!found) && (snapConnID != null) && (sendSnapshotEvents)) {
					this.callbackAndTypeVector.addElement(new CallbackAndType(
							callback, null));
				}
			}
		}

		DeviceObs devObs = null;
		DevWithType devWithType = null;

		if (_addressObservers != null) {
			found = false;

			devWithType = new DevWithType(tsDevice, false);

			Vector<TsapiCallMonitor> addressObservers = new Vector<TsapiCallMonitor>(_addressObservers);

			for (int i = 0; i < addressObservers.size(); i++) {
				callback = (TsapiCallMonitor) addressObservers.elementAt(i);
				found = false;
				if (this.monitorThreads.contains(callback)) {
					found = true;
				}

				if (!found) {
					synchronized (this.deviceObsVector) {
						synchronized (this.staleObsVector) {
							for (int j = 0; j < this.staleObsVector.size(); j++) {
								if (this.staleObsVector.elementAt(j) == callback) {
									found = true;
									devObs = new DeviceObs(callback);
									devObs.devWithTypeVector
											.addElement(devWithType);

									this.deviceObsVector.addElement(devObs);
									this.staleObsVector.removeElementAt(j);
									break;
								}
							}
						}
						if (!found) {
							for (int j = 0; j < this.deviceObsVector.size(); j++) {
								devObs = (DeviceObs) this.deviceObsVector
										.elementAt(j);
								if (devObs.callback == callback) {
									found = true;
									synchronized (devObs.devWithTypeVector) {
										if (!devObs.devWithTypeVector
												.contains(devWithType)) {
											devObs.devWithTypeVector
													.addElement(devWithType);
										}
									}
									break;
								}
							}
							if ((!found)
									&& ((snapConnID == null) || (!sendSnapshotEvents))) {
								devObs = new DeviceObs(callback);
								devObs.devWithTypeVector
										.addElement(devWithType);
								this.deviceObsVector.addElement(devObs);
								callback.addReference();
								if (sendSnapshotEvents)
									sendSnapshot(callback, null, false);
							}
						}
					}
				}
				if ((!found) && (snapConnID != null) && (sendSnapshotEvents)) {
					this.callbackAndTypeVector.addElement(new CallbackAndType(
							callback, devWithType));
				}
			}
		}
		if (_terminalObservers != null) {
			found = false;

			devWithType = new DevWithType(tsDevice, true);

			Vector<TsapiCallMonitor> terminalObservers = new Vector<TsapiCallMonitor>(_terminalObservers);

			for (int i = 0; i < terminalObservers.size(); i++) {
				callback = (TsapiCallMonitor) terminalObservers.elementAt(i);
				found = false;
				if (this.monitorThreads.contains(callback)) {
					found = true;
				}
				if (!found) {
					synchronized (this.deviceObsVector) {
						synchronized (this.staleObsVector) {
							for (int j = 0; j < this.staleObsVector.size(); j++) {
								if (this.staleObsVector.elementAt(j) == callback) {
									found = true;
									devObs = new DeviceObs(callback);
									devObs.devWithTypeVector
											.addElement(devWithType);

									this.deviceObsVector.addElement(devObs);
									this.staleObsVector.removeElementAt(j);
									break;
								}
							}
						}
						if (!found) {
							for (int j = 0; j < this.deviceObsVector.size(); j++) {
								devObs = (DeviceObs) this.deviceObsVector
										.elementAt(j);
								if (devObs.callback == callback) {
									found = true;
									synchronized (devObs.devWithTypeVector) {
										if (!devObs.devWithTypeVector
												.contains(devWithType)) {
											devObs.devWithTypeVector
													.addElement(devWithType);
										}
									}
									break;
								}
							}
							if ((!found)
									&& ((snapConnID == null) || (!sendSnapshotEvents))) {
								devObs = new DeviceObs(callback);
								devObs.devWithTypeVector
										.addElement(devWithType);
								this.deviceObsVector.addElement(devObs);
								callback.addReference();
								if (sendSnapshotEvents)
									sendSnapshot(callback, null, false);
							}
						}
					}
				}
				if ((!found) && (snapConnID != null) && (sendSnapshotEvents)) {
					this.callbackAndTypeVector.addElement(new CallbackAndType(
							callback, devWithType));
				}
			}
		}
	}