some race conditions solved