Fix possible concurrency exception (long-standing bug)