private void prepareFailTransitions() {
	Queue q = new Queue();
	for(int i = 0; i < 256; i++)
	    if (this.root.get((byte) i) != null) {
		this.root.get((byte) i).setFail(this.root);
		q.add(this.root.get((byte) i));
	    }
	this.prepareRoot();
	while (! q.isEmpty()) {
	    State<T> state = q.pop();
	    byte[] keys = state.keys();
	    for (int i = 0; i < keys.length; i++) {
		State<T> r = state;
		byte a = keys[i];
		State s = r.get(a);
		q.add(s);
		r = r.getFail();
		while (r.get(a) == null)
		    r = r.getFail();
		s.setFail(r.get(a));
		s.getOutputs().addAll(r.get(a).getOutputs());
	    }
	}
    }