Moves lifecycle handler guarding into lifecycle. Removes ensureContextUninitialized.