Theory of wqo and bqo and applications