Code cleanup for creating TupleStruct instances.

For safety's sake, wrap access (read/write) of global state in a mutex. Unclear
whether this can actually cause a problem in practice (at least under MRI), but
seems like an obviously unsafe thing to do and is easy to avoid.