Modified parse() to use beam search.