Make isEmpty atomic to avoid delay #1003