While we were talking, and when I was glad to believe that I had alleviated (if I may use such a term) the shock he had had in seeing me, Richard came in. 
While we were talking, and when I was glad to believe that I had alleviated the shock he had had in seeing me, Richard came in. 