Structure, defects and thermal stability of delithiated olivine phosphates