protected Element createBlockElement(Document document, TMState block,
			Automaton container) {
		Element be = createElement(document, BLOCK_NAME, null, null);
		be.setAttribute(STATE_ID_NAME, "" + block.getID());
		if (block.getName() != null) be.setAttribute(STATE_NAME_NAME, "" + block.getName());
		be.appendChild(createElement(document, FILE_NAME, null, ""
				+ block.getInternalName()));
		// Encode position.
		be.appendChild(createElement(document, STATE_X_COORD_NAME, null, ""
				+ block.getPoint().getX()));
		be.appendChild(createElement(document, STATE_Y_COORD_NAME, null, ""
				+ block.getPoint().getY()));
		// Encode whether the block is initial.
//		State parent = block.getParentBlock();
//		Automaton a = null;
//		if (parent != null) {
//			a = (Automaton) container.getBlockMap().get(
//					parent.getInternalName());
//		}
//		if (a == null) {
//			a = container;
//		}

        //MERLIN MERLIN MERLIN MERLIN MERLIN//
        Automaton a = block.getAutomaton(); //this will fetch the parent - I see no reason to go through the block map
		if (a.getInitialState() == block)
			be.appendChild(createElement(document, STATE_INITIAL_NAME, null,
					null));
		// Encode whether the state is final.
		if (a.isFinalState(block))
			be.appendChild(createElement(document, STATE_FINAL_NAME,
							null, null));
		return be;
	}