A photoelectron and energy-loss spectroscopy study of Ti and its interaction with H2, O2, N2 and NH3