Fix race condition. Authors: nmcmahon1215 notcras cerensavasan