Fix race conditions... I think