Add context lost and restored handlers.