DRY, and fixing a startup race condition