Fix race condition that prevented refs writing.