Hotfix - make writing to metadata file slightly less suspectible to race conditions (both between threads and processes).