refactor: minor optimizations and other small tweaks in the Thompson VM.