Added mutex to hopefully alleviate issues