int deleteConnections(float minDistance, float maxDistance, short order, BitSet bsA, BitSet bsB) {
		BitSet bsDelete = new BitSet();
		float minDistanceSquared = minDistance * minDistance;
		float maxDistanceSquared = maxDistance * maxDistance;
		if (order != JmolConstants.BOND_ORDER_NULL && (order & JmolConstants.BOND_HYDROGEN_MASK) != 0)
			order = JmolConstants.BOND_HYDROGEN_MASK;
		int nDeleted = 0;
		for (int i = bondCount; --i >= 0;) {
			Bond bond = bonds[i];
			Atom atom1 = bond.atom1;
			Atom atom2 = bond.atom2;
			if (bsA.get(atom1.atomIndex) && bsB.get(atom2.atomIndex) || bsA.get(atom2.atomIndex)
					&& bsB.get(atom1.atomIndex)) {
				if (bond.atom1.isBonded(bond.atom2)) {
					float distanceSquared = atom1.distanceSquared(atom2);
					if (distanceSquared >= minDistanceSquared && distanceSquared <= maxDistanceSquared)
						if (order == JmolConstants.BOND_ORDER_NULL
								|| order == (bond.order & ~JmolConstants.BOND_SULFUR_MASK)
								|| (order & bond.order & JmolConstants.BOND_HYDROGEN_MASK) != 0) {
							bsDelete.set(i);
							nDeleted++;
						}
				}
			}
		}
		deleteBonds(bsDelete);
		Logger.info(nDeleted + " bonds deleted");
		return nDeleted;
	}