beam search working at test time, other minor bug fixes