Fix for parallel data race in layout code. Fixes #2308.

There might be a "cleaner" rust way to separate the scope and invoke the drop() call?