rough initial pass at online tm decoder