Synchronize access to `Names` in the presentation compiler.

This may lead to subtle errors, like the mysterious
assertion error in pickler.

Refs #1001607, #1001606

Should be backported.