layout: Enforce that flow construction is thread-safe.

Closes #1584.

r? @metajack