public void removeMarkedAtoms(List<Integer> list) {

		if (selectedComponent != null) {
			selectedComponent.setSelected(false);
			selectedComponent = null;
		}

		if (atomBufferArray == null)
			atomBufferArray = new Atom[MolecularModel.getMaximumNumberOfAtoms()];
		// pasteBuffer=null;
		// if deleted atoms is a single atom or a whole molecule, set the paste buffer in the subsquent action

		liveAtomMap.clear();
		deadAtomMap.clear();
		deadLayered.clear();
		int temp = 0, temq = 0, ii = 0;
		for (int i = 0; i < nAtom; i++) {
			if (!list.contains(i)) {
				int nMeasure = atom[i].getNumberOfMeasurements();
				if (nMeasure > 0) {
					Object measure;
					for (int nm = 0; nm < nMeasure; nm++) {
						measure = atom[i].getMeasurement(nm);
						if (measure instanceof Integer && list.contains(measure)) {
							atom[i].removeMeasurement(nm);
						}
					}
				}
				if (atomBufferArray[temp] == null) {
					atomBufferArray[temp] = new Atom(model.getElement(Element.ID_NT));
					atomBufferArray[temp].setModel(model);
					atomBufferArray[temp].setIndex(temp);
				}
				atomBufferArray[temp].set(atom[i]);
				atomBufferArray[temp].setSelected(atom[i].isSelected());
				atomBufferArray[temp].setUserField(atom[i].getUserField());
				List<Layered> l = getLayeredComponentHostedBy(atom[i]);
				if (l != null) {
					for (Layered c : l)
						c.setHost(atomBufferArray[temp]);
				}
				// map the old indices of the surviving atoms to the new ones
				liveAtomMap.put(i, temp);
				temp++;
			} else {
				List<Layered> l = getLayeredComponentHostedBy(atom[i]);
				if (l != null) {
					for (Layered c : l) {
						c.setHost(null);
						layerBasket.remove(c); // WHAT IS THE IMPACT of this??
					}
				}
				ii = atom.length - 1 - temq;
				if (atomBufferArray[ii] == null) {
					atomBufferArray[ii] = new Atom(model.getElement(Element.ID_NT));
					atomBufferArray[ii].setModel(model);
					atomBufferArray[ii].setIndex(ii);
				}
				atomBufferArray[ii].set(atom[i]);
				atomBufferArray[ii].setUserField(atom[i].getUserField());
				atom[i].eraseProperties();
				// map the original indices of the dead atoms to those of their backups
				deadAtomMap.put(i, ii);
				if (l != null)
					deadLayered.put(atomBufferArray[ii], l);
				temq++;
			}
		}
		for (int i = temp; i < nAtom; i++)
			atom[i].erase();
		nAtom = temp;
		for (int i = 0; i < nAtom; i++) {
			atom[i].set(atomBufferArray[i]);
			atom[i].setSelected(atomBufferArray[i].isSelected());
			atom[i].setUserField(atomBufferArray[i].getUserField());
			List<Layered> l = getLayeredComponentHostedBy(atomBufferArray[i]);
			if (l != null) {
				for (Layered c : l)
					c.setHost(atom[i]);
			}
		}
		model.setNumberOfParticles(nAtom);
		model.computeForce(-1);

		deadBonds.clear();
		deadBends.clear();
		if (bonds.isEmpty())
			return;

		/* remove the associated radial bonds. */

		Set liveSet = liveAtomMap.keySet();
		Set deadSet = deadAtomMap.keySet();
		RadialBond rBond = null;
		Integer origin, destin;
		synchronized (bonds.getSynchronizationLock()) {
			for (Iterator i = bonds.iterator(); i.hasNext();) {
				rBond = (RadialBond) i.next();
				origin = rBond.getAtom1().getIndex();
				destin = rBond.getAtom2().getIndex();
				if (liveSet.contains(origin) && liveSet.contains(destin)) {
					rBond.setAtom1(atom[liveAtomMap.get(origin)]);
					rBond.setAtom2(atom[liveAtomMap.get(destin)]);
				} else {
					i.remove();
					List<Layered> l = getLayeredComponentHostedBy(rBond);
					if (l != null) {
						for (Layered x : l)
							layerBasket.remove(x);
					}
					/*
					 * store dead bonds for undoing: if a dead bond involves a live atom, rise that atomic index of the bond delegate to the ghost area. The ghost area starts from the length of the atom array, so there will not be any indicing conflict. Remember this when restoring the dead bonds.
					 */
					if (deadSet.contains(origin) && deadSet.contains(destin)) {
						if (model instanceof ReactionModel) {
							atom[deadAtomMap.get(origin)].setRadical(true);
							atom[deadAtomMap.get(destin)].setRadical(true);
						}
						RadialBond.Delegate d = addDeadBond(deadAtomMap.get(origin), deadAtomMap.get(destin), rBond);
						if (l != null)
							deadLayered.put(d, l);
					} else if (deadSet.contains(origin) && liveSet.contains(destin)) {
						if (model instanceof ReactionModel) {
							atom[deadAtomMap.get(origin)].setRadical(true);
							atom[liveAtomMap.get(destin)].setRadical(true);
						}
						RadialBond.Delegate d = addDeadBond(deadAtomMap.get(origin), liveAtomMap.get(destin) + atom.length, rBond);
						if (l != null)
							deadLayered.put(d, l);
					} else if (liveSet.contains(origin) && deadSet.contains(destin)) {
						if (model instanceof ReactionModel) {
							atom[liveAtomMap.get(origin)].setRadical(true);
							atom[deadAtomMap.get(destin)].setRadical(true);
						}
						RadialBond.Delegate d = addDeadBond(liveAtomMap.get(origin) + atom.length, deadAtomMap.get(destin), rBond);
						if (l != null)
							deadLayered.put(d, l);
					}
				}
			}
		}

		if (!deadBonds.isEmpty()) {
			if (useJmol && jmolRenderer != null) {
				jmolRenderer.renderBonds();
			}
		}

		MoleculeCollection.sort(model);

		/* remove the associated angular bonds */

		if (bends.isEmpty())
			return;
		AngularBond aBond = null;
		Integer middle;
		synchronized (bends.getSynchronizationLock()) {
			for (Iterator i = bends.iterator(); i.hasNext();) {
				aBond = (AngularBond) i.next();
				origin = aBond.getAtom1().getIndex();
				destin = aBond.getAtom2().getIndex();
				middle = aBond.getAtom3().getIndex();
				if (liveSet.contains(origin) && liveSet.contains(destin) && liveSet.contains(middle)) {
					aBond.setAtom1(atom[liveAtomMap.get(origin)]);
					aBond.setAtom2(atom[liveAtomMap.get(destin)]);
					aBond.setAtom3(atom[liveAtomMap.get(middle)]);
				} else {
					i.remove();
					/* explanation see the corresponding code of radial bonds */
					if (deadSet.contains(origin) && deadSet.contains(destin) && deadSet.contains(middle)) {
						addDeadBend(deadAtomMap.get(origin), deadAtomMap.get(destin), deadAtomMap.get(middle), aBond);
					} else if (liveSet.contains(origin) && deadSet.contains(destin) && deadSet.contains(middle)) {
						addDeadBend(liveAtomMap.get(origin) + atom.length, deadAtomMap.get(destin), deadAtomMap.get(middle), aBond);
					} else if (deadSet.contains(origin) && liveSet.contains(destin) && deadSet.contains(middle)) {
						addDeadBend(deadAtomMap.get(origin), liveAtomMap.get(destin) + atom.length, deadAtomMap.get(middle), aBond);
					} else if (deadSet.contains(origin) && deadSet.contains(destin) && liveSet.contains(middle)) {
						addDeadBend(deadAtomMap.get(origin), deadAtomMap.get(destin), liveAtomMap.get(middle) + atom.length, aBond);
					} else if (liveSet.contains(origin) && liveSet.contains(destin) && deadSet.contains(middle)) {
						addDeadBend(liveAtomMap.get(origin) + atom.length, liveAtomMap.get(destin) + atom.length, deadAtomMap.get(middle), aBond);
					} else if (liveSet.contains(origin) && deadSet.contains(destin) && liveSet.contains(middle)) {
						addDeadBend(liveAtomMap.get(origin) + atom.length, deadAtomMap.get(destin), liveAtomMap.get(middle) + atom.length, aBond);
					} else if (deadSet.contains(origin) && liveSet.contains(destin) && liveSet.contains(middle)) {
						addDeadBend(deadAtomMap.get(origin), liveAtomMap.get(destin) + atom.length, liveAtomMap.get(middle) + atom.length, aBond);
					}
				}
			}
		}

		if (molecules == null || molecules.isEmpty())
			setShowSites(false);
		boolean b = false;
		synchronized (molecules.getSynchronizationLock()) {
			for (Iterator it = molecules.iterator(); it.hasNext();) {
				if (it.next() instanceof MolecularObject) {
					b = true;
					break;
				}
			}
		}
		if (!b)
			setShowSites(false);

		// any non-bonded atom is supposed to be a radical
		if (model instanceof ReactionModel) {
			((ReactionModel) model).reassertFreeRadicals();
		}

	}