Fix race condition in collect(..)