Change Prepare.trim to a thread-local, to fix non-determinism in tests.