Move all Thompson logic into engine