Fix two concurrent bugs