Add null checks
Handle shutdown in BootstrappedPeerFactory