Attempting to use mutex's to prevent race conditions