Fixed race condition when tabs open in foreground