public byte[] array() {
		if (branches.size() > 0) {
			if (!longBranch && (codeLength >= 0x10000)) {
				longBranch = true;
				buildCode();
			}
		}

		final byte[] c = new byte[codeLength];
		int i = codeLength;

		for (ByteCell p = codeTail; p != null; p = p.prev) {
			c[--i] = p.value;
		}

		Iterator e;

		e = branches.keySet().iterator();

		while (e.hasNext()) {
			final Integer branch = (Integer) e.next();
			final int branchIndex = branch.intValue();

			final Integer inst = (Integer) branchInsts.get(branch);
			final int instIndex = inst.intValue();

			final Label label = (Label) branches.get(branch);
			final Integer target = (Integer) labels.get(label);

			Assert.isTrue(target != null, "Index of " + label + " not found");

			int diff = target.intValue() - instIndex;

			Assert.isTrue((-diff < 0x10000) && (diff < 0x10000),
					"Branch offset too large: " + diff);

			c[branchIndex] = (byte) ((diff >>> 8) & 0xff);
			c[branchIndex + 1] = (byte) (diff & 0xff);
		}

		e = longBranches.keySet().iterator();

		while (e.hasNext()) {
			final Integer branch = (Integer) e.next();
			final int branchIndex = branch.intValue();

			final Integer inst = (Integer) branchInsts.get(branch);
			final int instIndex = inst.intValue();

			final Label label = (Label) longBranches.get(branch);
			final Integer target = (Integer) labels.get(label);

			final int diff = target.intValue() - instIndex;

			c[branchIndex] = (byte) ((diff >>> 24) & 0xff);
			c[branchIndex + 1] = (byte) ((diff >>> 16) & 0xff);
			c[branchIndex + 2] = (byte) ((diff >>> 8) & 0xff);
			c[branchIndex + 3] = (byte) (diff & 0xff);
		}

		return c;
	}