Fix a startup race condition that could lead to a NPE