Fix a bunch of race conditions